summaryrefslogtreecommitdiff
path: root/crates/typst-cli
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-cli')
-rw-r--r--crates/typst-cli/src/args.rs32
-rw-r--r--crates/typst-cli/src/compile.rs39
2 files changed, 56 insertions, 15 deletions
diff --git a/crates/typst-cli/src/args.rs b/crates/typst-cli/src/args.rs
index 76f64727..fd0eb5f0 100644
--- a/crates/typst-cli/src/args.rs
+++ b/crates/typst-cli/src/args.rs
@@ -467,15 +467,45 @@ display_possible_values!(Feature);
#[derive(Debug, Copy, Clone, Eq, PartialEq, ValueEnum)]
#[allow(non_camel_case_types)]
pub enum PdfStandard {
+ /// PDF 1.4.
+ #[value(name = "1.4")]
+ V_1_4,
+ /// PDF 1.5.
+ #[value(name = "1.5")]
+ V_1_5,
+ /// PDF 1.5.
+ #[value(name = "1.6")]
+ V_1_6,
/// PDF 1.7.
#[value(name = "1.7")]
V_1_7,
+ /// PDF 2.0.
+ #[value(name = "2.0")]
+ V_2_0,
+ /// PDF/A-1b.
+ #[value(name = "a-1b")]
+ A_1b,
/// PDF/A-2b.
#[value(name = "a-2b")]
A_2b,
- /// PDF/A-3b.
+ /// PDF/A-2u.
+ #[value(name = "a-2u")]
+ A_2u,
+ /// PDF/A-3u.
#[value(name = "a-3b")]
A_3b,
+ /// PDF/A-3u.
+ #[value(name = "a-3u")]
+ A_3u,
+ /// PDF/A-4.
+ #[value(name = "a-4")]
+ A_4,
+ /// PDF/A-4f.
+ #[value(name = "a-4f")]
+ A_4f,
+ /// PDF/A-4e.
+ #[value(name = "a-4e")]
+ A_4e,
}
display_possible_values!(PdfStandard);
diff --git a/crates/typst-cli/src/compile.rs b/crates/typst-cli/src/compile.rs
index ae71e298..4edb4c32 100644
--- a/crates/typst-cli/src/compile.rs
+++ b/crates/typst-cli/src/compile.rs
@@ -63,8 +63,7 @@ pub struct CompileConfig {
/// Opens the output file with the default viewer or a specific program after
/// compilation.
pub open: Option<Option<String>>,
- /// One (or multiple comma-separated) PDF standards that Typst will enforce
- /// conformance with.
+ /// A list of standards the PDF should conform to.
pub pdf_standards: PdfStandards,
/// A path to write a Makefile rule describing the current compilation.
pub make_deps: Option<PathBuf>,
@@ -130,18 +129,9 @@ impl CompileConfig {
PageRanges::new(export_ranges.iter().map(|r| r.0.clone()).collect())
});
- let pdf_standards = {
- let list = args
- .pdf_standard
- .iter()
- .map(|standard| match standard {
- PdfStandard::V_1_7 => typst_pdf::PdfStandard::V_1_7,
- PdfStandard::A_2b => typst_pdf::PdfStandard::A_2b,
- PdfStandard::A_3b => typst_pdf::PdfStandard::A_3b,
- })
- .collect::<Vec<_>>();
- PdfStandards::new(&list)?
- };
+ let pdf_standards = PdfStandards::new(
+ &args.pdf_standard.iter().copied().map(Into::into).collect::<Vec<_>>(),
+ )?;
#[cfg(feature = "http-server")]
let server = match watch {
@@ -295,6 +285,7 @@ fn export_pdf(document: &PagedDocument, config: &CompileConfig) -> SourceResult<
})
}
};
+
let options = PdfOptions {
ident: Smart::Auto,
timestamp,
@@ -765,3 +756,23 @@ impl<'a> codespan_reporting::files::Files<'a> for SystemWorld {
})
}
}
+
+impl From<PdfStandard> for typst_pdf::PdfStandard {
+ fn from(standard: PdfStandard) -> Self {
+ match standard {
+ PdfStandard::V_1_4 => typst_pdf::PdfStandard::V_1_4,
+ PdfStandard::V_1_5 => typst_pdf::PdfStandard::V_1_5,
+ PdfStandard::V_1_6 => typst_pdf::PdfStandard::V_1_6,
+ PdfStandard::V_1_7 => typst_pdf::PdfStandard::V_1_7,
+ PdfStandard::V_2_0 => typst_pdf::PdfStandard::V_2_0,
+ PdfStandard::A_1b => typst_pdf::PdfStandard::A_1b,
+ PdfStandard::A_2b => typst_pdf::PdfStandard::A_2b,
+ PdfStandard::A_2u => typst_pdf::PdfStandard::A_2u,
+ PdfStandard::A_3b => typst_pdf::PdfStandard::A_3b,
+ PdfStandard::A_3u => typst_pdf::PdfStandard::A_3u,
+ PdfStandard::A_4 => typst_pdf::PdfStandard::A_4,
+ PdfStandard::A_4f => typst_pdf::PdfStandard::A_4f,
+ PdfStandard::A_4e => typst_pdf::PdfStandard::A_4e,
+ }
+ }
+}