blitz-pdf 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +266 -12
- package/THIRD_PARTY_NOTICES.md +4 -2
- package/dist/browser.d.ts +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/document-options.d.ts +36 -0
- package/dist/document-options.d.ts.map +1 -0
- package/dist/document-options.js +236 -0
- package/dist/document-options.js.map +1 -0
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/options.d.ts +35 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +21 -14
- package/dist/options.js.map +1 -1
- package/dist/types.d.ts +71 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +7 -0
- package/dist/validation.js.map +1 -0
- package/examples/zugferd.mjs +41 -0
- package/licenses/RUST_DEPENDENCIES.txt +27 -0
- package/package.json +3 -2
- package/src/browser.ts +1 -1
- package/src/document-options.ts +218 -0
- package/src/node.ts +1 -1
- package/src/options.ts +18 -13
- package/src/types.ts +76 -1
- package/src/validation.ts +6 -0
- package/vendor/README.md +27 -2
- package/vendor/krilla/.cargo-ok +1 -0
- package/vendor/krilla/.cargo_vcs_info.json +6 -0
- package/vendor/krilla/Cargo.lock +1357 -0
- package/vendor/krilla/Cargo.toml +165 -0
- package/vendor/krilla/LICENSE_APACHE +202 -0
- package/vendor/krilla/LICENSE_MIT +21 -0
- package/vendor/krilla/README.md +156 -0
- package/vendor/krilla/examples/basic.rs +117 -0
- package/vendor/krilla/examples/empty_document.rs +25 -0
- package/vendor/krilla/examples/parley.rs +174 -0
- package/vendor/krilla/examples/simple_text.rs +118 -0
- package/vendor/krilla/examples/stream_builder.rs +93 -0
- package/vendor/krilla/icc/LICENSE +116 -0
- package/vendor/krilla/icc/README.md +1 -0
- package/vendor/krilla/icc/sGrey-v2-magic.icc +0 -0
- package/vendor/krilla/icc/sGrey-v4.icc +0 -0
- package/vendor/krilla/icc/sRGB-v2-magic.icc +0 -0
- package/vendor/krilla/icc/sRGB-v4.icc +0 -0
- package/vendor/krilla/src/chunk_container.rs +503 -0
- package/vendor/krilla/src/configure/PDF_A1.md +227 -0
- package/vendor/krilla/src/configure/PDF_A2.md +269 -0
- package/vendor/krilla/src/configure/PDF_A3.md +31 -0
- package/vendor/krilla/src/configure/PDF_A4.md +211 -0
- package/vendor/krilla/src/configure/PDF_UA1.md +202 -0
- package/vendor/krilla/src/configure/README.md +23 -0
- package/vendor/krilla/src/configure/mod.rs +197 -0
- package/vendor/krilla/src/configure/validate.rs +1244 -0
- package/vendor/krilla/src/configure/version.rs +134 -0
- package/vendor/krilla/src/content.rs +1352 -0
- package/vendor/krilla/src/data.rs +49 -0
- package/vendor/krilla/src/document.rs +156 -0
- package/vendor/krilla/src/error.rs +170 -0
- package/vendor/krilla/src/geom.rs +341 -0
- package/vendor/krilla/src/graphics/blend.rs +46 -0
- package/vendor/krilla/src/graphics/color.rs +552 -0
- package/vendor/krilla/src/graphics/graphic.rs +30 -0
- package/vendor/krilla/src/graphics/graphics_state.rs +251 -0
- package/vendor/krilla/src/graphics/icc.rs +218 -0
- package/vendor/krilla/src/graphics/image.rs +835 -0
- package/vendor/krilla/src/graphics/mask.rs +128 -0
- package/vendor/krilla/src/graphics/mod.rs +14 -0
- package/vendor/krilla/src/graphics/paint.rs +434 -0
- package/vendor/krilla/src/graphics/separation.rs +86 -0
- package/vendor/krilla/src/graphics/shading_function.rs +865 -0
- package/vendor/krilla/src/graphics/shading_pattern.rs +60 -0
- package/vendor/krilla/src/graphics/tiling_pattern.rs +119 -0
- package/vendor/krilla/src/graphics/xobject.rs +150 -0
- package/vendor/krilla/src/interactive/action.rs +68 -0
- package/vendor/krilla/src/interactive/annotation.rs +283 -0
- package/vendor/krilla/src/interactive/destination.rs +289 -0
- package/vendor/krilla/src/interactive/mod.rs +3 -0
- package/vendor/krilla/src/interchange/embed.rs +240 -0
- package/vendor/krilla/src/interchange/metadata.rs +564 -0
- package/vendor/krilla/src/interchange/mod.rs +4 -0
- package/vendor/krilla/src/interchange/outline.rs +263 -0
- package/vendor/krilla/src/interchange/tagging/fmt.rs +733 -0
- package/vendor/krilla/src/interchange/tagging/generate.toml +474 -0
- package/vendor/krilla/src/interchange/tagging/generated.rs +4754 -0
- package/vendor/krilla/src/interchange/tagging/mod.rs +1324 -0
- package/vendor/krilla/src/interchange/tagging/tag.rs +686 -0
- package/vendor/krilla/src/lib.rs +179 -0
- package/vendor/krilla/src/num.rs +26 -0
- package/vendor/krilla/src/page.rs +612 -0
- package/vendor/krilla/src/pdf.rs +313 -0
- package/vendor/krilla/src/resource.rs +436 -0
- package/vendor/krilla/src/serialize.rs +1101 -0
- package/vendor/krilla/src/stream.rs +368 -0
- package/vendor/krilla/src/surface.rs +664 -0
- package/vendor/krilla/src/text/cid.rs +488 -0
- package/vendor/krilla/src/text/font.rs +351 -0
- package/vendor/krilla/src/text/glyph/bitmap.rs +81 -0
- package/vendor/krilla/src/text/glyph/colr.rs +581 -0
- package/vendor/krilla/src/text/glyph/mod.rs +205 -0
- package/vendor/krilla/src/text/glyph/outline.rs +72 -0
- package/vendor/krilla/src/text/glyph/svg.rs +34 -0
- package/vendor/krilla/src/text/group.rs +463 -0
- package/vendor/krilla/src/text/mod.rs +232 -0
- package/vendor/krilla/src/text/shape.rs +102 -0
- package/vendor/krilla/src/text/type3.rs +514 -0
- package/vendor/krilla/src/util.rs +286 -0
- package/vendor/stylo/properties/longhands.toml +0 -1
- package/vendor/stylo/stylesheets/rule_parser.rs +1 -1
- package/wasm/blitz_pdf.js +10 -5
- package/wasm/blitz_pdf_bg.wasm +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
use pdf_writer::Pdf;
|
|
2
|
+
use std::sync::LazyLock;
|
|
3
|
+
use xmp_writer::XmpWriter;
|
|
4
|
+
|
|
5
|
+
#[cfg(feature = "raster-images")]
|
|
6
|
+
use crate::graphics::icc::ICCMetadata;
|
|
7
|
+
use crate::graphics::icc::ICCProfile;
|
|
8
|
+
#[cfg(feature = "raster-images")]
|
|
9
|
+
use crate::image::BitsPerComponent;
|
|
10
|
+
|
|
11
|
+
/// The version of a PDF document.
|
|
12
|
+
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Default)]
|
|
13
|
+
pub enum PdfVersion {
|
|
14
|
+
/// PDF 1.4.
|
|
15
|
+
Pdf14,
|
|
16
|
+
/// PDF 1.5.
|
|
17
|
+
Pdf15,
|
|
18
|
+
/// PDF 1.6.
|
|
19
|
+
Pdf16,
|
|
20
|
+
/// PDF 1.7.
|
|
21
|
+
#[default]
|
|
22
|
+
Pdf17,
|
|
23
|
+
/// PDF 2.0.
|
|
24
|
+
Pdf20,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
impl PdfVersion {
|
|
28
|
+
/// The minimum supported PDF version.
|
|
29
|
+
pub const MIN: Self = Self::Pdf14;
|
|
30
|
+
/// The maximum supported PDF version.
|
|
31
|
+
pub const MAX: Self = Self::Pdf20;
|
|
32
|
+
|
|
33
|
+
pub(crate) fn write_xmp(&self, xmp: &mut XmpWriter) {
|
|
34
|
+
match self {
|
|
35
|
+
PdfVersion::Pdf14 => xmp.pdf_version("1.4"),
|
|
36
|
+
PdfVersion::Pdf15 => xmp.pdf_version("1.5"),
|
|
37
|
+
PdfVersion::Pdf16 => xmp.pdf_version("1.6"),
|
|
38
|
+
PdfVersion::Pdf17 => xmp.pdf_version("1.7"),
|
|
39
|
+
PdfVersion::Pdf20 => xmp.pdf_version("2.0"),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// Get a string representation of the PDF version.
|
|
44
|
+
pub fn as_str(self) -> &'static str {
|
|
45
|
+
match self {
|
|
46
|
+
PdfVersion::Pdf14 => "PDF 1.4",
|
|
47
|
+
PdfVersion::Pdf15 => "PDF 1.5",
|
|
48
|
+
PdfVersion::Pdf16 => "PDF 1.6",
|
|
49
|
+
PdfVersion::Pdf17 => "PDF 1.7",
|
|
50
|
+
PdfVersion::Pdf20 => "PDF 2.0",
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
pub(crate) fn rgb_icc(&self) -> ICCProfile<3> {
|
|
55
|
+
match self {
|
|
56
|
+
PdfVersion::Pdf14 => SRGB_V2_ICC.clone(),
|
|
57
|
+
PdfVersion::Pdf15 => SRGB_V2_ICC.clone(),
|
|
58
|
+
PdfVersion::Pdf16 => SRGB_V2_ICC.clone(),
|
|
59
|
+
PdfVersion::Pdf17 => SRGB_V4_ICC.clone(),
|
|
60
|
+
PdfVersion::Pdf20 => SRGB_V4_ICC.clone(),
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
pub(crate) fn grey_icc(&self) -> ICCProfile<1> {
|
|
65
|
+
match self {
|
|
66
|
+
PdfVersion::Pdf14 => GREY_V2_ICC.clone(),
|
|
67
|
+
PdfVersion::Pdf15 => GREY_V2_ICC.clone(),
|
|
68
|
+
PdfVersion::Pdf16 => GREY_V2_ICC.clone(),
|
|
69
|
+
PdfVersion::Pdf17 => GREY_V4_ICC.clone(),
|
|
70
|
+
PdfVersion::Pdf20 => GREY_V4_ICC.clone(),
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#[cfg(feature = "raster-images")]
|
|
75
|
+
pub(crate) fn supports_icc(&self, metadata: &ICCMetadata) -> bool {
|
|
76
|
+
match self {
|
|
77
|
+
PdfVersion::Pdf14 => metadata.major <= 2 && metadata.minor <= 2,
|
|
78
|
+
PdfVersion::Pdf15 => metadata.major <= 4,
|
|
79
|
+
PdfVersion::Pdf16 => metadata.major <= 4 && metadata.minor <= 1,
|
|
80
|
+
PdfVersion::Pdf17 => metadata.major <= 4 && metadata.minor <= 2,
|
|
81
|
+
PdfVersion::Pdf20 => metadata.major <= 4 && metadata.minor <= 2,
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#[cfg(feature = "raster-images")]
|
|
86
|
+
pub(crate) fn supports_bit_depth(&self, bits_per_component: BitsPerComponent) -> bool {
|
|
87
|
+
match bits_per_component {
|
|
88
|
+
BitsPerComponent::Eight => true,
|
|
89
|
+
BitsPerComponent::Sixteen => *self >= PdfVersion::Pdf15,
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// Whether the version supports the `/AF` key.
|
|
94
|
+
///
|
|
95
|
+
/// Note that support for the `/AF` key may instead be provided by the
|
|
96
|
+
/// PDF/A-3 standard for 1.x series files.
|
|
97
|
+
pub(crate) fn specifies_associated_files(&self) -> bool {
|
|
98
|
+
match self {
|
|
99
|
+
PdfVersion::Pdf14 | PdfVersion::Pdf15 | PdfVersion::Pdf16 | PdfVersion::Pdf17 => false,
|
|
100
|
+
PdfVersion::Pdf20 => true,
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
pub(crate) fn set_version(&self, pdf: &mut Pdf) {
|
|
105
|
+
match self {
|
|
106
|
+
PdfVersion::Pdf14 => pdf.set_version(1, 4),
|
|
107
|
+
PdfVersion::Pdf15 => pdf.set_version(1, 5),
|
|
108
|
+
PdfVersion::Pdf16 => pdf.set_version(1, 6),
|
|
109
|
+
PdfVersion::Pdf17 => pdf.set_version(1, 7),
|
|
110
|
+
PdfVersion::Pdf20 => pdf.set_version(2, 0),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
pub(crate) fn deprecates_proc_sets(&self) -> bool {
|
|
115
|
+
*self >= PdfVersion::Pdf20
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
pub(crate) fn deprecates_cid_set(&self) -> bool {
|
|
119
|
+
*self >= PdfVersion::Pdf20
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/// The ICC v4 profile for the SRGB color space.
|
|
124
|
+
static SRGB_V4_ICC: LazyLock<ICCProfile<3>> =
|
|
125
|
+
LazyLock::new(|| ICCProfile::new(include_bytes!("../../icc/sRGB-v4.icc")).unwrap());
|
|
126
|
+
/// The ICC v2 profile for the SRGB color space.
|
|
127
|
+
static SRGB_V2_ICC: LazyLock<ICCProfile<3>> =
|
|
128
|
+
LazyLock::new(|| ICCProfile::new(include_bytes!("../../icc/sRGB-v2-magic.icc")).unwrap());
|
|
129
|
+
/// The ICC v4 profile for the sgray color space.
|
|
130
|
+
static GREY_V4_ICC: LazyLock<ICCProfile<1>> =
|
|
131
|
+
LazyLock::new(|| ICCProfile::new(include_bytes!("../../icc/sGrey-v4.icc")).unwrap());
|
|
132
|
+
/// The ICC v2 profile for the sgray color space.
|
|
133
|
+
static GREY_V2_ICC: LazyLock<ICCProfile<1>> =
|
|
134
|
+
LazyLock::new(|| ICCProfile::new(include_bytes!("../../icc/sGrey-v2-magic.icc")).unwrap());
|