Serialize and Deserialize for PdfStandard (#5108)

This commit is contained in:
Laurenz 2024-10-03 21:40:42 +02:00 committed by GitHub
parent 4e6021cf88
commit 60f9f66950
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 3 deletions

1
Cargo.lock generated
View File

@ -2832,6 +2832,7 @@ dependencies = [
"miniz_oxide",
"once_cell",
"pdf-writer",
"serde",
"subsetter",
"svg2pdf",
"ttf-parser",

View File

@ -129,7 +129,7 @@ pub struct CompileCommand {
pub pdf_standard: Vec<PdfStandard>,
}
/// 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 {

View File

@ -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 }

View File

@ -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,
}