diff --git a/Cargo.lock b/Cargo.lock index 9d183f022..a475aa0af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2832,6 +2832,7 @@ dependencies = [ "miniz_oxide", "once_cell", "pdf-writer", + "serde", "subsetter", "svg2pdf", "ttf-parser", diff --git a/crates/typst-cli/src/args.rs b/crates/typst-cli/src/args.rs index 6505994bd..65259ab7a 100644 --- a/crates/typst-cli/src/args.rs +++ b/crates/typst-cli/src/args.rs @@ -129,7 +129,7 @@ pub struct CompileCommand { pub pdf_standard: Vec, } -/// A PDF standard. +/// A PDF standard that Typst can enforce conformance with. #[derive(Debug, Copy, Clone, Eq, PartialEq, ValueEnum)] #[allow(non_camel_case_types)] pub enum PdfStandard { diff --git a/crates/typst-pdf/Cargo.toml b/crates/typst-pdf/Cargo.toml index cdd65e828..642299452 100644 --- a/crates/typst-pdf/Cargo.toml +++ b/crates/typst-pdf/Cargo.toml @@ -27,6 +27,7 @@ miniz_oxide = { workspace = true } once_cell = { workspace = true } pdf-writer = { workspace = true } arrayvec = { workspace = true } +serde = { workspace = true } subsetter = { workspace = true } svg2pdf = { workspace = true } ttf-parser = { workspace = true } diff --git a/crates/typst-pdf/src/lib.rs b/crates/typst-pdf/src/lib.rs index 587f66cb1..7df77f10a 100644 --- a/crates/typst-pdf/src/lib.rs +++ b/crates/typst-pdf/src/lib.rs @@ -21,6 +21,7 @@ use std::ops::{Deref, DerefMut}; use base64::Engine; use pdf_writer::{Chunk, Name, Pdf, Ref, Str, TextStr}; +use serde::{Deserialize, Serialize}; use typst::diag::{bail, SourceResult, StrResult}; use typst::foundations::{Datetime, Smart}; use typst::layout::{Abs, Em, PageRanges, Transform}; @@ -128,16 +129,18 @@ impl Default for PdfStandards { } } -/// A PDF standard. +/// A PDF standard that Typst can enforce conformance with. /// /// Support for more standards is planned. -#[derive(Debug, Copy, Clone, Eq, PartialEq)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)] #[allow(non_camel_case_types)] #[non_exhaustive] pub enum PdfStandard { /// PDF 1.7. + #[serde(rename = "1.7")] V_1_7, /// PDF/A-2b. + #[serde(rename = "a-2b")] A_2b, }