summaryrefslogtreecommitdiff
path: root/crates/typst-pdf
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-11-29 11:49:14 +0100
committerLaurenz <laurmaedje@gmail.com>2023-11-29 11:53:09 +0100
commitaf9d8727e1984502cde553c1d722932ff1f15d94 (patch)
treee964ceddbc057f3a6ef894255be2e6fbd7218bc5 /crates/typst-pdf
parent2007f30b1137eec20678e3e9cd96788dc6c1b222 (diff)
Don't write multiple authors in XMP metadata
Fixes #2556.
Diffstat (limited to 'crates/typst-pdf')
-rw-r--r--crates/typst-pdf/src/lib.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/crates/typst-pdf/src/lib.rs b/crates/typst-pdf/src/lib.rs
index 005b5a9e..0c82cd90 100644
--- a/crates/typst-pdf/src/lib.rs
+++ b/crates/typst-pdf/src/lib.rs
@@ -183,8 +183,25 @@ fn write_catalog(ctx: &mut PdfContext, ident: Option<&str>, timestamp: Option<Da
let authors = &ctx.document.author;
if !authors.is_empty() {
- info.author(TextStr(&authors.join(", ")));
- xmp.creator(authors.iter().map(|s| s.as_str()));
+ // Turns out that if the authors are given in both the document
+ // information dictionary and the XMP metadata, Acrobat takes a little
+ // bit of both: The first author from the document information
+ // dictionary and the remaining authors from the XMP metadata.
+ //
+ // To fix this for Acrobat, we could omit the remaining authors or all
+ // metadata from the document information catalog (it is optional) and
+ // only write XMP. However, not all other tools (including Apple
+ // Preview) read the XMP data. This means we do want to include all
+ // authors in the document information dictionary.
+ //
+ // Thus, the only alternative is to fold all authors into a single
+ // `<rdf:li>` in the XMP metadata. This is, in fact, exactly what the
+ // PDF/A spec Part 1 section 6.7.3 has to say about the matter. It's a
+ // bit weird to not use the array (and it makes Acrobat show the author
+ // list in quotes), but there's not much we can do about that.
+ let joined = authors.join(", ");
+ info.author(TextStr(&joined));
+ xmp.creator([joined.as_str()]);
}
let creator = eco_format!("Typst {}", env!("CARGO_PKG_VERSION"));