diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-10-01 11:24:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-01 09:24:18 +0000 |
| commit | a0093ad8a7906068b4bd641c28f614804d3e099d (patch) | |
| tree | 85110d3e95b08c119cfe37fc3d7014511e41a453 /crates/typst-cli/src/compile.rs | |
| parent | 8eee3ec8d1b4d960017cb558887bd6180cc99cea (diff) | |
Minimal PDF/A support (#5075)
Co-authored-by: Martin Haug <mhaug@live.de>
Diffstat (limited to 'crates/typst-cli/src/compile.rs')
| -rw-r--r-- | crates/typst-cli/src/compile.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/typst-cli/src/compile.rs b/crates/typst-cli/src/compile.rs index 58745c80..b1786941 100644 --- a/crates/typst-cli/src/compile.rs +++ b/crates/typst-cli/src/compile.rs @@ -16,10 +16,11 @@ use typst::layout::{Frame, Page, PageRanges}; use typst::model::Document; use typst::syntax::{FileId, Source, Span}; use typst::WorldExt; -use typst_pdf::PdfOptions; +use typst_pdf::{PdfOptions, PdfStandards}; use crate::args::{ CompileCommand, DiagnosticFormat, Input, Output, OutputFormat, PageRangeArgument, + PdfStandard, }; use crate::timings::Timer; use crate::watch::Status; @@ -78,6 +79,19 @@ impl CompileCommand { ) }) } + + /// The PDF standards to try to conform with. + pub fn pdf_standards(&self) -> StrResult<PdfStandards> { + let list = self + .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, + }) + .collect::<Vec<_>>(); + PdfStandards::new(&list) + } } /// Execute a compilation command. @@ -179,6 +193,7 @@ fn export_pdf(document: &Document, command: &CompileCommand) -> SourceResult<()> command.common.creation_timestamp.unwrap_or_else(chrono::Utc::now), ), page_ranges: command.exported_page_ranges(), + standards: command.pdf_standards().at(Span::detached())?, }; let buffer = typst_pdf::pdf(document, &options)?; command |
