diff --git a/Cargo.lock b/Cargo.lock index f3dca3db4..5f386790f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1345,6 +1345,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.3.0" +source = "git+https://github.com/LaurenzV/krilla?rev=5978f97#5978f97aaacc9233d564b76773400218a7cdc21d" dependencies = [ "base64", "bumpalo", diff --git a/Cargo.toml b/Cargo.toml index acaaca107..5d4699609 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ if_chain = "1" image = { version = "0.25.5", default-features = false, features = ["png", "jpeg", "gif"] } indexmap = { version = "2", features = ["serde"] } kamadak-exif = "0.6" -krilla = { path = "../krilla/crates/krilla", features = ["svg", "raster-images", "comemo", "rayon"] } +krilla = { git = "https://github.com/LaurenzV/krilla", rev = "5978f97", features = ["svg", "raster-images", "comemo", "rayon"] } kurbo = "0.11" libfuzzer-sys = "0.4" lipsum = "0.9" diff --git a/crates/typst-pdf/src/convert.rs b/crates/typst-pdf/src/convert.rs index 6a30ad495..5931edee9 100644 --- a/crates/typst-pdf/src/convert.rs +++ b/crates/typst-pdf/src/convert.rs @@ -1,6 +1,7 @@ use ecow::EcoVec; use krilla::annotation::Annotation; use krilla::destination::{NamedDestination, XyzDestination}; +use krilla::embed::EmbedError; use krilla::error::KrillaError; use krilla::page::PageLabel; use krilla::path::PathBuilder; @@ -421,55 +422,77 @@ fn finish(document: Document, gc: GlobalContext) -> SourceResult> { } ValidationError::Transparency(loc) => { error!(get_span(*loc), "{prefix} document contains transparency"; - hint: "remove any transparency from your \ - document (e.g. fills with opacity)"; - hint: "you might have to convert certain SVGs into a bitmap image if \ - they contain transparency"; - hint: "export using a different standard that supports transparency" - ) + hint: "remove any transparency from your \ + document (e.g. fills with opacity)"; + hint: "you might have to convert certain SVGs into a bitmap image if \ + they contain transparency"; + hint: "export using a different standard that supports transparency" + ) } ValidationError::ImageInterpolation(loc) => { error!(get_span(*loc), "{prefix} the image has smooth interpolation"; - hint: "such images are not supported in this export mode" - ) + hint: "such images are not supported in this export mode" + ) } - ValidationError::EmbeddedFile(_) => { - error!(Span::detached(), "{prefix} document contains an embedded file"; - hint: "embedded files are not supported in this export mode" - ) + ValidationError::EmbeddedFile(e, s) => { + let span = get_span(*s); + match e { + EmbedError::Existence => { + error!(span, "{prefix} document contains an embedded file"; + hint: "embedded files are not supported in this export mode" + ) + } + EmbedError::MissingDate => { + error!(span, "{prefix} document date is missing"; + hint: "the document date needs to be set when embedding files" + ) + } + EmbedError::MissingDescription => { + error!(span, "{prefix} file description is missing") + } + EmbedError::MissingMimeType => { + error!(span, "{prefix} file mime type is missing") + } + } } - // The below errors cannot occur yet, only once Typst supports full PDF/A // and PDF/UA. // But let's still add a message just to be on the safe side. ValidationError::MissingAnnotationAltText => { error!(Span::detached(), "{prefix} missing annotation alt text"; - hint: "please report this as a bug") + hint: "please report this as a bug" + ) } ValidationError::MissingAltText => { error!(Span::detached(), "{prefix} missing alt text"; - hint: "make sure your images and formulas have alt text") + hint: "make sure your images and formulas have alt text" + ) } ValidationError::NoDocumentLanguage => { error!(Span::detached(), "{prefix} missing document language"; - hint: "set the language of the document") + hint: "set the language of the document" + ) } // Needs to be set by typst-pdf. ValidationError::MissingHeadingTitle => { error!(Span::detached(), "{prefix} missing heading title"; - hint: "please report this as a bug") + hint: "please report this as a bug" + ) } ValidationError::MissingDocumentOutline => { error!(Span::detached(), "{prefix} missing document outline"; - hint: "please report this as a bug") + hint: "please report this as a bug" + ) } ValidationError::MissingTagging => { error!(Span::detached(), "{prefix} missing document tags"; - hint: "please report this as a bug") + hint: "please report this as a bug" + ) } ValidationError::NoDocumentTitle => { error!(Span::detached(), "{prefix} missing document title"; - hint: "set the title of the document") + hint: "set the title of the document" + ) } } }) diff --git a/crates/typst-pdf/src/embed.rs b/crates/typst-pdf/src/embed.rs index 547d60dd5..0d501184a 100644 --- a/crates/typst-pdf/src/embed.rs +++ b/crates/typst-pdf/src/embed.rs @@ -42,6 +42,7 @@ pub(crate) fn embed_files( association_kind, data: data.into(), compress: true, + location: Some(embed.span().into_raw().get()), }; if document.embed_file(file).is_none() {