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.
Files changed (114) hide show
  1. package/README.md +266 -12
  2. package/THIRD_PARTY_NOTICES.md +4 -2
  3. package/dist/browser.d.ts +1 -1
  4. package/dist/browser.d.ts.map +1 -1
  5. package/dist/document-options.d.ts +36 -0
  6. package/dist/document-options.d.ts.map +1 -0
  7. package/dist/document-options.js +236 -0
  8. package/dist/document-options.js.map +1 -0
  9. package/dist/node.d.ts +1 -1
  10. package/dist/node.d.ts.map +1 -1
  11. package/dist/options.d.ts +35 -1
  12. package/dist/options.d.ts.map +1 -1
  13. package/dist/options.js +21 -14
  14. package/dist/options.js.map +1 -1
  15. package/dist/types.d.ts +71 -1
  16. package/dist/types.d.ts.map +1 -1
  17. package/dist/validation.d.ts +2 -0
  18. package/dist/validation.d.ts.map +1 -0
  19. package/dist/validation.js +7 -0
  20. package/dist/validation.js.map +1 -0
  21. package/examples/zugferd.mjs +41 -0
  22. package/licenses/RUST_DEPENDENCIES.txt +27 -0
  23. package/package.json +3 -2
  24. package/src/browser.ts +1 -1
  25. package/src/document-options.ts +218 -0
  26. package/src/node.ts +1 -1
  27. package/src/options.ts +18 -13
  28. package/src/types.ts +76 -1
  29. package/src/validation.ts +6 -0
  30. package/vendor/README.md +27 -2
  31. package/vendor/krilla/.cargo-ok +1 -0
  32. package/vendor/krilla/.cargo_vcs_info.json +6 -0
  33. package/vendor/krilla/Cargo.lock +1357 -0
  34. package/vendor/krilla/Cargo.toml +165 -0
  35. package/vendor/krilla/LICENSE_APACHE +202 -0
  36. package/vendor/krilla/LICENSE_MIT +21 -0
  37. package/vendor/krilla/README.md +156 -0
  38. package/vendor/krilla/examples/basic.rs +117 -0
  39. package/vendor/krilla/examples/empty_document.rs +25 -0
  40. package/vendor/krilla/examples/parley.rs +174 -0
  41. package/vendor/krilla/examples/simple_text.rs +118 -0
  42. package/vendor/krilla/examples/stream_builder.rs +93 -0
  43. package/vendor/krilla/icc/LICENSE +116 -0
  44. package/vendor/krilla/icc/README.md +1 -0
  45. package/vendor/krilla/icc/sGrey-v2-magic.icc +0 -0
  46. package/vendor/krilla/icc/sGrey-v4.icc +0 -0
  47. package/vendor/krilla/icc/sRGB-v2-magic.icc +0 -0
  48. package/vendor/krilla/icc/sRGB-v4.icc +0 -0
  49. package/vendor/krilla/src/chunk_container.rs +503 -0
  50. package/vendor/krilla/src/configure/PDF_A1.md +227 -0
  51. package/vendor/krilla/src/configure/PDF_A2.md +269 -0
  52. package/vendor/krilla/src/configure/PDF_A3.md +31 -0
  53. package/vendor/krilla/src/configure/PDF_A4.md +211 -0
  54. package/vendor/krilla/src/configure/PDF_UA1.md +202 -0
  55. package/vendor/krilla/src/configure/README.md +23 -0
  56. package/vendor/krilla/src/configure/mod.rs +197 -0
  57. package/vendor/krilla/src/configure/validate.rs +1244 -0
  58. package/vendor/krilla/src/configure/version.rs +134 -0
  59. package/vendor/krilla/src/content.rs +1352 -0
  60. package/vendor/krilla/src/data.rs +49 -0
  61. package/vendor/krilla/src/document.rs +156 -0
  62. package/vendor/krilla/src/error.rs +170 -0
  63. package/vendor/krilla/src/geom.rs +341 -0
  64. package/vendor/krilla/src/graphics/blend.rs +46 -0
  65. package/vendor/krilla/src/graphics/color.rs +552 -0
  66. package/vendor/krilla/src/graphics/graphic.rs +30 -0
  67. package/vendor/krilla/src/graphics/graphics_state.rs +251 -0
  68. package/vendor/krilla/src/graphics/icc.rs +218 -0
  69. package/vendor/krilla/src/graphics/image.rs +835 -0
  70. package/vendor/krilla/src/graphics/mask.rs +128 -0
  71. package/vendor/krilla/src/graphics/mod.rs +14 -0
  72. package/vendor/krilla/src/graphics/paint.rs +434 -0
  73. package/vendor/krilla/src/graphics/separation.rs +86 -0
  74. package/vendor/krilla/src/graphics/shading_function.rs +865 -0
  75. package/vendor/krilla/src/graphics/shading_pattern.rs +60 -0
  76. package/vendor/krilla/src/graphics/tiling_pattern.rs +119 -0
  77. package/vendor/krilla/src/graphics/xobject.rs +150 -0
  78. package/vendor/krilla/src/interactive/action.rs +68 -0
  79. package/vendor/krilla/src/interactive/annotation.rs +283 -0
  80. package/vendor/krilla/src/interactive/destination.rs +289 -0
  81. package/vendor/krilla/src/interactive/mod.rs +3 -0
  82. package/vendor/krilla/src/interchange/embed.rs +240 -0
  83. package/vendor/krilla/src/interchange/metadata.rs +564 -0
  84. package/vendor/krilla/src/interchange/mod.rs +4 -0
  85. package/vendor/krilla/src/interchange/outline.rs +263 -0
  86. package/vendor/krilla/src/interchange/tagging/fmt.rs +733 -0
  87. package/vendor/krilla/src/interchange/tagging/generate.toml +474 -0
  88. package/vendor/krilla/src/interchange/tagging/generated.rs +4754 -0
  89. package/vendor/krilla/src/interchange/tagging/mod.rs +1324 -0
  90. package/vendor/krilla/src/interchange/tagging/tag.rs +686 -0
  91. package/vendor/krilla/src/lib.rs +179 -0
  92. package/vendor/krilla/src/num.rs +26 -0
  93. package/vendor/krilla/src/page.rs +612 -0
  94. package/vendor/krilla/src/pdf.rs +313 -0
  95. package/vendor/krilla/src/resource.rs +436 -0
  96. package/vendor/krilla/src/serialize.rs +1101 -0
  97. package/vendor/krilla/src/stream.rs +368 -0
  98. package/vendor/krilla/src/surface.rs +664 -0
  99. package/vendor/krilla/src/text/cid.rs +488 -0
  100. package/vendor/krilla/src/text/font.rs +351 -0
  101. package/vendor/krilla/src/text/glyph/bitmap.rs +81 -0
  102. package/vendor/krilla/src/text/glyph/colr.rs +581 -0
  103. package/vendor/krilla/src/text/glyph/mod.rs +205 -0
  104. package/vendor/krilla/src/text/glyph/outline.rs +72 -0
  105. package/vendor/krilla/src/text/glyph/svg.rs +34 -0
  106. package/vendor/krilla/src/text/group.rs +463 -0
  107. package/vendor/krilla/src/text/mod.rs +232 -0
  108. package/vendor/krilla/src/text/shape.rs +102 -0
  109. package/vendor/krilla/src/text/type3.rs +514 -0
  110. package/vendor/krilla/src/util.rs +286 -0
  111. package/vendor/stylo/properties/longhands.toml +0 -1
  112. package/vendor/stylo/stylesheets/rule_parser.rs +1 -1
  113. package/wasm/blitz_pdf.js +10 -5
  114. package/wasm/blitz_pdf_bg.wasm +0 -0
@@ -0,0 +1,211 @@
1
+ # Description
2
+ PDF/A-4 requires PDF version 2.0.
3
+
4
+ See `README.md` for the meaning of each color.
5
+
6
+ ## 5.1 Conforming files
7
+ - krilla does not use any deprecated features for PDF 2.0. 🟢
8
+
9
+ ## 6.1 File structure
10
+ -
11
+
12
+ ### 6.1.2 File header
13
+ - krilla only allows exporting with PDF 2.0 in this mode. 🟢
14
+ - krilla always writes the binary marker as written. 🟢
15
+
16
+ ### 6.1.3 File trailer
17
+ - The trailer is written as defined. 🟢
18
+ - krilla does not support encryption. 🟢
19
+ - krilla does not write the `Info` attribute into the trailer. 🟢
20
+
21
+ ### 6.1.4 Cross reference table
22
+ - The cross-reference table is always written as defined. 🟢
23
+
24
+ ### 6.1.5 String objects
25
+ - pdf-writer always writes an even amount of digits for hexadecimal strings. 🟢
26
+
27
+ ### 6.1.6 Stream objects
28
+ - krilla writes streams as mandated. 🟢
29
+ - krilla does not use the `F`, `FFilter` or `FDecodeParams` attributes. 🟢
30
+ - krilla does not use LZWDecode. 🟢
31
+ - krilla does not support the `Crypt` filter. 🟢
32
+
33
+ ### 6.1.7 Name objects
34
+ - krilla does not use non-UTF8 names. 🟢 (TODO: what about user supplied ones?)
35
+
36
+ ### 6.1.8 Indirect objects
37
+ - krilla always writes indirect objects as defined. 🟢
38
+
39
+ ### 6.1.9 Inline image dictionaries
40
+ - krilla does not use inline images. 🟢
41
+
42
+ ### 6.1.10 Linearized PDF
43
+ - krilla does not support linearization. 🟢
44
+
45
+ ### 6.1.11 Permissions
46
+ - krilla does not support permissions. 🟢
47
+
48
+ ### 6.1.12 Document catalog dictionary
49
+ - krilla writes the PDF file header version as 2.0 and does not write a conflicting catalog
50
+ `Version` entry. 🟢
51
+
52
+ ## 6.2 Graphics
53
+
54
+ ### 6.2.1 General
55
+
56
+ ### 6.2.2 Content streams
57
+ - krilla does not use custom content stream operators. 🟢
58
+
59
+ ### 6.2.3 Output intent
60
+ - krilla always writes the output intent for this export mode. 🟢
61
+ - krilla does not use the `DestOutputProfileRef` attribute. 🟢
62
+ - krilla does not write multiple output intents (since PDF/X and PDF/E are not supported). 🟢
63
+ - krilla only uses a Display ICC profile for output intent. 🟢
64
+ - krilla only uses RGB for output intents. 🟢
65
+
66
+ ### 6.2.4 Colour spaces
67
+ - krilla only uses device-independent colors in this export mode. 🟢
68
+ - krilla uses compatible ICC profiles. 🟢
69
+ - krilla does not use the OPM entry. 🟢
70
+ - krilla never uses CMYK profiles as the destination profile. 🟢
71
+ - krilla does not use device color spaces in this mode. 🟢
72
+ - krilla ensures the Alternate space in Separation color spaces obeys the restrictions
73
+ in the applicable clauses 🟢
74
+ - krilla does not support DeviceN color spaces. 🔵
75
+ - krilla fails export if a Separation colorant is associated with multiple different
76
+ fallback color spaces 🟢
77
+ - krilla manages the `tintTransform` function and will always write the same function for
78
+ the same color space 🟢
79
+
80
+ ### 6.2.5 Extended graphics state
81
+ - krilla does not use the `TR`, `HTO`, `TR2` or `HT` keys. 🟢
82
+ - krilla does not use halftones. 🟢
83
+ - krilla does not use the `FL`, `BG`, `BG2`, `UCR` or `URC2` functions. 🟢
84
+
85
+ ### 6.2.6 Flatness
86
+ - krilla does not use the flatness parameter. 🟢
87
+
88
+ ### 6.2.7 Images
89
+ - krilla does not use the `Alternates` or `OPI` key. 🟢
90
+ - krilla disallows the `Interpolate` key in this mode. 🟢
91
+ - krilla does not support thumbnails. 🟢
92
+ - krilla does not support JPEG2000 images. 🟢
93
+
94
+ ### 6.2.8 XObjects
95
+ - krilla does not use the `OPI` key in FormXObjects. 🟢
96
+ - krilla does not use reference XObjects. 🟢
97
+
98
+ ### 6.2.9 Transparency
99
+ - krilla uses transparency as mandated. 🟢
100
+
101
+ ### 6.2.10 Fonts
102
+ - krilla uses fonts as described in the spec. 🟢
103
+ - krilla always uses the IDENTITY-H encoding. 🟢
104
+ - krilla always embeds a CIDtoGIDMap for Type2 CID fonts. 🟢
105
+ - krilla always embeds cmaps and adds the WMode entry. 🟢
106
+ - krilla always embeds the font programs. 🟢
107
+ - krilla only uses glyphs referenced in the font. 🟢
108
+ - krilla derives the glyph width information from the font program, also for Type3 fonts. 🟢
109
+ - krilla does not use fonts in vertical writing mode. 🟢
110
+ - krilla only writes symbolic TrueType fonts. 🟢
111
+ - krilla does not use the `Encoding` entry in the font dictionary. 🟢
112
+ - krilla always writes the `ToUnicode` entry. 🟢
113
+ - krilla ensures Unicode values are always greater than 0 and not equal to U+FEFF or U+FFFE. 🟢
114
+ - krilla straight out forbids characters in the private use area. 🟢
115
+ - krilla disallows the .notdef glyph in this export mode. 🟢
116
+ - krilla checks the OpenType fsType field to ensure that fonts are legally embeddable. 🟢
117
+
118
+ ## 6.3 Annotations
119
+
120
+ ### 6.3.1 Annotation types
121
+ - krilla only supports link annotations. 🟢
122
+
123
+ ### 6.3.2 Annotation dictionaries
124
+ - Annotation dictionaries always contain the `F` key and sets the values accordingly. 🟢
125
+ - krilla does not support text annotations. 🟢
126
+
127
+ ### 6.3.3 Annotation appearances
128
+ - This section only contains provisions for readers. 🟢
129
+
130
+ ### 6.3.4 Display of annotation contents
131
+ - krilla does not use appearence dictionaries. 🟢
132
+
133
+ ## 6.4 Interactive forms
134
+
135
+ - krilla does not support interactive forms. 🟢
136
+
137
+ ## 6.5 Digital signatures
138
+
139
+ - krilla does not support digital signatures. 🟢
140
+
141
+ ## 6.6 Action
142
+
143
+ ### 6.6.1 General
144
+ - krilla does not support any of the named actions. 🟢
145
+
146
+ ### 6.6.2 Handling of JavaScript actions
147
+ - krilla does not support JavaScript actions. 🟢
148
+
149
+ ### 6.6.3 Trigger events
150
+ - krilla does not use the `AA` entry anywhere. 🟢
151
+
152
+ ### 6.6.4 Handling of GoToR, GoToE, URI and SubmitForm actions
153
+ - This section only contains provisions for readers. 🟢
154
+
155
+ ## 6.7 Metadata
156
+
157
+ ### 6.7.1 General
158
+
159
+ ### 6.7.2 Metadata streams
160
+ - krilla always requires metadata in this export mode. 🟢
161
+ - krilla does not use the `bytes` and `encoding` attributes. 🟢
162
+ - krilla uses the outlined namespaces and prefixes. 🟢
163
+ - krilla does not currently have an associated file containing the embedded file specification. However,
164
+ it seems like there is an issue with the spec because I can't find that table entry in the PDF 2.0 spec?
165
+ And no validator I tried seems to complain about this.🔴
166
+
167
+ ### 6.7.3 Version identification
168
+ - krilla always writes the required version identification parts. 🟢
169
+
170
+ ### 6.7.4 File identifiers
171
+ - krilla always adds a document identifier to the metadata. 🟢
172
+ - krilla writes a minimal `xmpMM:History` entry when a creation date is provided. 🟢
173
+
174
+ ### 6.7.5 File provenance information
175
+ - krilla writes a minimal `xmpMM:History` entry when a creation date is provided. 🟢
176
+
177
+ ## 6.8 Logical structure
178
+ - Logical structure is only optional, so krilla does not make any enforcements here, but the
179
+ recommendation is documented. 🟢
180
+
181
+ ## 6.9 Embedded files
182
+ - krilla straight out forbids embedding files in this export mode. 🟢
183
+
184
+ ## 6.10 Optional content
185
+ - krilla does not support optional content. 🟢
186
+
187
+ ## 6.11 Use of alternate presentations and transitions
188
+ - krilla does not use the `AlternatePresentations` entry. 🟢
189
+
190
+ ## 6.12 Document requirements
191
+ - krilla does not use the `Requirements` key. 🟢
192
+
193
+ ## 6.13 Print scaling
194
+ - This section only contains provisions for processors. 🟢
195
+
196
+ ## 6.14 Geospatial
197
+ - krilla does not support any of the geospatial features. 🟢
198
+
199
+ ## 6.15 Measurement Properties
200
+ - krilla does not use any of the measurement properties. 🟢
201
+
202
+ # A4-F
203
+ - krilla allows embedding any files in this export mode. 🟢
204
+ - krilla always writes the `AFRelationship`, `Desc`, `UF` and `F` strings in this case. 🟢
205
+ - krilla always writes the corresponding file identification. 🟢
206
+
207
+ # A4-E
208
+ - krilla does not support any of the 3D features. 🟢
209
+ - krilla deals similarly with embedded files similarly to A4-F. 🟢
210
+ - krilla always writes the corresponding file identification. 🟢
211
+
@@ -0,0 +1,202 @@
1
+ # Description
2
+ PDF/UA-1 requires a version <= PDF 1.7.
3
+
4
+ See `README.md` for the meaning of each color.
5
+
6
+ # 6.1 General
7
+
8
+ - krilla defaults to PDF 1.7 for this mode, but allows any PDF version up to PDF 1.7. 🟢
9
+
10
+ # 6.2 Conforming files
11
+
12
+ - krilla writes the `pdfuaid:part` attribute. 🟢
13
+ - krilla does adhere to the file format provisions. 🟢
14
+
15
+ # 6.3 Conforming reader
16
+
17
+ - Not applicable to krilla as a writer. -
18
+
19
+ # 6.4 Conforming assistive technology
20
+
21
+ - Not applicable to krilla as a writer. -
22
+
23
+ # 7.1 General
24
+
25
+ - The fact that real content should be tagged is documented. 🟣
26
+ - The fact that artifacts should be marked is documented. 🟣
27
+ - krilla never includes artifacts in the structure tree. 🟢
28
+ - krilla role maps all non-standard structure types. 🟢
29
+ - krilla does not overwrite non-standard structure types. 🟢
30
+ - krilla doesn't support any elements that flicker, flash or blink. 🟢
31
+ - The fact that information shall not be conveyed by contrast, colour, format or layout is documented. 🟣
32
+ - krilla does not support sounds. 🔵
33
+ - krilla forces the user to provide a document title. 🟢
34
+ - krilla always sets `DisplayDocTitle` to true for this mode. 🟢
35
+ - krilla can't really control if the user provides raster-based images as content. 🟠
36
+ - krilla always writes the `Suspects` value as false. 🟢
37
+
38
+ # 7.2 Text
39
+ - The fact that logical reading order should be followed is documented. 🟣
40
+ - krilla checks that every character is mapped to a codepoint. 🟢
41
+ - The fact that the user should make use of the natural language attributes is documented. 🟣
42
+ - The fact that stretchable characters should be marked with `ActualText` is documented. 🟣
43
+ - krilla allows setting the language of spans. 🟢
44
+
45
+ # 7.3 Graphics
46
+ - The fact that figures should be tagged (as a figure or an artifact) is documented. 🟣
47
+ - The fact that figures should be followed by a caption is documented. 🟣
48
+ - The fact that an alternate text should be provided to figures is checked. 🟢
49
+ - The fact graphics that possess semantic value only in combination with other graphics should be tagged with a single Figure tag for each group is documented. 🟣
50
+ - The fact that a more accessible representation should be used if it exists is documented. 🟣
51
+
52
+ # 7.4 Headings
53
+
54
+ 7.4.1:
55
+ - The fact that headings should be tagged is documented. 🟣
56
+ - krilla supports the `T` key for headings. 🟢
57
+
58
+ 7.4.2:
59
+ - The information there is hardly enforceable in an automated way, so not documented yet. 🟠
60
+
61
+ 7.4.3:
62
+ - krilla adds tags for heading levels higher than 6 as prescribed. 🟢
63
+
64
+ 7.4.4:
65
+ - The information there is hardly enforceable in an automated way, so not documented yet. 🟠
66
+
67
+ # 7.5 Tables
68
+ - The fact that tables should include headers is documented. 🟣
69
+ - krilla always requires the user to provide a table header scope. 🟢
70
+ - The fact that table tagging structures should only be used to tag content presented within logical row and/or column relationships is documented. 🟣
71
+
72
+ # 7.6 Lists
73
+ - The fact that lists should be tagged is documented. 🟣
74
+ - The fact that Li, Lbl and LBody should be used is documented. 🟣
75
+ - krilla always forces writing the `ListNumbering` attribute for lists. 🟢
76
+
77
+ # 7.7 Mathematical expressions
78
+ - The fact that mathematical expressions should be wrapped in `Formula` is documented. 🟣
79
+ - The fact that mathematical expressions should have an alternate text is checked. 🟢
80
+
81
+ # 7.8 Page headers and footers
82
+ - The fact that headers and footers should be tagged is documented. 🟣
83
+
84
+ # 7.9 Notes and references
85
+ - The fact that footnotes, endnotes, note labels and references should be tagged is documented. 🟣
86
+ - The fact that footnotes and endnotes should be tagged with `Note` is documented. 🟣
87
+ - krilla always generates an ID for notes. 🟢
88
+
89
+ # 7.10 Optional content
90
+ - krilla does currently not support optional content. 🔵
91
+
92
+ # 7.11 Embedded files
93
+ - krilla supports embedded files, and requires a description in this export mode. 🟢
94
+ - The fact that embedded files should be accessible in their own right is documented. 🟣
95
+
96
+ # 7.12 Article threads
97
+ - The fact that the logical reading order should be preserved is documented. 🟣
98
+
99
+ # 7.13 Digital signatures
100
+ - krilla does not support digital signatures. 🔵
101
+
102
+ # 7.14 Non-interactive forms
103
+ - krilla does not support forms. 🔵
104
+
105
+ # 7.15 XFA
106
+ - krilla does not support forms. 🔵
107
+
108
+ # 7.16 Security
109
+ - krilla does not support encryption. 🔵
110
+
111
+ # 7.17 Navigation
112
+ - krilla enforces setting a document outline. 🟢
113
+ - The fact that the outline should reflect the reading order is
114
+ documented. 🟣
115
+ - The fact that page labels should be semantically appropriate is documented. 🟣
116
+
117
+ # 7.18 Annotations
118
+ 7.18.1:
119
+ - The fact that annotations should reflect the reading order is documented. 🟣
120
+ - The fact that for visual formatting, annotations should
121
+ be tagged according to their semantic function is not documented. 🟠
122
+ - krilla ensures that annotations have an alternate text. 🟢
123
+
124
+ 7.18.2:
125
+ - krilla only supports the default annotation types. 🟢
126
+ - krilla does not use the `TrapNet` annotation. 🔵
127
+
128
+ 7.18.3
129
+ - krilla always writes the `TabOrder` property for pages that have a struct parent. 🟢
130
+
131
+ 7.18.4
132
+ - krilla does not support widget annotations. 🔵
133
+
134
+ 7.18.5
135
+ - The best practices for link tagging are documented. 🟣
136
+ - krilla enforces an alt text for all annotations. 🟢
137
+ - krilla never writes the `IMap` key for URIs. 🔵
138
+
139
+ 7.18.6
140
+ - krilla does not support media annotations. 🔵
141
+
142
+ 7.18.7
143
+ - krilla does not support file attachment annotations. 🔵
144
+
145
+ 7.18.8
146
+ - krilla does not support printer mark annotations. 🔵
147
+
148
+ # 7.19 Actions
149
+ - krilla does not support adding (JavaScript) scripts. 🔵
150
+
151
+ # 7.20 XObjects
152
+ - krilla never creates reference XObjects. 🔵
153
+ - krilla doesn't allow references to XObjects for tagging. 🔵
154
+
155
+ # 7.21 Fonts
156
+
157
+ 7.21.1: -
158
+
159
+ 7.21.2:
160
+ - krilla ensures to always conform to the PDF specification. 🟢
161
+
162
+ 7.21.3.1:
163
+ - krilla always uses Identity-H for encoding. 🟢
164
+
165
+ 7.21.3.2:
166
+ - krilla always includes a `CIDToGIDMap`. 🟢
167
+
168
+ 7.21.3.3
169
+ - krilla always includes a cmap. 🟢
170
+ - krilla always writes the `WMode` entry in cmaps. 🟢
171
+ - krilla never references other cmaps in a cmap. 🟢
172
+
173
+ 7.21.4.1
174
+ - krilla always embeds a cmap for all used fonts. 🟢
175
+ - The fact that only legally embeddable fonts should be used is
176
+ documented. 🟣
177
+ - krilla export only succeeds if all glyphs are available in the font (otherwise subsetting fails). 🟢
178
+
179
+ 7.21.4.2
180
+ - krilla doesn't include a CharSet in font descriptors. 🟢
181
+ - krilla always includes all CIDs in `CIDSet`. 🟢
182
+
183
+ 7.21.5
184
+ - Font metrics should (hopefully) be as consistent as possible. 🟢
185
+
186
+ 7.21.6
187
+ - krilla only uses CID fonts and not (PDF) TrueType fonts. 🟢
188
+
189
+ 7.21.7
190
+ - krilla always includes the `ToUnicode` entry with corresponding mappings. 🟢
191
+ - krilla will fail export if 0, U+FEFF or U+FFFE is included. 🟢
192
+
193
+ 7.21.8
194
+ - krilla will fail export if the .notdef glyph is included. 🟢
195
+
196
+ # 8 Reader Requirements
197
+
198
+ - Not applicable to krilla as a writer. -
199
+
200
+ # 9 Assistive Technology Requirements
201
+
202
+ - Not applicable to krilla as a writer. -
@@ -0,0 +1,23 @@
1
+ # Introduction
2
+
3
+ The files in this folder track the properties that are required to achieve
4
+ different compliance level, as well as a description of how/why krilla achieves those.
5
+ As krilla evolves and new features are added, these documents
6
+ might have to be updated, and we always need to ensure that all invariants are still enforced,
7
+ when adding new features.
8
+
9
+ # Legend
10
+ 🟢: This means that krilla actively checks that this property is enforced, either by an
11
+ invariant in the code, or by returning an error to the user in case it's not fulfillable.
12
+
13
+ 🔵: This means that krilla fulfills this property because it's not supported.
14
+
15
+ 🟣: This means that this property cannot be enforced by krilla, and thus is only documented.
16
+ It is upon the user of the library to enforce it.
17
+
18
+ 🔴: This means that the property is currently not enforced by krilla.
19
+
20
+ 🟠: This means that the property should perhaps be documented/checked, but is
21
+ currently not because it seems unnecessary or hard to implement.
22
+
23
+ -: This means that the clause is not applicable to krilla (for example because it's not a reader application)
@@ -0,0 +1,197 @@
1
+ //! Configuring PDF version and export mode.
2
+
3
+ pub mod validate;
4
+ mod version;
5
+
6
+ pub use validate::{Accessibility, Archival, ValidationError, Validator, Validators};
7
+ pub use version::PdfVersion;
8
+
9
+ use crate::configure::validate::ValidatorsBuilder;
10
+
11
+ /// A configuration of validator and PDF version.
12
+ #[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
13
+ pub struct Configuration {
14
+ validators: Validators,
15
+ version: PdfVersion,
16
+ }
17
+
18
+ impl Configuration {
19
+ /// Return the validators of the configuration.
20
+ pub fn validators(self) -> Validators {
21
+ self.validators
22
+ }
23
+
24
+ /// Return the PDF version of the configuration.
25
+ pub fn version(self) -> PdfVersion {
26
+ self.version
27
+ }
28
+ }
29
+
30
+ /// A configuration of validator and PDF version.
31
+ #[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
32
+ pub struct ConfigurationBuilder {
33
+ validators: ValidatorsBuilder,
34
+ version: Option<PdfVersion>,
35
+ }
36
+
37
+ impl ConfigurationBuilder {
38
+ /// Create a new `ConfigurationBuilder` with default settings.
39
+ pub fn new() -> Self {
40
+ Self::default()
41
+ }
42
+
43
+ /// Set the PDF version, overwriting the current one if already set.
44
+ pub fn with_version(mut self, version: PdfVersion) -> Self {
45
+ self.version = Some(version);
46
+ self
47
+ }
48
+
49
+ /// Set a validator, overwriting the current one if the same standard family is already set.
50
+ pub fn set_validator(mut self, validator: Validator) -> Self {
51
+ self.validators = self.validators.set_validator(validator);
52
+ self
53
+ }
54
+
55
+ /// Set the PDF/A validator, overwriting the current one if already set.
56
+ pub fn with_archival_validator(mut self, archival: Archival) -> Self {
57
+ self.validators = self.validators.with_archival_validator(archival);
58
+ self
59
+ }
60
+
61
+ /// Set the PDF/UA accessibility validator, overwriting the current one if already set.
62
+ pub fn with_accessibility_validator(mut self, ua: Accessibility) -> Self {
63
+ self.validators = self.validators.with_accessibility_validator(ua);
64
+ self
65
+ }
66
+
67
+ /// Build the [`Configuration`], returning an error if the validators and version are incompatible.
68
+ pub fn finish(self) -> Result<Configuration, ConfigurationError> {
69
+ let validators = self
70
+ .validators
71
+ .finish()
72
+ .map_err(ConfigurationError::NoOverlappingValidatorsRange)?;
73
+
74
+ let validator_range = validators.min().unwrap_or(PdfVersion::MIN)..=validators.max();
75
+ match self.version {
76
+ Some(version) if validator_range.contains(&version) => Ok(Configuration {
77
+ validators,
78
+ version,
79
+ }),
80
+ Some(version) => Err(ConfigurationError::VersionDoesNotMatchValidatorsRange(
81
+ version, validators,
82
+ )),
83
+ None if !validators.is_empty() => Ok(Configuration {
84
+ validators,
85
+ version: *validator_range.end(),
86
+ }),
87
+ None => {
88
+ let version = PdfVersion::default();
89
+ debug_assert!(validator_range.contains(&version));
90
+ Ok(Configuration {
91
+ validators,
92
+ version,
93
+ })
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ /// An error that occurred while building a [`Configuration`].
100
+ #[derive(Clone, Debug, PartialEq, Eq)]
101
+ pub enum ConfigurationError {
102
+ /// The selected validators have no overlapping valid PDF version range.
103
+ NoOverlappingValidatorsRange(Validators),
104
+ /// The explicitly set PDF version falls outside the range allowed by the validators.
105
+ VersionDoesNotMatchValidatorsRange(PdfVersion, Validators),
106
+ }
107
+
108
+ #[cfg(test)]
109
+ mod tests {
110
+ use crate::configure::{
111
+ Accessibility, Archival, Configuration, ConfigurationBuilder, ConfigurationError,
112
+ PdfVersion,
113
+ };
114
+
115
+ #[test]
116
+ fn invalid_combination_1() {
117
+ // A1_B max is PDF 1.4; explicit PDF 1.7 is out of range.
118
+ assert!(matches!(
119
+ ConfigurationBuilder::new()
120
+ .with_version(PdfVersion::Pdf17)
121
+ .with_archival_validator(Archival::A1_B)
122
+ .finish(),
123
+ Err(ConfigurationError::VersionDoesNotMatchValidatorsRange(
124
+ PdfVersion::Pdf17,
125
+ _
126
+ ))
127
+ ));
128
+ }
129
+
130
+ #[test]
131
+ fn invalid_combination_2() {
132
+ // A4 requires PDF 2.0; UA1 max is PDF 1.7 → no overlapping range.
133
+ assert!(matches!(
134
+ ConfigurationBuilder::new()
135
+ .with_archival_validator(Archival::A4)
136
+ .with_accessibility_validator(Accessibility::UA1)
137
+ .finish(),
138
+ Err(ConfigurationError::NoOverlappingValidatorsRange(_))
139
+ ));
140
+ }
141
+
142
+ #[test]
143
+ fn invalid_combination_3() {
144
+ // A1_B max is PDF 1.4; UA1 max is PDF 1.7 → intersection is PDF14..=PDF14.
145
+ // Explicitly setting PDF 1.7 is out of range.
146
+ assert!(matches!(
147
+ ConfigurationBuilder::new()
148
+ .with_archival_validator(Archival::A1_B)
149
+ .with_accessibility_validator(Accessibility::UA1)
150
+ .with_version(PdfVersion::Pdf17)
151
+ .finish(),
152
+ Err(ConfigurationError::VersionDoesNotMatchValidatorsRange(
153
+ PdfVersion::Pdf17,
154
+ _
155
+ ))
156
+ ));
157
+ }
158
+
159
+ #[test]
160
+ fn multi_validator_pdf_a3b_pdf_ua1() {
161
+ let config = ConfigurationBuilder::new()
162
+ .with_archival_validator(Archival::A3_B)
163
+ .with_accessibility_validator(Accessibility::UA1)
164
+ .finish()
165
+ .unwrap();
166
+ assert_eq!(config.validators().archival(), Some(Archival::A3_B));
167
+ assert_eq!(
168
+ config.validators().accessibility(),
169
+ Some(Accessibility::UA1)
170
+ );
171
+ assert_eq!(config.version(), PdfVersion::Pdf17);
172
+ }
173
+
174
+ #[test]
175
+ fn multi_validator_pdfa2a_pdfua1() {
176
+ assert!(ConfigurationBuilder::new()
177
+ .with_archival_validator(Archival::A2_A)
178
+ .with_accessibility_validator(Accessibility::UA1)
179
+ .finish()
180
+ .is_ok());
181
+ }
182
+
183
+ #[test]
184
+ fn empty_validators() {
185
+ let config = ConfigurationBuilder::new().finish().unwrap();
186
+ assert!(config.validators().is_empty());
187
+ assert_eq!(config.version(), PdfVersion::Pdf17);
188
+ }
189
+
190
+ #[test]
191
+ fn default_config() {
192
+ assert_eq!(
193
+ ConfigurationBuilder::new().finish().unwrap(),
194
+ Configuration::default()
195
+ );
196
+ }
197
+ }