This commit is contained in:
Laurenz Stampfl 2025-03-11 23:12:19 +01:00
parent 644996302a
commit 385061256b
4 changed files with 46 additions and 21 deletions

1
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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;
@ -433,43 +434,65 @@ fn finish(document: Document, gc: GlobalContext) -> SourceResult<Vec<u8>> {
hint: "such images are not supported in this export mode"
)
}
ValidationError::EmbeddedFile(_) => {
error!(Span::detached(), "{prefix} document contains an embedded file";
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"
)
}
}
})

View File

@ -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() {