From c55901e972f6671ecfe05358a96f85f34c703cc0 Mon Sep 17 00:00:00 2001 From: Laurenz Stampfl <47084093+LaurenzV@users.noreply.github.com> Date: Tue, 26 Sep 2023 10:47:25 +0200 Subject: [PATCH] Embed the current Typst version in the PDF (#2236) --- crates/typst/src/export/pdf/mod.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/typst/src/export/pdf/mod.rs b/crates/typst/src/export/pdf/mod.rs index 4043c928e..3d0b91358 100644 --- a/crates/typst/src/export/pdf/mod.rs +++ b/crates/typst/src/export/pdf/mod.rs @@ -15,7 +15,7 @@ use std::collections::{BTreeMap, HashMap}; use std::hash::Hash; use std::num::NonZeroUsize; -use ecow::EcoString; +use ecow::{eco_format, EcoString}; use pdf_writer::types::Direction; use pdf_writer::writers::PageLabel; use pdf_writer::{Finish, Name, PdfWriter, Ref, TextStr}; @@ -133,6 +133,10 @@ fn write_catalog(ctx: &mut PdfContext) { xmp.creator(authors.iter().map(|s| s.as_str())); } + let creator = eco_format!("Typst {}", env!("CARGO_PKG_VERSION")); + info.creator(TextStr(&creator)); + xmp.creator_tool(&creator); + let keywords = &ctx.document.keywords; if !keywords.is_empty() { let joined = keywords.join(", "); @@ -140,9 +144,7 @@ fn write_catalog(ctx: &mut PdfContext) { xmp.pdf_keywords(&joined); } - info.creator(TextStr("Typst")); info.finish(); - xmp.creator_tool("Typst"); xmp.num_pages(ctx.document.pages.len() as u32); xmp.format("application/pdf"); xmp.language(ctx.languages.keys().map(|lang| LangId(lang.as_str())));