pulpweaver4 0.0.0-stage → 0.0.88
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/dist/ast/djot.d.ts +123 -0
- package/dist/ast/djot.js +458 -0
- package/dist/ast/djot.js.map +1 -0
- package/dist/ast/index.d.ts +10 -0
- package/dist/ast/index.js +11 -0
- package/dist/ast/index.js.map +1 -0
- package/dist/ast/locator.d.ts +27 -0
- package/dist/ast/locator.js +77 -0
- package/dist/ast/locator.js.map +1 -0
- package/dist/ast/nodes.d.ts +534 -0
- package/dist/ast/nodes.js +48 -0
- package/dist/ast/nodes.js.map +1 -0
- package/dist/ast/position.d.ts +88 -0
- package/dist/ast/position.js +98 -0
- package/dist/ast/position.js.map +1 -0
- package/dist/ast/traverse.d.ts +12 -0
- package/dist/ast/traverse.js +37 -0
- package/dist/ast/traverse.js.map +1 -0
- package/dist/bibliography/biblatex.d.ts +13 -0
- package/dist/bibliography/biblatex.js +849 -0
- package/dist/bibliography/biblatex.js.map +1 -0
- package/dist/bibliography/bibtex.d.ts +39 -0
- package/dist/bibliography/bibtex.js +259 -0
- package/dist/bibliography/bibtex.js.map +1 -0
- package/dist/bibliography/csl.d.ts +9 -0
- package/dist/bibliography/csl.js +241 -0
- package/dist/bibliography/csl.js.map +1 -0
- package/dist/bibliography/dates.d.ts +33 -0
- package/dist/bibliography/dates.js +223 -0
- package/dist/bibliography/dates.js.map +1 -0
- package/dist/bibliography/index.d.ts +8 -0
- package/dist/bibliography/index.js +9 -0
- package/dist/bibliography/index.js.map +1 -0
- package/dist/bibliography/item.d.ts +142 -0
- package/dist/bibliography/item.js +181 -0
- package/dist/bibliography/item.js.map +1 -0
- package/dist/bibliography/latex.d.ts +21 -0
- package/dist/bibliography/latex.js +586 -0
- package/dist/bibliography/latex.js.map +1 -0
- package/dist/bibliography/names.d.ts +23 -0
- package/dist/bibliography/names.js +244 -0
- package/dist/bibliography/names.js.map +1 -0
- package/dist/bibliography/read.d.ts +24 -0
- package/dist/bibliography/read.js +50 -0
- package/dist/bibliography/read.js.map +1 -0
- package/dist/citations/book.d.ts +91 -0
- package/dist/citations/book.js +206 -0
- package/dist/citations/book.js.map +1 -0
- package/dist/citations/collect.d.ts +52 -0
- package/dist/citations/collect.js +125 -0
- package/dist/citations/collect.js.map +1 -0
- package/dist/citations/hast.d.ts +12 -0
- package/dist/citations/hast.js +49 -0
- package/dist/citations/hast.js.map +1 -0
- package/dist/citations/index.d.ts +14 -0
- package/dist/citations/index.js +15 -0
- package/dist/citations/index.js.map +1 -0
- package/dist/citations/lint.d.ts +70 -0
- package/dist/citations/lint.js +92 -0
- package/dist/citations/lint.js.map +1 -0
- package/dist/citations/notes.d.ts +11 -0
- package/dist/citations/notes.js +120 -0
- package/dist/citations/notes.js.map +1 -0
- package/dist/citations/positions.d.ts +34 -0
- package/dist/citations/positions.js +90 -0
- package/dist/citations/positions.js.map +1 -0
- package/dist/citations/project.d.ts +7 -0
- package/dist/citations/project.js +24 -0
- package/dist/citations/project.js.map +1 -0
- package/dist/colour/cmyk.d.ts +71 -0
- package/dist/colour/cmyk.js +210 -0
- package/dist/colour/cmyk.js.map +1 -0
- package/dist/colour/images.d.ts +36 -0
- package/dist/colour/images.js +106 -0
- package/dist/colour/images.js.map +1 -0
- package/dist/colour/index.d.ts +7 -0
- package/dist/colour/index.js +8 -0
- package/dist/colour/index.js.map +1 -0
- package/dist/colour/ink-limit.d.ts +68 -0
- package/dist/colour/ink-limit.js +109 -0
- package/dist/colour/ink-limit.js.map +1 -0
- package/dist/colour/intents.d.ts +135 -0
- package/dist/colour/intents.js +183 -0
- package/dist/colour/intents.js.map +1 -0
- package/dist/colour/lcms.d.ts +79 -0
- package/dist/colour/lcms.js +229 -0
- package/dist/colour/lcms.js.map +1 -0
- package/dist/colour/previews.d.ts +49 -0
- package/dist/colour/previews.js +116 -0
- package/dist/colour/previews.js.map +1 -0
- package/dist/colour/wasm/LICENSE-lcms2 +22 -0
- package/dist/colour/wasm/lcms2.wasm +0 -0
- package/dist/config/config.d.ts +109 -0
- package/dist/config/config.js +295 -0
- package/dist/config/config.js.map +1 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.js +7 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/page.d.ts +42 -0
- package/dist/config/page.js +95 -0
- package/dist/config/page.js.map +1 -0
- package/dist/config/project-schema.d.ts +23 -0
- package/dist/config/project-schema.js +209 -0
- package/dist/config/project-schema.js.map +1 -0
- package/dist/config/schema.d.ts +68 -0
- package/dist/config/schema.js +333 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/toml.d.ts +54 -0
- package/dist/config/toml.js +238 -0
- package/dist/config/toml.js.map +1 -0
- package/dist/contents/index.d.ts +8 -0
- package/dist/contents/index.js +9 -0
- package/dist/contents/index.js.map +1 -0
- package/dist/contents/transform.d.ts +64 -0
- package/dist/contents/transform.js +149 -0
- package/dist/contents/transform.js.map +1 -0
- package/dist/csl/affix.d.ts +16 -0
- package/dist/csl/affix.js +74 -0
- package/dist/csl/affix.js.map +1 -0
- package/dist/csl/data/chicago-author-date.d.ts +2 -0
- package/dist/csl/data/chicago-author-date.js +3 -0
- package/dist/csl/data/chicago-author-date.js.map +1 -0
- package/dist/csl/data/chicago-notes-bibliography.d.ts +2 -0
- package/dist/csl/data/chicago-notes-bibliography.js +3 -0
- package/dist/csl/data/chicago-notes-bibliography.js.map +1 -0
- package/dist/csl/data/locales-en-GB.d.ts +2 -0
- package/dist/csl/data/locales-en-GB.js +3 -0
- package/dist/csl/data/locales-en-GB.js.map +1 -0
- package/dist/csl/data/locales-en-US.d.ts +2 -0
- package/dist/csl/data/locales-en-US.js +3 -0
- package/dist/csl/data/locales-en-US.js.map +1 -0
- package/dist/csl/dates.d.ts +30 -0
- package/dist/csl/dates.js +223 -0
- package/dist/csl/dates.js.map +1 -0
- package/dist/csl/format.d.ts +29 -0
- package/dist/csl/format.js +157 -0
- package/dist/csl/format.js.map +1 -0
- package/dist/csl/index.d.ts +26 -0
- package/dist/csl/index.js +16 -0
- package/dist/csl/index.js.map +1 -0
- package/dist/csl/ir.d.ts +103 -0
- package/dist/csl/ir.js +549 -0
- package/dist/csl/ir.js.map +1 -0
- package/dist/csl/load.d.ts +98 -0
- package/dist/csl/load.js +163 -0
- package/dist/csl/load.js.map +1 -0
- package/dist/csl/locale.d.ts +90 -0
- package/dist/csl/locale.js +251 -0
- package/dist/csl/locale.js.map +1 -0
- package/dist/csl/names.d.ts +41 -0
- package/dist/csl/names.js +203 -0
- package/dist/csl/names.js.map +1 -0
- package/dist/csl/numbers.d.ts +48 -0
- package/dist/csl/numbers.js +170 -0
- package/dist/csl/numbers.js.map +1 -0
- package/dist/csl/processor.d.ts +177 -0
- package/dist/csl/processor.js +759 -0
- package/dist/csl/processor.js.map +1 -0
- package/dist/csl/project.d.ts +21 -0
- package/dist/csl/project.js +78 -0
- package/dist/csl/project.js.map +1 -0
- package/dist/csl/render.d.ts +130 -0
- package/dist/csl/render.js +748 -0
- package/dist/csl/render.js.map +1 -0
- package/dist/csl/style.d.ts +168 -0
- package/dist/csl/style.js +262 -0
- package/dist/csl/style.js.map +1 -0
- package/dist/csl/xml.d.ts +28 -0
- package/dist/csl/xml.js +162 -0
- package/dist/csl/xml.js.map +1 -0
- package/dist/djot/djot.js/LICENSE +20 -0
- package/dist/djot/djot.js/src/ast.d.ts +324 -0
- package/dist/djot/djot.js/src/ast.js +61 -0
- package/dist/djot/djot.js/src/ast.js.map +1 -0
- package/dist/djot/djot.js/src/attributes.d.ts +31 -0
- package/dist/djot/djot.js/src/attributes.js +300 -0
- package/dist/djot/djot.js/src/attributes.js.map +1 -0
- package/dist/djot/djot.js/src/block.d.ts +87 -0
- package/dist/djot/djot.js/src/block.js +1201 -0
- package/dist/djot/djot.js/src/block.js.map +1 -0
- package/dist/djot/djot.js/src/djot-renderer.d.ts +8 -0
- package/dist/djot/djot.js/src/djot-renderer.js +755 -0
- package/dist/djot/djot.js/src/djot-renderer.js.map +1 -0
- package/dist/djot/djot.js/src/event.d.ts +6 -0
- package/dist/djot/djot.js/src/event.js +2 -0
- package/dist/djot/djot.js/src/event.js.map +1 -0
- package/dist/djot/djot.js/src/filter.d.ts +13 -0
- package/dist/djot/djot.js/src/filter.js +159 -0
- package/dist/djot/djot.js/src/filter.js.map +1 -0
- package/dist/djot/djot.js/src/find.d.ts +7 -0
- package/dist/djot/djot.js/src/find.js +33 -0
- package/dist/djot/djot.js/src/find.js.map +1 -0
- package/dist/djot/djot.js/src/html.d.ts +40 -0
- package/dist/djot/djot.js/src/html.js +656 -0
- package/dist/djot/djot.js/src/html.js.map +1 -0
- package/dist/djot/djot.js/src/index.d.ts +9 -0
- package/dist/djot/djot.js/src/index.js +9 -0
- package/dist/djot/djot.js/src/index.js.map +1 -0
- package/dist/djot/djot.js/src/inline.d.ts +62 -0
- package/dist/djot/djot.js/src/inline.js +1019 -0
- package/dist/djot/djot.js/src/inline.js.map +1 -0
- package/dist/djot/djot.js/src/options.d.ts +13 -0
- package/dist/djot/djot.js/src/options.js +27 -0
- package/dist/djot/djot.js/src/options.js.map +1 -0
- package/dist/djot/djot.js/src/pandoc.d.ts +20 -0
- package/dist/djot/djot.js/src/pandoc.js +1040 -0
- package/dist/djot/djot.js/src/pandoc.js.map +1 -0
- package/dist/djot/djot.js/src/parse.d.ts +19 -0
- package/dist/djot/djot.js/src/parse.js +1436 -0
- package/dist/djot/djot.js/src/parse.js.map +1 -0
- package/dist/djot/djot.js/src/version.d.ts +1 -0
- package/dist/djot/djot.js/src/version.js +2 -0
- package/dist/djot/djot.js/src/version.js.map +1 -0
- package/dist/djot/index.d.ts +5 -0
- package/dist/djot/index.js +6 -0
- package/dist/djot/index.js.map +1 -0
- package/dist/djot/read.d.ts +57 -0
- package/dist/djot/read.js +146 -0
- package/dist/djot/read.js.map +1 -0
- package/dist/fonts/css.d.ts +82 -0
- package/dist/fonts/css.js +329 -0
- package/dist/fonts/css.js.map +1 -0
- package/dist/fonts/faces.d.ts +101 -0
- package/dist/fonts/faces.js +226 -0
- package/dist/fonts/faces.js.map +1 -0
- package/dist/fonts/index.d.ts +12 -0
- package/dist/fonts/index.js +13 -0
- package/dist/fonts/index.js.map +1 -0
- package/dist/fonts/lint.d.ts +58 -0
- package/dist/fonts/lint.js +209 -0
- package/dist/fonts/lint.js.map +1 -0
- package/dist/fonts/match.d.ts +36 -0
- package/dist/fonts/match.js +104 -0
- package/dist/fonts/match.js.map +1 -0
- package/dist/fonts/names.d.ts +9 -0
- package/dist/fonts/names.js +50 -0
- package/dist/fonts/names.js.map +1 -0
- package/dist/fonts/subset.d.ts +72 -0
- package/dist/fonts/subset.js +169 -0
- package/dist/fonts/subset.js.map +1 -0
- package/dist/fonts/walk.d.ts +33 -0
- package/dist/fonts/walk.js +120 -0
- package/dist/fonts/walk.js.map +1 -0
- package/dist/fonts/wasm/LICENSE-harfbuzzjs +19 -0
- package/dist/fonts/wasm/harfbuzz-subset.wasm +0 -0
- package/dist/html/check.d.ts +62 -0
- package/dist/html/check.js +186 -0
- package/dist/html/check.js.map +1 -0
- package/dist/html/counters.d.ts +32 -0
- package/dist/html/counters.js +72 -0
- package/dist/html/counters.js.map +1 -0
- package/dist/html/css.d.ts +33 -0
- package/dist/html/css.js +72 -0
- package/dist/html/css.js.map +1 -0
- package/dist/html/dom.d.ts +28 -0
- package/dist/html/dom.js +162 -0
- package/dist/html/dom.js.map +1 -0
- package/dist/html/editions.d.ts +26 -0
- package/dist/html/editions.js +57 -0
- package/dist/html/editions.js.map +1 -0
- package/dist/html/images.d.ts +13 -0
- package/dist/html/images.js +62 -0
- package/dist/html/images.js.map +1 -0
- package/dist/html/index.d.ts +14 -0
- package/dist/html/index.js +15 -0
- package/dist/html/index.js.map +1 -0
- package/dist/html/registry.d.ts +120 -0
- package/dist/html/registry.js +48 -0
- package/dist/html/registry.js.map +1 -0
- package/dist/html/render.d.ts +99 -0
- package/dist/html/render.js +687 -0
- package/dist/html/render.js.map +1 -0
- package/dist/hyphenation/NOTICE +429 -0
- package/dist/hyphenation/exceptions.d.ts +60 -0
- package/dist/hyphenation/exceptions.js +79 -0
- package/dist/hyphenation/exceptions.js.map +1 -0
- package/dist/hyphenation/hyphenator.d.ts +66 -0
- package/dist/hyphenation/hyphenator.js +245 -0
- package/dist/hyphenation/hyphenator.js.map +1 -0
- package/dist/hyphenation/index.d.ts +4 -0
- package/dist/hyphenation/index.js +5 -0
- package/dist/hyphenation/index.js.map +1 -0
- package/dist/hyphenation/languages.d.ts +20 -0
- package/dist/hyphenation/languages.js +75 -0
- package/dist/hyphenation/languages.js.map +1 -0
- package/dist/hyphenation/patterns/af.wasm +0 -0
- package/dist/hyphenation/patterns/as.wasm +0 -0
- package/dist/hyphenation/patterns/be.wasm +0 -0
- package/dist/hyphenation/patterns/bg.wasm +0 -0
- package/dist/hyphenation/patterns/bn.wasm +0 -0
- package/dist/hyphenation/patterns/ca.wasm +0 -0
- package/dist/hyphenation/patterns/cy.wasm +0 -0
- package/dist/hyphenation/patterns/da.wasm +0 -0
- package/dist/hyphenation/patterns/de.wasm +0 -0
- package/dist/hyphenation/patterns/el-monoton.wasm +0 -0
- package/dist/hyphenation/patterns/el-polyton.wasm +0 -0
- package/dist/hyphenation/patterns/en-gb.wasm +0 -0
- package/dist/hyphenation/patterns/en-us.wasm +0 -0
- package/dist/hyphenation/patterns/eo.wasm +0 -0
- package/dist/hyphenation/patterns/es.wasm +0 -0
- package/dist/hyphenation/patterns/et.wasm +0 -0
- package/dist/hyphenation/patterns/eu.wasm +0 -0
- package/dist/hyphenation/patterns/fi-x-school.wasm +0 -0
- package/dist/hyphenation/patterns/fr.wasm +0 -0
- package/dist/hyphenation/patterns/fur.wasm +0 -0
- package/dist/hyphenation/patterns/ga.wasm +0 -0
- package/dist/hyphenation/patterns/gl.wasm +0 -0
- package/dist/hyphenation/patterns/gu.wasm +0 -0
- package/dist/hyphenation/patterns/hi.wasm +0 -0
- package/dist/hyphenation/patterns/hr.wasm +0 -0
- package/dist/hyphenation/patterns/hsb.wasm +0 -0
- package/dist/hyphenation/patterns/ia.wasm +0 -0
- package/dist/hyphenation/patterns/is.wasm +0 -0
- package/dist/hyphenation/patterns/it.wasm +0 -0
- package/dist/hyphenation/patterns/ka.wasm +0 -0
- package/dist/hyphenation/patterns/kmr.wasm +0 -0
- package/dist/hyphenation/patterns/kn.wasm +0 -0
- package/dist/hyphenation/patterns/la.wasm +0 -0
- package/dist/hyphenation/patterns/lt.wasm +0 -0
- package/dist/hyphenation/patterns/ml.wasm +0 -0
- package/dist/hyphenation/patterns/mn-cyrl.wasm +0 -0
- package/dist/hyphenation/patterns/mr.wasm +0 -0
- package/dist/hyphenation/patterns/nb.wasm +0 -0
- package/dist/hyphenation/patterns/nl.wasm +0 -0
- package/dist/hyphenation/patterns/nn.wasm +0 -0
- package/dist/hyphenation/patterns/no.wasm +0 -0
- package/dist/hyphenation/patterns/oc.wasm +0 -0
- package/dist/hyphenation/patterns/or.wasm +0 -0
- package/dist/hyphenation/patterns/pa.wasm +0 -0
- package/dist/hyphenation/patterns/pi.wasm +0 -0
- package/dist/hyphenation/patterns/pl.wasm +0 -0
- package/dist/hyphenation/patterns/pms.wasm +0 -0
- package/dist/hyphenation/patterns/pt.wasm +0 -0
- package/dist/hyphenation/patterns/rm.wasm +0 -0
- package/dist/hyphenation/patterns/ru.wasm +0 -0
- package/dist/hyphenation/patterns/sh-cyrl.wasm +0 -0
- package/dist/hyphenation/patterns/sh-latn.wasm +0 -0
- package/dist/hyphenation/patterns/sk.wasm +0 -0
- package/dist/hyphenation/patterns/sl.wasm +0 -0
- package/dist/hyphenation/patterns/sq.wasm +0 -0
- package/dist/hyphenation/patterns/sv.wasm +0 -0
- package/dist/hyphenation/patterns/ta.wasm +0 -0
- package/dist/hyphenation/patterns/te.wasm +0 -0
- package/dist/hyphenation/patterns/th.wasm +0 -0
- package/dist/hyphenation/patterns/tk.wasm +0 -0
- package/dist/hyphenation/patterns/tr.wasm +0 -0
- package/dist/hyphenation/patterns/uk.wasm +0 -0
- package/dist/hyphenation/patterns/zh-latn-pinyin.wasm +0 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/indexes/index.d.ts +10 -0
- package/dist/indexes/index.js +11 -0
- package/dist/indexes/index.js.map +1 -0
- package/dist/indexes/layout.d.ts +30 -0
- package/dist/indexes/layout.js +83 -0
- package/dist/indexes/layout.js.map +1 -0
- package/dist/indexes/locators.d.ts +33 -0
- package/dist/indexes/locators.js +51 -0
- package/dist/indexes/locators.js.map +1 -0
- package/dist/indexes/terms.d.ts +97 -0
- package/dist/indexes/terms.js +211 -0
- package/dist/indexes/terms.js.map +1 -0
- package/dist/indexes/transform.d.ts +90 -0
- package/dist/indexes/transform.js +154 -0
- package/dist/indexes/transform.js.map +1 -0
- package/dist/layout/calibrate.d.ts +12 -0
- package/dist/layout/calibrate.js +50 -0
- package/dist/layout/calibrate.js.map +1 -0
- package/dist/layout/converge.d.ts +31 -0
- package/dist/layout/converge.js +84 -0
- package/dist/layout/converge.js.map +1 -0
- package/dist/layout/counters.d.ts +16 -0
- package/dist/layout/counters.js +62 -0
- package/dist/layout/counters.js.map +1 -0
- package/dist/layout/first-letter.d.ts +34 -0
- package/dist/layout/first-letter.js +183 -0
- package/dist/layout/first-letter.js.map +1 -0
- package/dist/layout/fonts.d.ts +67 -0
- package/dist/layout/fonts.js +110 -0
- package/dist/layout/fonts.js.map +1 -0
- package/dist/layout/generated.d.ts +9 -0
- package/dist/layout/generated.js +83 -0
- package/dist/layout/generated.js.map +1 -0
- package/dist/layout/glue.d.ts +18 -0
- package/dist/layout/glue.js +48 -0
- package/dist/layout/glue.js.map +1 -0
- package/dist/layout/index.d.ts +17 -0
- package/dist/layout/index.js +18 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/lists.d.ts +91 -0
- package/dist/layout/lists.js +1068 -0
- package/dist/layout/lists.js.map +1 -0
- package/dist/layout/margin-boxes.d.ts +114 -0
- package/dist/layout/margin-boxes.js +429 -0
- package/dist/layout/margin-boxes.js.map +1 -0
- package/dist/layout/minipage.d.ts +85 -0
- package/dist/layout/minipage.js +83 -0
- package/dist/layout/minipage.js.map +1 -0
- package/dist/layout/page-box.d.ts +32 -0
- package/dist/layout/page-box.js +110 -0
- package/dist/layout/page-box.js.map +1 -0
- package/dist/layout/page-rules.d.ts +47 -0
- package/dist/layout/page-rules.js +202 -0
- package/dist/layout/page-rules.js.map +1 -0
- package/dist/layout/page.d.ts +51 -0
- package/dist/layout/page.js +133 -0
- package/dist/layout/page.js.map +1 -0
- package/dist/layout/pagebuilder.d.ts +243 -0
- package/dist/layout/pagebuilder.js +591 -0
- package/dist/layout/pagebuilder.js.map +1 -0
- package/dist/layout/pages.d.ts +71 -0
- package/dist/layout/pages.js +741 -0
- package/dist/layout/pages.js.map +1 -0
- package/dist/layout/paragraph.d.ts +194 -0
- package/dist/layout/paragraph.js +1148 -0
- package/dist/layout/paragraph.js.map +1 -0
- package/dist/layout/pre.d.ts +8 -0
- package/dist/layout/pre.js +151 -0
- package/dist/layout/pre.js.map +1 -0
- package/dist/layout/region.d.ts +66 -0
- package/dist/layout/region.js +200 -0
- package/dist/layout/region.js.map +1 -0
- package/dist/layout/vlist.d.ts +218 -0
- package/dist/layout/vlist.js +72 -0
- package/dist/layout/vlist.js.map +1 -0
- package/dist/linebreak/items.d.ts +69 -0
- package/dist/linebreak/items.js +44 -0
- package/dist/linebreak/items.js.map +1 -0
- package/dist/linebreak/knuth-plass.d.ts +149 -0
- package/dist/linebreak/knuth-plass.js +461 -0
- package/dist/linebreak/knuth-plass.js.map +1 -0
- package/dist/lint/config.d.ts +48 -0
- package/dist/lint/config.js +185 -0
- package/dist/lint/config.js.map +1 -0
- package/dist/lint/context.d.ts +64 -0
- package/dist/lint/context.js +37 -0
- package/dist/lint/context.js.map +1 -0
- package/dist/lint/fix.d.ts +40 -0
- package/dist/lint/fix.js +86 -0
- package/dist/lint/fix.js.map +1 -0
- package/dist/lint/index.d.ts +14 -0
- package/dist/lint/index.js +15 -0
- package/dist/lint/index.js.map +1 -0
- package/dist/lint/linter.d.ts +59 -0
- package/dist/lint/linter.js +239 -0
- package/dist/lint/linter.js.map +1 -0
- package/dist/lint/presets.d.ts +20 -0
- package/dist/lint/presets.js +65 -0
- package/dist/lint/presets.js.map +1 -0
- package/dist/lint/project.d.ts +31 -0
- package/dist/lint/project.js +100 -0
- package/dist/lint/project.js.map +1 -0
- package/dist/lint/rules/html.d.ts +30 -0
- package/dist/lint/rules/html.js +163 -0
- package/dist/lint/rules/html.js.map +1 -0
- package/dist/lint/rules/layout.d.ts +42 -0
- package/dist/lint/rules/layout.js +428 -0
- package/dist/lint/rules/layout.js.map +1 -0
- package/dist/lint/rules/source.d.ts +65 -0
- package/dist/lint/rules/source.js +334 -0
- package/dist/lint/rules/source.js.map +1 -0
- package/dist/lint/testing.d.ts +7 -0
- package/dist/lint/testing.js +77 -0
- package/dist/lint/testing.js.map +1 -0
- package/dist/math/hast.d.ts +46 -0
- package/dist/math/hast.js +297 -0
- package/dist/math/hast.js.map +1 -0
- package/dist/math/index.d.ts +9 -0
- package/dist/math/index.js +10 -0
- package/dist/math/index.js.map +1 -0
- package/dist/math/mathjax/LICENSE-mathjax +202 -0
- package/dist/math/mathjax/LICENSE-speech-rule-engine +177 -0
- package/dist/math/mathjax/sre/af.json +146 -0
- package/dist/math/mathjax/sre/base.json +140 -0
- package/dist/math/mathjax/sre/ca.json +140 -0
- package/dist/math/mathjax/sre/da.json +140 -0
- package/dist/math/mathjax/sre/de.json +146 -0
- package/dist/math/mathjax/sre/en.json +158 -0
- package/dist/math/mathjax/sre/es.json +140 -0
- package/dist/math/mathjax/sre/euro.json +32 -0
- package/dist/math/mathjax/sre/fr.json +146 -0
- package/dist/math/mathjax/sre/hi.json +146 -0
- package/dist/math/mathjax/sre/it.json +146 -0
- package/dist/math/mathjax/sre/ko.json +146 -0
- package/dist/math/mathjax/sre/nb.json +146 -0
- package/dist/math/mathjax/sre/nemeth.json +125 -0
- package/dist/math/mathjax/sre/nn.json +146 -0
- package/dist/math/mathjax/sre/sv.json +146 -0
- package/dist/math/mathjax/svg/PUA.json +1 -0
- package/dist/math/mathjax/svg/accents-b-i.json +1 -0
- package/dist/math/mathjax/svg/accents.json +1 -0
- package/dist/math/mathjax/svg/arabic.json +1 -0
- package/dist/math/mathjax/svg/arrows.json +1 -0
- package/dist/math/mathjax/svg/braille-d.json +1 -0
- package/dist/math/mathjax/svg/braille.json +1 -0
- package/dist/math/mathjax/svg/calligraphic.json +1 -0
- package/dist/math/mathjax/svg/cherokee.json +1 -0
- package/dist/math/mathjax/svg/cyrillic-ss.json +1 -0
- package/dist/math/mathjax/svg/cyrillic.json +1 -0
- package/dist/math/mathjax/svg/devanagari.json +1 -0
- package/dist/math/mathjax/svg/double-struck.json +1 -0
- package/dist/math/mathjax/svg/fraktur.json +1 -0
- package/dist/math/mathjax/svg/greek-ss.json +1 -0
- package/dist/math/mathjax/svg/greek.json +1 -0
- package/dist/math/mathjax/svg/hebrew.json +1 -0
- package/dist/math/mathjax/svg/latin-b.json +1 -0
- package/dist/math/mathjax/svg/latin-bi.json +1 -0
- package/dist/math/mathjax/svg/latin-i.json +1 -0
- package/dist/math/mathjax/svg/latin.json +1 -0
- package/dist/math/mathjax/svg/marrows.json +1 -0
- package/dist/math/mathjax/svg/math.json +1 -0
- package/dist/math/mathjax/svg/monospace-ex.json +1 -0
- package/dist/math/mathjax/svg/monospace-l.json +1 -0
- package/dist/math/mathjax/svg/monospace.json +1 -0
- package/dist/math/mathjax/svg/mshapes.json +1 -0
- package/dist/math/mathjax/svg/phonetics-ss.json +1 -0
- package/dist/math/mathjax/svg/phonetics.json +1 -0
- package/dist/math/mathjax/svg/sans-serif-b.json +1 -0
- package/dist/math/mathjax/svg/sans-serif-bi.json +1 -0
- package/dist/math/mathjax/svg/sans-serif-ex.json +1 -0
- package/dist/math/mathjax/svg/sans-serif-i.json +1 -0
- package/dist/math/mathjax/svg/sans-serif-r.json +1 -0
- package/dist/math/mathjax/svg/sans-serif.json +1 -0
- package/dist/math/mathjax/svg/script.json +1 -0
- package/dist/math/mathjax/svg/shapes.json +1 -0
- package/dist/math/mathjax/svg/symbols-b-i.json +1 -0
- package/dist/math/mathjax/svg/symbols.json +1 -0
- package/dist/math/mathjax/svg/variants.json +1 -0
- package/dist/math/mathjax.d.ts +67 -0
- package/dist/math/mathjax.js +162 -0
- package/dist/math/mathjax.js.map +1 -0
- package/dist/math/speech.d.ts +27 -0
- package/dist/math/speech.js +87 -0
- package/dist/math/speech.js.map +1 -0
- package/dist/math/typeset.d.ts +75 -0
- package/dist/math/typeset.js +108 -0
- package/dist/math/typeset.js.map +1 -0
- package/dist/measure/css.d.ts +44 -0
- package/dist/measure/css.js +158 -0
- package/dist/measure/css.js.map +1 -0
- package/dist/measure/index.d.ts +3 -0
- package/dist/measure/index.js +4 -0
- package/dist/measure/index.js.map +1 -0
- package/dist/measure/measurer.d.ts +159 -0
- package/dist/measure/measurer.js +300 -0
- package/dist/measure/measurer.js.map +1 -0
- package/dist/measure/model.d.ts +46 -0
- package/dist/measure/model.js +47 -0
- package/dist/measure/model.js.map +1 -0
- package/dist/output/assets.d.ts +10 -0
- package/dist/output/assets.js +65 -0
- package/dist/output/assets.js.map +1 -0
- package/dist/output/index.d.ts +4 -0
- package/dist/output/index.js +5 -0
- package/dist/output/index.js.map +1 -0
- package/dist/output/output.d.ts +103 -0
- package/dist/output/output.js +86 -0
- package/dist/output/output.js.map +1 -0
- package/dist/output/stylesheets.d.ts +45 -0
- package/dist/output/stylesheets.js +50 -0
- package/dist/output/stylesheets.js.map +1 -0
- package/dist/paint/backgrounds.d.ts +56 -0
- package/dist/paint/backgrounds.js +261 -0
- package/dist/paint/backgrounds.js.map +1 -0
- package/dist/paint/blend.d.ts +61 -0
- package/dist/paint/blend.js +157 -0
- package/dist/paint/blend.js.map +1 -0
- package/dist/paint/border-image.d.ts +13 -0
- package/dist/paint/border-image.js +149 -0
- package/dist/paint/border-image.js.map +1 -0
- package/dist/paint/borders.d.ts +47 -0
- package/dist/paint/borders.js +329 -0
- package/dist/paint/borders.js.map +1 -0
- package/dist/paint/canvas.d.ts +52 -0
- package/dist/paint/canvas.js +274 -0
- package/dist/paint/canvas.js.map +1 -0
- package/dist/paint/colours.d.ts +55 -0
- package/dist/paint/colours.js +380 -0
- package/dist/paint/colours.js.map +1 -0
- package/dist/paint/columns.d.ts +11 -0
- package/dist/paint/columns.js +42 -0
- package/dist/paint/columns.js.map +1 -0
- package/dist/paint/context.d.ts +47 -0
- package/dist/paint/context.js +2 -0
- package/dist/paint/context.js.map +1 -0
- package/dist/paint/decoration.d.ts +97 -0
- package/dist/paint/decoration.js +280 -0
- package/dist/paint/decoration.js.map +1 -0
- package/dist/paint/effects.d.ts +64 -0
- package/dist/paint/effects.js +342 -0
- package/dist/paint/effects.js.map +1 -0
- package/dist/paint/emphasis.d.ts +13 -0
- package/dist/paint/emphasis.js +95 -0
- package/dist/paint/emphasis.js.map +1 -0
- package/dist/paint/flatten.d.ts +33 -0
- package/dist/paint/flatten.js +968 -0
- package/dist/paint/flatten.js.map +1 -0
- package/dist/paint/geometry.d.ts +62 -0
- package/dist/paint/geometry.js +170 -0
- package/dist/paint/geometry.js.map +1 -0
- package/dist/paint/gradients.d.ts +31 -0
- package/dist/paint/gradients.js +394 -0
- package/dist/paint/gradients.js.map +1 -0
- package/dist/paint/images.d.ts +17 -0
- package/dist/paint/images.js +80 -0
- package/dist/paint/images.js.map +1 -0
- package/dist/paint/lint.d.ts +46 -0
- package/dist/paint/lint.js +105 -0
- package/dist/paint/lint.js.map +1 -0
- package/dist/paint/overprint.d.ts +13 -0
- package/dist/paint/overprint.js +12 -0
- package/dist/paint/overprint.js.map +1 -0
- package/dist/paint/painter.d.ts +92 -0
- package/dist/paint/painter.js +281 -0
- package/dist/paint/painter.js.map +1 -0
- package/dist/paint/path.d.ts +9 -0
- package/dist/paint/path.js +173 -0
- package/dist/paint/path.js.map +1 -0
- package/dist/paint/raster.d.ts +32 -0
- package/dist/paint/raster.js +180 -0
- package/dist/paint/raster.js.map +1 -0
- package/dist/paint/shadows.d.ts +28 -0
- package/dist/paint/shadows.js +104 -0
- package/dist/paint/shadows.js.map +1 -0
- package/dist/paint/sources.d.ts +13 -0
- package/dist/paint/sources.js +17 -0
- package/dist/paint/sources.js.map +1 -0
- package/dist/paint/stacking.d.ts +75 -0
- package/dist/paint/stacking.js +327 -0
- package/dist/paint/stacking.js.map +1 -0
- package/dist/paint/svg-lint.d.ts +57 -0
- package/dist/paint/svg-lint.js +119 -0
- package/dist/paint/svg-lint.js.map +1 -0
- package/dist/paint/svg.d.ts +95 -0
- package/dist/paint/svg.js +728 -0
- package/dist/paint/svg.js.map +1 -0
- package/dist/paint/tables.d.ts +18 -0
- package/dist/paint/tables.js +178 -0
- package/dist/paint/tables.js.map +1 -0
- package/dist/paint/text-shadow.d.ts +26 -0
- package/dist/paint/text-shadow.js +187 -0
- package/dist/paint/text-shadow.js.map +1 -0
- package/dist/paint/text.d.ts +144 -0
- package/dist/paint/text.js +713 -0
- package/dist/paint/text.js.map +1 -0
- package/dist/paint/values.d.ts +24 -0
- package/dist/paint/values.js +160 -0
- package/dist/paint/values.js.map +1 -0
- package/dist/paint/vertical.d.ts +19 -0
- package/dist/paint/vertical.js +236 -0
- package/dist/paint/vertical.js.map +1 -0
- package/dist/pdf/index.d.ts +6 -0
- package/dist/pdf/index.js +7 -0
- package/dist/pdf/index.js.map +1 -0
- package/dist/pdf/pdfx.d.ts +30 -0
- package/dist/pdf/pdfx.js +18 -0
- package/dist/pdf/pdfx.js.map +1 -0
- package/dist/pdf/structure/index.d.ts +53 -0
- package/dist/pdf/structure/index.js +52 -0
- package/dist/pdf/structure/index.js.map +1 -0
- package/dist/pdf/structure/labels.d.ts +16 -0
- package/dist/pdf/structure/labels.js +45 -0
- package/dist/pdf/structure/labels.js.map +1 -0
- package/dist/pdf/structure/links.d.ts +49 -0
- package/dist/pdf/structure/links.js +136 -0
- package/dist/pdf/structure/links.js.map +1 -0
- package/dist/pdf/structure/tags.d.ts +79 -0
- package/dist/pdf/structure/tags.js +314 -0
- package/dist/pdf/structure/tags.js.map +1 -0
- package/dist/pdf/types.d.ts +534 -0
- package/dist/pdf/types.js +16 -0
- package/dist/pdf/types.js.map +1 -0
- package/dist/pdf/wasm/pulpweaver4_pdf.d.ts +41 -0
- package/dist/pdf/wasm/pulpweaver4_pdf.js +286 -0
- package/dist/pdf/wasm/pulpweaver4_pdf_bg.wasm +0 -0
- package/dist/pdf/writer.d.ts +41 -0
- package/dist/pdf/writer.js +78 -0
- package/dist/pdf/writer.js.map +1 -0
- package/dist/plugin/attributes.d.ts +10 -0
- package/dist/plugin/attributes.js +63 -0
- package/dist/plugin/attributes.js.map +1 -0
- package/dist/plugin/define.d.ts +425 -0
- package/dist/plugin/define.js +311 -0
- package/dist/plugin/define.js.map +1 -0
- package/dist/plugin/failure.d.ts +80 -0
- package/dist/plugin/failure.js +97 -0
- package/dist/plugin/failure.js.map +1 -0
- package/dist/plugin/index.d.ts +11 -0
- package/dist/plugin/index.js +12 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/load.d.ts +105 -0
- package/dist/plugin/load.js +197 -0
- package/dist/plugin/load.js.map +1 -0
- package/dist/plugin/register.d.ts +166 -0
- package/dist/plugin/register.js +306 -0
- package/dist/plugin/register.js.map +1 -0
- package/dist/plugin/render.d.ts +4 -0
- package/dist/plugin/render.js +28 -0
- package/dist/plugin/render.js.map +1 -0
- package/dist/preflight/index.d.ts +3 -0
- package/dist/preflight/index.js +4 -0
- package/dist/preflight/index.js.map +1 -0
- package/dist/preflight/pdfx.d.ts +440 -0
- package/dist/preflight/pdfx.js +1779 -0
- package/dist/preflight/pdfx.js.map +1 -0
- package/dist/preflight/reader.d.ts +126 -0
- package/dist/preflight/reader.js +832 -0
- package/dist/preflight/reader.js.map +1 -0
- package/dist/preflight/xmp.d.ts +30 -0
- package/dist/preflight/xmp.js +145 -0
- package/dist/preflight/xmp.js.map +1 -0
- package/dist/print/index.d.ts +2 -0
- package/dist/print/index.js +3 -0
- package/dist/print/index.js.map +1 -0
- package/dist/print/output.d.ts +5 -0
- package/dist/print/output.js +199 -0
- package/dist/print/output.js.map +1 -0
- package/dist/problem.d.ts +142 -0
- package/dist/problem.js +234 -0
- package/dist/problem.js.map +1 -0
- package/dist/profile/index.d.ts +10 -0
- package/dist/profile/index.js +11 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/profile/lint.d.ts +69 -0
- package/dist/profile/lint.js +282 -0
- package/dist/profile/lint.js.map +1 -0
- package/dist/profile/metadata.d.ts +27 -0
- package/dist/profile/metadata.js +38 -0
- package/dist/profile/metadata.js.map +1 -0
- package/dist/profile/profile.d.ts +92 -0
- package/dist/profile/profile.js +282 -0
- package/dist/profile/profile.js.map +1 -0
- package/dist/project.d.ts +56 -0
- package/dist/project.js +137 -0
- package/dist/project.js.map +1 -0
- package/dist/reproducible/clock.d.ts +46 -0
- package/dist/reproducible/clock.js +173 -0
- package/dist/reproducible/clock.js.map +1 -0
- package/dist/reproducible/date.d.ts +42 -0
- package/dist/reproducible/date.js +82 -0
- package/dist/reproducible/date.js.map +1 -0
- package/dist/reproducible/index.d.ts +8 -0
- package/dist/reproducible/index.js +9 -0
- package/dist/reproducible/index.js.map +1 -0
- package/dist/spike/spike-page.chromium.json +330 -0
- package/dist/spike/spike.d.ts +75 -0
- package/dist/spike/spike.js +106 -0
- package/dist/spike/spike.js.map +1 -0
- package/dist/style/borders.d.ts +25 -0
- package/dist/style/borders.js +177 -0
- package/dist/style/borders.js.map +1 -0
- package/dist/style/colours.d.ts +34 -0
- package/dist/style/colours.js +138 -0
- package/dist/style/colours.js.map +1 -0
- package/dist/style/compile.d.ts +79 -0
- package/dist/style/compile.js +325 -0
- package/dist/style/compile.js.map +1 -0
- package/dist/style/defaults.d.ts +20 -0
- package/dist/style/defaults.js +45 -0
- package/dist/style/defaults.js.map +1 -0
- package/dist/style/gcpm.d.ts +22 -0
- package/dist/style/gcpm.js +86 -0
- package/dist/style/gcpm.js.map +1 -0
- package/dist/style/index.d.ts +4 -0
- package/dist/style/index.js +5 -0
- package/dist/style/index.js.map +1 -0
- package/dist/style/media.d.ts +22 -0
- package/dist/style/media.js +342 -0
- package/dist/style/media.js.map +1 -0
- package/dist/style/properties.d.ts +44 -0
- package/dist/style/properties.js +497 -0
- package/dist/style/properties.js.map +1 -0
- package/dist/style/scope.d.ts +6 -0
- package/dist/style/scope.js +134 -0
- package/dist/style/scope.js.map +1 -0
- package/dist/style/values.d.ts +45 -0
- package/dist/style/values.js +106 -0
- package/dist/style/values.js.map +1 -0
- package/dist/test/book.d.ts +180 -0
- package/dist/test/book.js +314 -0
- package/dist/test/book.js.map +1 -0
- package/dist/test/build.d.ts +58 -0
- package/dist/test/build.js +222 -0
- package/dist/test/build.js.map +1 -0
- package/dist/test/environment.d.ts +63 -0
- package/dist/test/environment.js +46 -0
- package/dist/test/environment.js.map +1 -0
- package/dist/test/index.d.ts +17 -0
- package/dist/test/index.js +18 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/indexes.d.ts +4 -0
- package/dist/test/indexes.js +48 -0
- package/dist/test/indexes.js.map +1 -0
- package/dist/test/layout.d.ts +8 -0
- package/dist/test/layout.js +120 -0
- package/dist/test/layout.js.map +1 -0
- package/dist/test/matchers.d.ts +80 -0
- package/dist/test/matchers.js +177 -0
- package/dist/test/matchers.js.map +1 -0
- package/dist/test/pipeline.d.ts +228 -0
- package/dist/test/pipeline.js +73 -0
- package/dist/test/pipeline.js.map +1 -0
- package/dist/test/plugins.d.ts +13 -0
- package/dist/test/plugins.js +22 -0
- package/dist/test/plugins.js.map +1 -0
- package/dist/test/render.d.ts +46 -0
- package/dist/test/render.js +149 -0
- package/dist/test/render.js.map +1 -0
- package/dist/test/runner.d.ts +61 -0
- package/dist/test/runner.js +256 -0
- package/dist/test/runner.js.map +1 -0
- package/dist/test/select.d.ts +54 -0
- package/dist/test/select.js +193 -0
- package/dist/test/select.js.map +1 -0
- package/dist/test/snapshot.d.ts +52 -0
- package/dist/test/snapshot.js +175 -0
- package/dist/test/snapshot.js.map +1 -0
- package/dist/test/text.d.ts +7 -0
- package/dist/test/text.js +46 -0
- package/dist/test/text.js.map +1 -0
- package/dist/test/vitest.d.ts +3 -0
- package/dist/test/vitest.js +39 -0
- package/dist/test/vitest.js.map +1 -0
- package/dist/text/index.d.ts +5 -0
- package/dist/text/index.js +6 -0
- package/dist/text/index.js.map +1 -0
- package/dist/text/output.d.ts +5 -0
- package/dist/text/output.js +39 -0
- package/dist/text/output.js.map +1 -0
- package/dist/text/render.d.ts +82 -0
- package/dist/text/render.js +583 -0
- package/dist/text/render.js.map +1 -0
- package/dist/text/width.d.ts +16 -0
- package/dist/text/width.js +90 -0
- package/dist/text/width.js.map +1 -0
- package/dist/text/wrap.d.ts +19 -0
- package/dist/text/wrap.js +151 -0
- package/dist/text/wrap.js.map +1 -0
- package/dist/transform/core.d.ts +19 -0
- package/dist/transform/core.js +22 -0
- package/dist/transform/core.js.map +1 -0
- package/dist/transform/index.d.ts +10 -0
- package/dist/transform/index.js +11 -0
- package/dist/transform/index.js.map +1 -0
- package/dist/transform/numbering.d.ts +47 -0
- package/dist/transform/numbering.js +142 -0
- package/dist/transform/numbering.js.map +1 -0
- package/dist/transform/references.d.ts +38 -0
- package/dist/transform/references.js +182 -0
- package/dist/transform/references.js.map +1 -0
- package/dist/transform/run.d.ts +32 -0
- package/dist/transform/run.js +210 -0
- package/dist/transform/run.js.map +1 -0
- package/dist/transform/store.d.ts +111 -0
- package/dist/transform/store.js +331 -0
- package/dist/transform/store.js.map +1 -0
- package/dist/transform/testing.d.ts +31 -0
- package/dist/transform/testing.js +76 -0
- package/dist/transform/testing.js.map +1 -0
- package/dist/transform/transform.d.ts +104 -0
- package/dist/transform/transform.js +89 -0
- package/dist/transform/transform.js.map +1 -0
- package/dist/vfs/fsa.d.ts +14 -0
- package/dist/vfs/fsa.js +123 -0
- package/dist/vfs/fsa.js.map +1 -0
- package/dist/vfs/index.d.ts +7 -0
- package/dist/vfs/index.js +8 -0
- package/dist/vfs/index.js.map +1 -0
- package/dist/vfs/memory.d.ts +15 -0
- package/dist/vfs/memory.js +101 -0
- package/dist/vfs/memory.js.map +1 -0
- package/dist/vfs/path.d.ts +30 -0
- package/dist/vfs/path.js +67 -0
- package/dist/vfs/path.js.map +1 -0
- package/dist/vfs/vfs.d.ts +66 -0
- package/dist/vfs/vfs.js +68 -0
- package/dist/vfs/vfs.js.map +1 -0
- package/dist/vfs/zip.d.ts +27 -0
- package/dist/vfs/zip.js +67 -0
- package/dist/vfs/zip.js.map +1 -0
- package/dist/web/css.d.ts +15 -0
- package/dist/web/css.js +80 -0
- package/dist/web/css.js.map +1 -0
- package/dist/web/hast.d.ts +44 -0
- package/dist/web/hast.js +175 -0
- package/dist/web/hast.js.map +1 -0
- package/dist/web/index.d.ts +11 -0
- package/dist/web/index.js +12 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/justify-main.d.ts +1 -0
- package/dist/web/justify-main.js +38 -0
- package/dist/web/justify-main.js.map +1 -0
- package/dist/web/justify.d.ts +46 -0
- package/dist/web/justify.js +147 -0
- package/dist/web/justify.js.map +1 -0
- package/dist/web/output.d.ts +28 -0
- package/dist/web/output.js +251 -0
- package/dist/web/output.js.map +1 -0
- package/dist/web/runtime/LICENSE-harfbuzzjs.txt +19 -0
- package/dist/web/runtime/NOTICE-patterns.txt +429 -0
- package/dist/web/runtime/harfbuzz.wasm +0 -0
- package/dist/web/runtime/justify.js.txt +2 -0
- package/dist/web/site.d.ts +53 -0
- package/dist/web/site.js +219 -0
- package/dist/web/site.js.map +1 -0
- package/docs/README.md +16 -0
- package/docs/reference/css-properties/index.md +94 -0
- package/docs/reference/css-properties/pw-adj-demerits.md +22 -0
- package/docs/reference/css-properties/pw-border-bottom-width.md +24 -0
- package/docs/reference/css-properties/pw-border-left-width.md +24 -0
- package/docs/reference/css-properties/pw-border-right-width.md +24 -0
- package/docs/reference/css-properties/pw-border-top-width.md +24 -0
- package/docs/reference/css-properties/pw-box.md +28 -0
- package/docs/reference/css-properties/pw-broken-penalty.md +22 -0
- package/docs/reference/css-properties/pw-club-penalty.md +24 -0
- package/docs/reference/css-properties/pw-column-rule-width.md +23 -0
- package/docs/reference/css-properties/pw-content-after.md +31 -0
- package/docs/reference/css-properties/pw-content-before.md +31 -0
- package/docs/reference/css-properties/pw-double-hyphen-demerits.md +23 -0
- package/docs/reference/css-properties/pw-emergency-stretch.md +28 -0
- package/docs/reference/css-properties/pw-ex-hyphen-penalty.md +22 -0
- package/docs/reference/css-properties/pw-final-hyphen-demerits.md +22 -0
- package/docs/reference/css-properties/pw-float-skip.md +22 -0
- package/docs/reference/css-properties/pw-float.md +33 -0
- package/docs/reference/css-properties/pw-footnote-max-height.md +22 -0
- package/docs/reference/css-properties/pw-footnote-skip.md +23 -0
- package/docs/reference/css-properties/pw-hyphen-penalty.md +24 -0
- package/docs/reference/css-properties/pw-inter-line-penalty.md +24 -0
- package/docs/reference/css-properties/pw-leader-space.md +22 -0
- package/docs/reference/css-properties/pw-leader.md +29 -0
- package/docs/reference/css-properties/pw-left-hyphen-min.md +23 -0
- package/docs/reference/css-properties/pw-line-breaking.md +29 -0
- package/docs/reference/css-properties/pw-line-penalty.md +23 -0
- package/docs/reference/css-properties/pw-list-indent.md +18 -0
- package/docs/reference/css-properties/pw-looseness.md +30 -0
- package/docs/reference/css-properties/pw-max-depth.md +22 -0
- package/docs/reference/css-properties/pw-minipage-footnotes.md +23 -0
- package/docs/reference/css-properties/pw-orphans.md +24 -0
- package/docs/reference/css-properties/pw-outline-width.md +23 -0
- package/docs/reference/css-properties/pw-overprint.md +26 -0
- package/docs/reference/css-properties/pw-padding-bottom.md +22 -0
- package/docs/reference/css-properties/pw-padding-left.md +22 -0
- package/docs/reference/css-properties/pw-padding-right.md +22 -0
- package/docs/reference/css-properties/pw-padding-top.md +22 -0
- package/docs/reference/css-properties/pw-page-prefix.md +28 -0
- package/docs/reference/css-properties/pw-page.md +32 -0
- package/docs/reference/css-properties/pw-penalty-after.md +23 -0
- package/docs/reference/css-properties/pw-penalty-before.md +30 -0
- package/docs/reference/css-properties/pw-pretolerance.md +23 -0
- package/docs/reference/css-properties/pw-right-hyphen-min.md +22 -0
- package/docs/reference/css-properties/pw-running.md +23 -0
- package/docs/reference/css-properties/pw-site-background.md +21 -0
- package/docs/reference/css-properties/pw-site-link.md +17 -0
- package/docs/reference/css-properties/pw-site-measure.md +17 -0
- package/docs/reference/css-properties/pw-site-muted.md +21 -0
- package/docs/reference/css-properties/pw-site-rule.md +17 -0
- package/docs/reference/css-properties/pw-site-text.md +22 -0
- package/docs/reference/css-properties/pw-space-after.md +23 -0
- package/docs/reference/css-properties/pw-space-before.md +29 -0
- package/docs/reference/css-properties/pw-string-set.md +32 -0
- package/docs/reference/css-properties/pw-tolerance.md +33 -0
- package/docs/reference/css-properties/pw-top-skip.md +22 -0
- package/docs/reference/css-properties/pw-widow-penalty.md +32 -0
- package/docs/reference/css-properties/pw-widows.md +24 -0
- package/docs/reference/css-properties/pw-word-space.md +22 -0
- package/docs/reference/css-properties/pw-xspace.md +22 -0
- package/docs/reference/index.md +17 -0
- package/docs/reference/lint-rules/black-text.md +31 -0
- package/docs/reference/lint-rules/blank-page.md +35 -0
- package/docs/reference/lint-rules/chapter-verso.md +34 -0
- package/docs/reference/lint-rules/citation-in-heading.md +24 -0
- package/docs/reference/lint-rules/consecutive-hyphens.md +34 -0
- package/docs/reference/lint-rules/empty-link.md +32 -0
- package/docs/reference/lint-rules/figure-distance.md +34 -0
- package/docs/reference/lint-rules/fonts.md +24 -0
- package/docs/reference/lint-rules/generated-text.md +24 -0
- package/docs/reference/lint-rules/heading-levels.md +30 -0
- package/docs/reference/lint-rules/ibid-across-page.md +30 -0
- package/docs/reference/lint-rules/image-alt.md +30 -0
- package/docs/reference/lint-rules/image-resolution.md +34 -0
- package/docs/reference/lint-rules/index.md +120 -0
- package/docs/reference/lint-rules/ink-limit.md +30 -0
- package/docs/reference/lint-rules/missing-field.md +37 -0
- package/docs/reference/lint-rules/orphan.md +34 -0
- package/docs/reference/lint-rules/overfull-line.md +28 -0
- package/docs/reference/lint-rules/profile.md +24 -0
- package/docs/reference/lint-rules/raw-html.md +30 -0
- package/docs/reference/lint-rules/signature.md +34 -0
- package/docs/reference/lint-rules/straight-quotes.md +33 -0
- package/docs/reference/lint-rules/svg-use-css.md +24 -0
- package/docs/reference/lint-rules/underfull-line.md +35 -0
- package/docs/reference/lint-rules/unknown-citation.md +30 -0
- package/docs/reference/lint-rules/unknown-label.md +31 -0
- package/docs/reference/lint-rules/unpaintable.md +24 -0
- package/docs/reference/lint-rules/unplaced-index.md +31 -0
- package/docs/reference/lint-rules/unused-entry.md +36 -0
- package/docs/reference/lint-rules/widow.md +34 -0
- package/docs/reference/plugin-api/assert-no-errors.md +18 -0
- package/docs/reference/plugin-api/asset-processor.md +28 -0
- package/docs/reference/plugin-api/attribute-problem.md +26 -0
- package/docs/reference/plugin-api/attribute-type.md +18 -0
- package/docs/reference/plugin-api/capabilities.md +18 -0
- package/docs/reference/plugin-api/capability.md +22 -0
- package/docs/reference/plugin-api/check-attributes.md +18 -0
- package/docs/reference/plugin-api/claim-kind.md +20 -0
- package/docs/reference/plugin-api/combine-penalties.md +17 -0
- package/docs/reference/plugin-api/command-context.md +30 -0
- package/docs/reference/plugin-api/command-definition.md +34 -0
- package/docs/reference/plugin-api/core-claims.md +18 -0
- package/docs/reference/plugin-api/define-plugin.md +20 -0
- package/docs/reference/plugin-api/define-rule.md +19 -0
- package/docs/reference/plugin-api/describe-error.md +14 -0
- package/docs/reference/plugin-api/describe-node.md +14 -0
- package/docs/reference/plugin-api/empty-registry.md +18 -0
- package/docs/reference/plugin-api/failed-on.md +32 -0
- package/docs/reference/plugin-api/fails-as.md +18 -0
- package/docs/reference/plugin-api/import-plugins.md +20 -0
- package/docs/reference/plugin-api/import-text.md +14 -0
- package/docs/reference/plugin-api/index.md +123 -0
- package/docs/reference/plugin-api/layout-definition.md +42 -0
- package/docs/reference/plugin-api/layout-slot.md +28 -0
- package/docs/reference/plugin-api/line-breaker.md +18 -0
- package/docs/reference/plugin-api/lint-context.md +48 -0
- package/docs/reference/plugin-api/lint-definition.md +32 -0
- package/docs/reference/plugin-api/lint-edition.md +38 -0
- package/docs/reference/plugin-api/lint-fix.md +36 -0
- package/docs/reference/plugin-api/lint-level.md +20 -0
- package/docs/reference/plugin-api/lint-preset.md +30 -0
- package/docs/reference/plugin-api/lint-rule.md +42 -0
- package/docs/reference/plugin-api/load-failure.md +32 -0
- package/docs/reference/plugin-api/load-plugins-options.md +32 -0
- package/docs/reference/plugin-api/load-plugins.md +20 -0
- package/docs/reference/plugin-api/loaded-plugin.md +32 -0
- package/docs/reference/plugin-api/node-claim.md +34 -0
- package/docs/reference/plugin-api/output-definition.md +28 -0
- package/docs/reference/plugin-api/owned.md +28 -0
- package/docs/reference/plugin-api/page-builder-hook.md +18 -0
- package/docs/reference/plugin-api/penalty-rule.md +34 -0
- package/docs/reference/plugin-api/plugin-api.md +18 -0
- package/docs/reference/plugin-api/plugin-definition.md +66 -0
- package/docs/reference/plugin-api/plugin-error.md +22 -0
- package/docs/reference/plugin-api/plugin-failure.md +30 -0
- package/docs/reference/plugin-api/plugin-importer.md +34 -0
- package/docs/reference/plugin-api/plugin-problem.md +30 -0
- package/docs/reference/plugin-api/plugin-registry.md +83 -0
- package/docs/reference/plugin-api/plugin-scope.md +15 -0
- package/docs/reference/plugin-api/plugin-stage.md +18 -0
- package/docs/reference/plugin-api/plugin-threw-problem.md +34 -0
- package/docs/reference/plugin-api/plugin-threw.md +21 -0
- package/docs/reference/plugin-api/plugin.md +69 -0
- package/docs/reference/plugin-api/project-with-plugins.md +36 -0
- package/docs/reference/plugin-api/read-context.md +30 -0
- package/docs/reference/plugin-api/read-failure.md +18 -0
- package/docs/reference/plugin-api/read-plugin-styles.md +22 -0
- package/docs/reference/plugin-api/reader.md +22 -0
- package/docs/reference/plugin-api/register-options.md +28 -0
- package/docs/reference/plugin-api/register-plugins.md +20 -0
- package/docs/reference/plugin-api/render-format.md +18 -0
- package/docs/reference/plugin-api/render-formats.md +18 -0
- package/docs/reference/plugin-api/renderer-registry.md +18 -0
- package/docs/reference/plugin-api/renderer-set.md +34 -0
- package/docs/reference/plugin-api/renderers.md +34 -0
- package/docs/reference/plugin-api/specifier-kind.md +14 -0
- package/docs/reference/plugin-api/style-source.md +18 -0
- package/docs/reference/plugin-api/text-context.md +28 -0
- package/docs/reference/plugin-api/text-edit.md +28 -0
- package/docs/reference/plugin-api/text-renderer.md +24 -0
- package/docs/reference/plugin-api/try-plugin-async.md +18 -0
- package/docs/reference/plugin-api/try-plugin.md +20 -0
- package/docs/reference/pulpweaver4-toml/editions.md +194 -0
- package/docs/reference/pulpweaver4-toml/index.md +182 -0
- package/docs/reference/pulpweaver4-toml/inks.md +50 -0
- package/docs/reference/pulpweaver4-toml/lint.md +36 -0
- package/docs/reference/test-matchers/index.md +33 -0
- package/docs/reference/test-matchers/to-be-recto.md +20 -0
- package/docs/reference/test-matchers/to-cite.md +22 -0
- package/docs/reference/test-matchers/to-fit-on-one-page.md +20 -0
- package/docs/reference/test-matchers/to-have-no-overfull-lines.md +20 -0
- package/docs/reference/test-matchers/to-match-html-snapshot.md +20 -0
- package/docs/reference/test-matchers/to-match-page-snapshot.md +20 -0
- package/docs/reference/test-matchers/to-match-text-snapshot.md +21 -0
- package/docs/reference/test-matchers/to-start-page.md +20 -0
- package/package.json +75 -4
- package/README.md +0 -3
|
@@ -0,0 +1,1779 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A PDF/X checker: PDF/X-1a (ISO 15930-1:2001 and 15930-4:2003), PDF/X-3
|
|
3
|
+
* (15930-3:2002 and 15930-6:2003) and PDF/X-4 (15930-7:2010). PDF/X has no
|
|
4
|
+
* free validator, so the core checks its own output against every rule a
|
|
5
|
+
* file can be checked for (https://plans.inkylabs.com/pulpweaver#every-kind-of-pdf).
|
|
6
|
+
*
|
|
7
|
+
* Each rule names its clauses in ISO 15930-4 (PDF/X-1a:2003), -6
|
|
8
|
+
* (X-3:2003) and -7 (X-4), against which they were checked clause by clause
|
|
9
|
+
* (#121); `iso-15930.md` beside this file goes through every clause of the
|
|
10
|
+
* three and says which rule checks it, or why none can. The rules paraphrase
|
|
11
|
+
* the standards, whose text is ISO's. Where a clause leans on the PDF
|
|
12
|
+
* Reference (1.4 for the 2003 parts, 1.6 for X-4), so do the rules.
|
|
13
|
+
*
|
|
14
|
+
* PDF/X-1a:2001 and X-3:2002 (ISO 15930-1 and -3, PDF 1.3) are held to
|
|
15
|
+
* their 2003 successors' rules; they were not read clause by clause.
|
|
16
|
+
*/
|
|
17
|
+
import { contentOps, newLexical, PdfDict, PdfFile, PdfFilterError, PdfRef, PdfStream, PdfString } from './reader.js';
|
|
18
|
+
import { XMP_NS, decodeXmp, xmpProperty, xmpProblems } from './xmp.js';
|
|
19
|
+
/** The PDF/X standards the checker knows. */
|
|
20
|
+
export const PDF_X_STANDARDS = ['PDF/X-1a:2001', 'PDF/X-1a:2003', 'PDF/X-3:2002', 'PDF/X-3:2003', 'PDF/X-4'];
|
|
21
|
+
const ALL = PDF_X_STANDARDS;
|
|
22
|
+
const X1A = ['PDF/X-1a:2001', 'PDF/X-1a:2003'];
|
|
23
|
+
const X3 = ['PDF/X-3:2002', 'PDF/X-3:2003'];
|
|
24
|
+
const BEFORE_X4 = [...X1A, ...X3];
|
|
25
|
+
const X3_X4 = [...X3, 'PDF/X-4'];
|
|
26
|
+
const X4 = ['PDF/X-4'];
|
|
27
|
+
/** The rules, by ID. */
|
|
28
|
+
export const PDF_X_RULES = {
|
|
29
|
+
'PDFX-SYNTAX': {
|
|
30
|
+
text: 'The file is PDF as the PDF Reference defines it (1.4 before X-4, 1.6 for X-4), as far as the checker reads it.',
|
|
31
|
+
standards: ALL,
|
|
32
|
+
clauses: { '15930-4': '6.1, Annex A', '15930-6': '6.1, Annex A', '15930-7': '6.1.1' },
|
|
33
|
+
note: 'The corpus checks the rest of the PDF Reference with the Arlington PDF Model (tests/pdf/checks.bzl).',
|
|
34
|
+
},
|
|
35
|
+
'PDFX-COMPRESSION': {
|
|
36
|
+
text: 'Before PDF/X-4, no cross-reference or object streams, which came with PDF 1.5.',
|
|
37
|
+
standards: BEFORE_X4,
|
|
38
|
+
clauses: { '15930-4': '6.1', '15930-6': '6.1' },
|
|
39
|
+
note: 'The 2003 parts use PDF as the PDF Reference 1.4 has it (6.1), which has neither. Neither the header’s version nor the catalog’s /Version decides conformance (clause 5), so they are not checked.',
|
|
40
|
+
},
|
|
41
|
+
'PDFX-ENCRYPT': {
|
|
42
|
+
text: 'The file is not encrypted (no /Encrypt in the trailer); in X-4 a /Perms dictionary has only /UR and /UR3.',
|
|
43
|
+
standards: ALL,
|
|
44
|
+
clauses: { '15930-4': '6.11', '15930-6': '6.11', '15930-7': '6.15' },
|
|
45
|
+
},
|
|
46
|
+
'PDFX-TRAILER-ID': {
|
|
47
|
+
text: 'The trailer has an /ID (of two strings, as the PDF Reference has it).',
|
|
48
|
+
standards: ALL,
|
|
49
|
+
clauses: { '15930-4': '6.7', '15930-6': '6.7', '15930-7': '6.10.4' },
|
|
50
|
+
note: 'That the ID is likely to be unique is a recommendation, and can’t be checked from one file.',
|
|
51
|
+
},
|
|
52
|
+
'PDFX-VERSION-ID': {
|
|
53
|
+
text: 'The file identifies its standard: before X-4, Info /GTS_PDFXVersion (PDF/X-1a:2003, PDF/X-3:2003; PDF/X-1:2001 with /GTS_PDFXConformance (PDF/X-1a:2001), PDF/X-3:2002); in X-4, XMP pdfxid:GTS_PDFXVersion “PDF/X-4”, with no other pdfxid property and no Info /GTS_PDFXConformance, and Info /GTS_PDFXVersion, if present, the same and in PDFDocEncoding.',
|
|
54
|
+
standards: ALL,
|
|
55
|
+
clauses: { '15930-4': '6.7', '15930-6': '6.7', '15930-7': '6.10.2, 6.11' },
|
|
56
|
+
},
|
|
57
|
+
'PDFX-METADATA': {
|
|
58
|
+
text: 'PDF/X-4: the catalog has an XMP /Metadata stream without /Filter, well-formed, whose packet header has no bytes or encoding attribute, and which binds the namespaces of Table 2 to their prefixes: dc, pdf, xmp, xmpMM and pdfxid.',
|
|
59
|
+
standards: X4,
|
|
60
|
+
clauses: { '15930-7': '6.10.1, 6.10.3, 6.10.6' },
|
|
61
|
+
note: 'Well-formed as XML (tags matched and nested, attributes quoted, & and < escaped); RDF/XML’s own grammar is not checked.',
|
|
62
|
+
},
|
|
63
|
+
'PDFX-TITLE': {
|
|
64
|
+
text: 'A title, not empty: Info /Title before X-4, XMP dc:title in X-4.',
|
|
65
|
+
standards: ALL,
|
|
66
|
+
clauses: { '15930-4': '6.7', '15930-6': '6.7', '15930-7': '6.10.4' },
|
|
67
|
+
},
|
|
68
|
+
'PDFX-DATES': {
|
|
69
|
+
text: 'Dates, not empty: Info /CreationDate and /ModDate before X-4; XMP xmp:CreateDate, xmp:ModifyDate and xmp:MetadataDate in X-4.',
|
|
70
|
+
standards: ALL,
|
|
71
|
+
clauses: { '15930-4': '6.7', '15930-6': '6.7', '15930-7': '6.10.4' },
|
|
72
|
+
note: 'That they are updated when the file is changed (-4 and -6 6.7, -7 6.10.5) can’t be checked from one file.',
|
|
73
|
+
},
|
|
74
|
+
'PDFX-TRAPPED': {
|
|
75
|
+
text: 'Whether the file is trapped, /True or /False and never /Unknown: Info /Trapped before X-4, XMP pdf:Trapped in X-4; True if a page has a TrapNet annotation, whose /FontFauxing is absent or empty and whose appearance’s /PCM is DeviceCMYK in X-1a, the output intent’s colour space otherwise.',
|
|
76
|
+
standards: ALL,
|
|
77
|
+
clauses: { '15930-4': '6.6', '15930-6': '6.6', '15930-7': '6.9' },
|
|
78
|
+
note: 'That a file said to be trapped is trapped throughout can’t be checked.',
|
|
79
|
+
},
|
|
80
|
+
'PDFX-XMP-IDS': {
|
|
81
|
+
text: 'PDF/X-4: XMP has xmpMM:DocumentID, xmpMM:VersionID and xmpMM:RenditionClass.',
|
|
82
|
+
standards: X4,
|
|
83
|
+
clauses: { '15930-7': '6.10.4' },
|
|
84
|
+
},
|
|
85
|
+
'PDFX-INFO-XMP': {
|
|
86
|
+
text: 'PDF/X-4: each Info entry with an XMP counterpart (Title, Author, Subject, Keywords, Creator, Producer, CreationDate, ModDate, Trapped, GTS_PDFXVersion) is in the XMP too, with the same value: text character by character, dates component by component in UTC, and Author as dc:creator’s one item.',
|
|
87
|
+
standards: X4,
|
|
88
|
+
clauses: { '15930-7': '6.10.2' },
|
|
89
|
+
},
|
|
90
|
+
'PDFX-OUTPUT-INTENT': {
|
|
91
|
+
text: 'The catalog has exactly one GTS_PDFX output intent, with an /OutputConditionIdentifier text string.',
|
|
92
|
+
standards: ALL,
|
|
93
|
+
clauses: { '15930-4': '6.2.2', '15930-6': '6.2.2', '15930-7': '6.4.2.1' },
|
|
94
|
+
note: 'That an identifier with a /RegistryName is a reference name in that registry is not checked: registries change, and the checker has no copy of one.',
|
|
95
|
+
},
|
|
96
|
+
'PDFX-OUTPUT-PROFILE': {
|
|
97
|
+
text: 'The output intent’s /DestOutputProfile is an output device (prtr) ICC profile. X-4 always embeds it, without the /DestOutputProfileRef of X-4p, and its colour space is grey, RGB or CMYK; X-1a’s is CMYK. Before X-4 it may be left out when /RegistryName is http://www.color.org, but not in X-3 if print elements use ICC-based or CIE colour.',
|
|
98
|
+
standards: ALL,
|
|
99
|
+
clauses: { '15930-4': '6.2.1, 6.2.2', '15930-6': '6.2.2', '15930-7': '6.4.1, 6.4.2.1' },
|
|
100
|
+
note: 'X-1a’s CMYK is 6.2.1’s: its print elements are CMYK, grey or spot colour for the characterized condition. An identifier of Custom names no registered condition, whatever /RegistryName says.',
|
|
101
|
+
},
|
|
102
|
+
'PDFX-ICC-VERSION': {
|
|
103
|
+
text: 'ICC profiles are of a version the standard allows: before PDF/X-4, version 2, the output intent’s as ICC.1:1998 defines an output profile and ICC-based colour spaces’ as PDF 1.4 holds them; in X-4, version 2 or 4.0 to 4.2 (ICC.1:1998-09, ICC.1:2001-12, ICC.1:2003-09 or ISO 15076-1:2005), both.',
|
|
104
|
+
standards: ALL,
|
|
105
|
+
clauses: { '15930-4': '6.2.2', '15930-6': '6.1, 6.2.2', '15930-7': '6.4.2.1, 6.4.3.3' },
|
|
106
|
+
note: 'The 2003 parts cite ICC.1:1998 alone; their PDF Reference 1.4 holds ICC profiles to version 2.3.',
|
|
107
|
+
},
|
|
108
|
+
'PDFX-PROFILE-REUSE': {
|
|
109
|
+
text: 'PDF/X-4: no four-colour ICC-based colour space has the output intent’s profile: the same stream, or the same MD5, from the profiles’ IDs or computed as ISO 15076-1 does (their bytes with the flags, rendering intent and ID set to zero).',
|
|
110
|
+
standards: X4,
|
|
111
|
+
clauses: { '15930-7': '6.4.3.3' },
|
|
112
|
+
},
|
|
113
|
+
'PDFX-ICC-OVERPRINT': {
|
|
114
|
+
text: 'PDF/X-4, under a CMYK output intent: a stroke, fill, text or image mask in a four-colour ICC-based colour space that overprints does so in overprint mode 0.',
|
|
115
|
+
standards: X4,
|
|
116
|
+
clauses: { '15930-7': '6.4.3.3' },
|
|
117
|
+
note: 'A form XObject or pattern is checked once, in the graphics state it is first painted in.',
|
|
118
|
+
},
|
|
119
|
+
'PDFX-PAGE-BOX': {
|
|
120
|
+
text: 'Every page has a /TrimBox or an /ArtBox, but not both.',
|
|
121
|
+
standards: ALL,
|
|
122
|
+
clauses: { '15930-4': '6.8', '15930-6': '6.8', '15930-7': '6.12' },
|
|
123
|
+
},
|
|
124
|
+
'PDFX-BOX-NESTING': {
|
|
125
|
+
text: 'Each page’s trim or art box lies within its bleed box, if it has one; its trim, art and bleed boxes within its crop box, if it has one; and all four within its media box.',
|
|
126
|
+
standards: ALL,
|
|
127
|
+
clauses: { '15930-4': '6.8', '15930-6': '6.8', '15930-7': '6.12' },
|
|
128
|
+
},
|
|
129
|
+
'PDFX-FONT-EMBEDDED': {
|
|
130
|
+
text: 'Every font text is shown in is embedded, the standard 14 included (a Type 3 font’s glyphs are content, checked as such); in X-4, but a font used only in text rendering mode 3 (invisible).',
|
|
131
|
+
standards: ALL,
|
|
132
|
+
clauses: { '15930-4': '6.3', '15930-6': '6.3', '15930-7': '6.5.1' },
|
|
133
|
+
note: 'That each program has a glyph for every character used needs reading the font programs, which the checker doesn’t; nor can it know a font’s licence.',
|
|
134
|
+
},
|
|
135
|
+
'PDFX-NOTDEF': {
|
|
136
|
+
text: 'PDF/X-4: no text shows the .notdef glyph: code 0 of a composite font with an Identity encoding and an Identity CID-to-glyph map (or a CFF CIDFont’s CID 0), or a code a simple font’s /Differences names /.notdef.',
|
|
137
|
+
standards: X4,
|
|
138
|
+
clauses: { '15930-7': '6.5.2' },
|
|
139
|
+
note: 'Other fonts reach glyphs through their programs’ cmap tables or CMaps, which are not read.',
|
|
140
|
+
},
|
|
141
|
+
'PDFX-TRUETYPE-ENCODING': {
|
|
142
|
+
text: 'PDF/X-4: a non-symbolic TrueType font’s encoding is /MacRomanEncoding or /WinAnsiEncoding, as its /Encoding or that dictionary’s /BaseEncoding, without /Differences; a symbolic one has no /Encoding, and its program’s cmap table exactly one subtable.',
|
|
143
|
+
standards: X4,
|
|
144
|
+
clauses: { '15930-7': '6.5.4' },
|
|
145
|
+
},
|
|
146
|
+
'PDFX-NAMES': {
|
|
147
|
+
text: 'PDF/X-4: font names and separation names are UTF-8, with every byte outside 33 (!) to 126 (~) written #xx.',
|
|
148
|
+
standards: X4,
|
|
149
|
+
clauses: { '15930-7': '6.6' },
|
|
150
|
+
},
|
|
151
|
+
'PDFX-FILES': {
|
|
152
|
+
text: 'Before X-4, no file specifications: no embedded files, file attachment annotations, external streams (/F in a stream dictionary), reference XObjects (/Ref) or file specification dictionaries; in X-4, every file specification embeds its file (/EF), no stream is external and no form XObject has /Ref.',
|
|
153
|
+
standards: ALL,
|
|
154
|
+
clauses: { '15930-4': '6.4', '15930-6': '6.4', '15930-7': '6.7' },
|
|
155
|
+
note: 'A file specification may be a bare string, which only its place shows: the checker looks in the places the PDF Reference gives them (annotations’ /FS, streams’ /F, reference XObjects); the places actions give them are actions, which no part allows.',
|
|
156
|
+
},
|
|
157
|
+
'PDFX-OPI': {
|
|
158
|
+
text: 'No image or form XObject has OPI comments (/OPI).',
|
|
159
|
+
standards: ALL,
|
|
160
|
+
clauses: { '15930-4': '6.4', '15930-6': '6.4', '15930-7': '6.7' },
|
|
161
|
+
note: 'In the 2003 parts through 6.4: an OPI dictionary’s file specification is one (6.4’s note names them).',
|
|
162
|
+
},
|
|
163
|
+
'PDFX-FILTERS': {
|
|
164
|
+
text: 'No LZWDecode; before X-4, no JBIG2Decode, nor the JPXDecode and Crypt filters PDF 1.4 lacks; in X-4, no Crypt and no filter the PDF Reference doesn’t list.',
|
|
165
|
+
standards: ALL,
|
|
166
|
+
clauses: { '15930-4': '6.1, 6.5', '15930-6': '6.1, 6.5', '15930-7': '6.8' },
|
|
167
|
+
note: 'That DCT, JPX and JBIG2 data follow their own standards needs decoding them, beyond the checker.',
|
|
168
|
+
},
|
|
169
|
+
'PDFX-JPX': {
|
|
170
|
+
text: 'PDF/X-4: JPEG 2000 images are JPX files, not bare codestreams, with 1, 3 or 4 channels, at most one colour specification, never the enumerated colour space 19 (CIEJab), and every channel of one depth: 1, 8 or 16 bits.',
|
|
171
|
+
standards: X4,
|
|
172
|
+
clauses: { '15930-7': '6.27' },
|
|
173
|
+
note: 'That only JPX baseline features are used needs decoding the codestream, and is not checked.',
|
|
174
|
+
},
|
|
175
|
+
'PDFX-COLOUR-SPACE': {
|
|
176
|
+
text: 'PDF/X-1a: print elements use only DeviceCMYK, DeviceGray, Separation and DeviceN (and Indexed and Pattern spaces over them), whose alternates are DeviceCMYK or DeviceGray; no DeviceRGB, ICC-based or CIE colour, and no Default colour spaces.',
|
|
177
|
+
standards: X1A,
|
|
178
|
+
clauses: { '15930-4': '6.2.1, 6.2.3, 6.2.4' },
|
|
179
|
+
note: 'A Default space would make device colour device independent, which X-1a’s print elements are not (6.2.1 and its note).',
|
|
180
|
+
},
|
|
181
|
+
'PDFX-DEVICE-COLOUR': {
|
|
182
|
+
text: 'PDF/X-3 and X-4: a device colour space only where the output intent characterises it (DeviceCMYK under CMYK, DeviceRGB under RGB, DeviceGray under grey or CMYK), or else remapped by a Default colour space in the content’s resources, which X-3 asks to be colorimetric and X-4 holds to these rules itself.',
|
|
183
|
+
standards: X3_X4,
|
|
184
|
+
clauses: { '15930-6': '6.2.3, 6.2.4, 6.2.5, 6.2.7, 6.2.8', '15930-7': '6.4.3.1, 6.4.3.2, 6.4.3.4' },
|
|
185
|
+
},
|
|
186
|
+
'PDFX-SPOT-COLOURS': {
|
|
187
|
+
text: 'PDF/X-4: every spot colorant of a DeviceN space is in its /Colorants; Separation arrays of one name have the same alternate space and tint transform; a DeviceN /Process space is the output intent’s device space; /MixingHints have no /DotGain, one /PrintingOrder throughout and one /Solidities value per ink.',
|
|
188
|
+
standards: X4,
|
|
189
|
+
clauses: { '15930-7': '6.4.3.4' },
|
|
190
|
+
},
|
|
191
|
+
'PDFX-TRANSPARENCY': {
|
|
192
|
+
text: 'Before X-4, no transparency: no soft mask (/SMask other than /None) in a graphics state or image, /CA and /ca 1, blend mode /Normal or /Compatible, and no form XObject that is a transparency group. In X-4, only the PDF Reference’s blend modes, and a page group’s blending space held to the colour rules.',
|
|
193
|
+
standards: ALL,
|
|
194
|
+
clauses: { '15930-4': '6.16', '15930-6': '6.16', '15930-7': '6.20' },
|
|
195
|
+
note: 'Before X-4 a page may still be a transparency group: 6.16 names form XObjects alone.',
|
|
196
|
+
},
|
|
197
|
+
'PDFX-TRANSFER': {
|
|
198
|
+
text: 'Graphics states have no transfer function: before X-4 no /TR or /TR2 at all; in X-4 no /TR, and /TR2 only /Default.',
|
|
199
|
+
standards: ALL,
|
|
200
|
+
clauses: { '15930-4': '6.9', '15930-6': '6.9', '15930-7': '6.13' },
|
|
201
|
+
},
|
|
202
|
+
'PDFX-HALFTONE': {
|
|
203
|
+
text: 'Halftones are of type 1 or 5, without /HalftoneName, with a /TransferFunction only where the PDF Reference requires one (in a type 5 halftone, for a colorant other than the primaries); graphics states have no halftone phase (/HTP).',
|
|
204
|
+
standards: ALL,
|
|
205
|
+
clauses: { '15930-4': '6.9', '15930-6': '6.9', '15930-7': '6.13' },
|
|
206
|
+
note: 'That a halftone suits the printing condition is not checkable.',
|
|
207
|
+
},
|
|
208
|
+
'PDFX-RENDERING-INTENT': {
|
|
209
|
+
text: 'PDF/X-4: rendering intents (graphics states’ /RI, the ri operator, images’ /Intent) are RelativeColorimetric, AbsoluteColorimetric, Perceptual or Saturation.',
|
|
210
|
+
standards: X4,
|
|
211
|
+
clauses: { '15930-7': '6.13, 6.23' },
|
|
212
|
+
},
|
|
213
|
+
'PDFX-POSTSCRIPT': {
|
|
214
|
+
text: 'No PostScript XObjects, no form XObject with /Subtype2 /PS, and no PS operator.',
|
|
215
|
+
standards: ALL,
|
|
216
|
+
clauses: { '15930-4': '6.10', '15930-6': '6.10', '15930-7': '6.14, 6.19' },
|
|
217
|
+
note: 'In X-4 the PS operator is one the PDF Reference 1.6 doesn’t describe (6.19’s note).',
|
|
218
|
+
},
|
|
219
|
+
'PDFX-OPERATORS': {
|
|
220
|
+
text: 'Content streams use only operators the PDF Reference describes, between BX and EX too.',
|
|
221
|
+
standards: ALL,
|
|
222
|
+
clauses: { '15930-4': '6.15', '15930-6': '6.15', '15930-7': '6.19' },
|
|
223
|
+
},
|
|
224
|
+
'PDFX-ANNOTATIONS': {
|
|
225
|
+
text: 'Every annotation’s /Rect but a TrapNet’s or PrinterMark’s lies wholly outside the bleed box (or the trim or art box without one), touching it at most; a PrinterMark’s lies wholly outside the trim or art box.',
|
|
226
|
+
standards: ALL,
|
|
227
|
+
clauses: { '15930-4': '6.13', '15930-6': '6.13', '15930-7': '6.17' },
|
|
228
|
+
},
|
|
229
|
+
'PDFX-ACTIONS': {
|
|
230
|
+
text: 'No actions or JavaScript: no /OpenAction action, no additional actions (/AA), no /A on annotations, form fields or outline items, no action dictionary, and no /JavaScript name tree.',
|
|
231
|
+
standards: ALL,
|
|
232
|
+
clauses: { '15930-4': '6.14', '15930-6': '6.14', '15930-7': '6.2, 6.18' },
|
|
233
|
+
},
|
|
234
|
+
'PDFX-ALTERNATES': {
|
|
235
|
+
text: 'No image has an alternate (in /Alternates) with /DefaultForPrinting true.',
|
|
236
|
+
standards: ALL,
|
|
237
|
+
clauses: { '15930-4': '6.12', '15930-6': '6.12', '15930-7': '6.16' },
|
|
238
|
+
note: 'That an image’s alternates show the same image can’t be checked.',
|
|
239
|
+
},
|
|
240
|
+
'PDFX-VIEW-AREAS': {
|
|
241
|
+
text: 'The viewer preferences’ /ViewArea, /ViewClip, /PrintArea and /PrintClip are /MediaBox or /BleedBox: before X-4, when a page has a bleed box; in X-4 always, /BleedBox only if every page has one.',
|
|
242
|
+
standards: ALL,
|
|
243
|
+
clauses: { '15930-4': '6.17', '15930-6': '6.17', '15930-7': '6.21' },
|
|
244
|
+
note: 'Before X-4, “if BleedBox is present” is read as on any page: the preferences are the document’s.',
|
|
245
|
+
},
|
|
246
|
+
'PDFX-OPTIONAL-CONTENT': {
|
|
247
|
+
text: 'Before X-4, no optional content (/OCProperties, PDF 1.5). In X-4, each optional content configuration (/D and those in /Configs) has a /Name no other has and no /AS, and an /Order that is empty or lists every group.',
|
|
248
|
+
standards: ALL,
|
|
249
|
+
clauses: { '15930-4': '6.1', '15930-6': '6.1', '15930-7': '6.24' },
|
|
250
|
+
},
|
|
251
|
+
'PDFX-ALTERNATE-PRESENTATIONS': {
|
|
252
|
+
text: 'PDF/X-4: no /AlternatePresentations in the names dictionary, and no /PresSteps on a page.',
|
|
253
|
+
standards: X4,
|
|
254
|
+
clauses: { '15930-7': '6.22' },
|
|
255
|
+
},
|
|
256
|
+
'PDFX-XFA': {
|
|
257
|
+
text: 'PDF/X-4: the interactive form (/AcroForm) has no /XFA.',
|
|
258
|
+
standards: X4,
|
|
259
|
+
clauses: { '15930-7': '6.26' },
|
|
260
|
+
},
|
|
261
|
+
'PDFX-LIMITS': {
|
|
262
|
+
text: 'PDF/X-4: within the PDF Reference’s architectural limits (Table C.1): integers within −2³¹ to 2³¹ − 1, reals within ±3.403 × 10³⁸ and none nearer 0 than ±1.175 × 10⁻³⁸, strings in content streams of at most 32,767 bytes, names of at most 127 bytes, at most 8,388,607 indirect objects, q nested at most 28 deep, and DeviceN spaces of at most 32 colorants.',
|
|
263
|
+
standards: X4,
|
|
264
|
+
clauses: { '15930-7': '6.25' },
|
|
265
|
+
note: 'CIDs above 65,535 would need reading CMaps; the reals’ five significant digits are a precision, not a limit a file breaks.',
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
/** The part of ISO 15930 that sets each standard’s rules. */
|
|
269
|
+
export const ISO_PART = {
|
|
270
|
+
'PDF/X-1a:2001': '15930-4',
|
|
271
|
+
'PDF/X-1a:2003': '15930-4',
|
|
272
|
+
'PDF/X-3:2002': '15930-6',
|
|
273
|
+
'PDF/X-3:2003': '15930-6',
|
|
274
|
+
'PDF/X-4': '15930-7',
|
|
275
|
+
};
|
|
276
|
+
/** A standard named in any case, as on the command line: `pdf/x-4`, `PDF/X-1a:2003`. */
|
|
277
|
+
export function pdfXStandard(name) {
|
|
278
|
+
return PDF_X_STANDARDS.find((s) => s.toLowerCase() === name.toLowerCase());
|
|
279
|
+
}
|
|
280
|
+
/** Checks a PDF’s bytes against the rules of a PDF/X standard ({@link PDF_X_RULES}). */
|
|
281
|
+
export function preflightPdfX(bytes, options = {}) {
|
|
282
|
+
const pdf = new PdfFile(bytes);
|
|
283
|
+
return new Checker(pdf, options.standard ?? identify(pdf) ?? 'PDF/X-4', options).run();
|
|
284
|
+
}
|
|
285
|
+
/** The standard a file says it is: from XMP, as PDF/X-4 has it, else from the Info dictionary. */
|
|
286
|
+
function identify(pdf) {
|
|
287
|
+
const meta = pdf.stream(pdf.catalog?.get('Metadata'));
|
|
288
|
+
if (meta) {
|
|
289
|
+
try {
|
|
290
|
+
const named = PDF_X_STANDARDS.find((s) => s === xmpProperty(decodeXmp(pdf.decode(meta)), XMP_NS.pdfxid, 'GTS_PDFXVersion'));
|
|
291
|
+
if (named)
|
|
292
|
+
return named;
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
// Unreadable XMP: the Info dictionary may still say.
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const text = (key) => {
|
|
299
|
+
const v = pdf.resolve(pdf.info?.get(key));
|
|
300
|
+
return v instanceof PdfString ? v.text : undefined;
|
|
301
|
+
};
|
|
302
|
+
const version = text('GTS_PDFXVersion');
|
|
303
|
+
if (version === 'PDF/X-1:2001' && text('GTS_PDFXConformance') === 'PDF/X-1a:2001')
|
|
304
|
+
return 'PDF/X-1a:2001';
|
|
305
|
+
return PDF_X_STANDARDS.find((s) => s === version);
|
|
306
|
+
}
|
|
307
|
+
/** Device colour space names, with inline images’ abbreviations. */
|
|
308
|
+
const DEVICE = {
|
|
309
|
+
DeviceGray: 'DeviceGray',
|
|
310
|
+
G: 'DeviceGray',
|
|
311
|
+
DeviceRGB: 'DeviceRGB',
|
|
312
|
+
RGB: 'DeviceRGB',
|
|
313
|
+
DeviceCMYK: 'DeviceCMYK',
|
|
314
|
+
CMYK: 'DeviceCMYK',
|
|
315
|
+
};
|
|
316
|
+
/** The device colour space each output intent’s colour space is. */
|
|
317
|
+
const INTENT_DEVICE = { GRAY: 'DeviceGray', RGB: 'DeviceRGB', CMYK: 'DeviceCMYK' };
|
|
318
|
+
/** Colour space families that are device independent: ICC-based and CIE-based. */
|
|
319
|
+
const INDEPENDENT = new Set(['ICCBased', 'CalGray', 'CalRGB', 'Lab']);
|
|
320
|
+
/** The process colorants of DeviceN, which need no /Colorants entry. */
|
|
321
|
+
const PROCESS = new Set(['Cyan', 'Magenta', 'Yellow', 'Black', 'None']);
|
|
322
|
+
/** A type 5 halftone’s components that are primaries (or its default), which take no /TransferFunction. */
|
|
323
|
+
const PRIMARY = new Set(['Cyan', 'Magenta', 'Yellow', 'Black', 'Red', 'Green', 'Blue', 'Gray', 'Default']);
|
|
324
|
+
/** The PDF Reference’s content stream operators (its Table A.1), PS aside, which PDFX-POSTSCRIPT reports. */
|
|
325
|
+
const OPERATORS = new Set(('b B b* B* BDC BI BMC BT BX c cm CS cs d d0 d1 Do DP EI EMC ET EX f F f* G g gs h i ID j J K k l m M MP n q Q re RG rg ri s S SC sc SCN scn sh T* ' +
|
|
326
|
+
'Tc Td TD Tf TJ Tj TL Tm Tr Ts Tw Tz v w W W* y \' "').split(' '));
|
|
327
|
+
/** The PDF Reference’s standard filters (its Table 3.5), with inline images’ abbreviations. */
|
|
328
|
+
const FILTERS = new Set([
|
|
329
|
+
'ASCIIHexDecode', 'ASCII85Decode', 'LZWDecode', 'FlateDecode', 'RunLengthDecode', 'CCITTFaxDecode', 'JBIG2Decode', 'DCTDecode', 'JPXDecode', 'Crypt',
|
|
330
|
+
'AHx', 'A85', 'LZW', 'Fl', 'RL', 'CCF', 'DCT',
|
|
331
|
+
]);
|
|
332
|
+
/** The PDF Reference’s blend modes (PDF/X-4, 6.20). */
|
|
333
|
+
const BLEND_MODES = new Set([
|
|
334
|
+
'Normal', 'Compatible', 'Multiply', 'Screen', 'Overlay', 'Darken', 'Lighten', 'ColorDodge', 'ColorBurn', 'HardLight', 'SoftLight',
|
|
335
|
+
'Difference', 'Exclusion', 'Hue', 'Saturation', 'Color', 'Luminosity',
|
|
336
|
+
]);
|
|
337
|
+
/** The rendering intents PDF/X-4 allows (6.23). */
|
|
338
|
+
const INTENTS = new Set(['RelativeColorimetric', 'AbsoluteColorimetric', 'Perceptual', 'Saturation']);
|
|
339
|
+
/** Operators that show text, with the index of their string operand (TJ’s is an array). */
|
|
340
|
+
const SHOW = new Set(['Tj', 'TJ', '\'', '"']);
|
|
341
|
+
const INITIAL = { font: undefined, render: 0, fill: 'DeviceGray', stroke: 'DeviceGray', op: false, OP: false, opm: 0 };
|
|
342
|
+
/** Rectangles may be written with rounding: a box this close to its container is within it. */
|
|
343
|
+
const EPSILON = 0.01;
|
|
344
|
+
class Checker {
|
|
345
|
+
pdf;
|
|
346
|
+
standard;
|
|
347
|
+
options;
|
|
348
|
+
report;
|
|
349
|
+
reported = new Set();
|
|
350
|
+
/** Objects already checked, so that what pages share is checked once and loops end. */
|
|
351
|
+
seen = new Set();
|
|
352
|
+
intent;
|
|
353
|
+
/** The output intent’s profile, to tell it apart when used as a colour space. */
|
|
354
|
+
intentProfile;
|
|
355
|
+
intentProfileRef;
|
|
356
|
+
/** An X-3 output intent without a profile: allowed unless ICC-based or CIE colour is used. */
|
|
357
|
+
profileMissing = false;
|
|
358
|
+
independentColour = false;
|
|
359
|
+
/** Each Separation name’s alternate space and tint transform, as first seen (X-4). */
|
|
360
|
+
separations = new Map();
|
|
361
|
+
/** DeviceN mixing hints’ printing order, and each ink’s solidity, as first seen (X-4). */
|
|
362
|
+
printingOrder;
|
|
363
|
+
solidities = new Map();
|
|
364
|
+
/** How the content streams were written (X-4’s limits). */
|
|
365
|
+
lexical = newLexical();
|
|
366
|
+
trapNet = false;
|
|
367
|
+
x1a;
|
|
368
|
+
x4;
|
|
369
|
+
constructor(pdf, standard, options) {
|
|
370
|
+
this.pdf = pdf;
|
|
371
|
+
this.standard = standard;
|
|
372
|
+
this.options = options;
|
|
373
|
+
this.report = { standard, violations: [], notices: [] };
|
|
374
|
+
this.x1a = X1A.includes(standard);
|
|
375
|
+
this.x4 = standard === 'PDF/X-4';
|
|
376
|
+
}
|
|
377
|
+
run() {
|
|
378
|
+
const catalog = this.pdf.catalog;
|
|
379
|
+
if (!catalog)
|
|
380
|
+
this.violation('PDFX-SYNTAX', 'the file has no document catalog, so nothing else could be checked');
|
|
381
|
+
else {
|
|
382
|
+
const { xrefStream, objectStreams } = this.pdf.compression;
|
|
383
|
+
if (xrefStream)
|
|
384
|
+
this.violation('PDFX-COMPRESSION', `the file has a cross-reference stream, which ${this.standard} doesn’t allow`);
|
|
385
|
+
if (objectStreams)
|
|
386
|
+
this.violation('PDFX-COMPRESSION', `the file has object streams, which ${this.standard} doesn’t allow`);
|
|
387
|
+
this.trailer(catalog);
|
|
388
|
+
this.identification();
|
|
389
|
+
this.outputIntent(catalog);
|
|
390
|
+
const pages = this.pdf.pages();
|
|
391
|
+
this.documentLevel(catalog, pages);
|
|
392
|
+
if (!pages.length)
|
|
393
|
+
this.violation('PDFX-SYNTAX', 'the document has no pages');
|
|
394
|
+
if (this.intent === undefined && pages.length && !this.x1a)
|
|
395
|
+
this.notice('PDFX-DEVICE-COLOUR', 'without a usable output intent, device colours were not checked');
|
|
396
|
+
for (const page of pages) {
|
|
397
|
+
this.boxes(page);
|
|
398
|
+
this.page(page);
|
|
399
|
+
}
|
|
400
|
+
if (this.profileMissing && this.independentColour)
|
|
401
|
+
this.violation('PDFX-OUTPUT-PROFILE', 'the file uses ICC-based or CIE colour, so its output intent must embed a /DestOutputProfile');
|
|
402
|
+
// After the pages, which find any TrapNet annotation.
|
|
403
|
+
if (this.x4)
|
|
404
|
+
this.xmpMetadata(catalog);
|
|
405
|
+
else
|
|
406
|
+
this.infoMetadata();
|
|
407
|
+
this.everyObject();
|
|
408
|
+
if (this.x4)
|
|
409
|
+
this.limits();
|
|
410
|
+
}
|
|
411
|
+
// Last, as reading objects for the other rules finds problems too.
|
|
412
|
+
for (const p of this.pdf.problems)
|
|
413
|
+
this.violation('PDFX-SYNTAX', p);
|
|
414
|
+
return this.report;
|
|
415
|
+
}
|
|
416
|
+
violation(rule, message, page) {
|
|
417
|
+
// A rule another standard has is not this one’s.
|
|
418
|
+
if (!PDF_X_RULES[rule].standards.includes(this.standard))
|
|
419
|
+
return;
|
|
420
|
+
this.issue(this.report.violations, rule, message, page);
|
|
421
|
+
}
|
|
422
|
+
notice(rule, message, page) {
|
|
423
|
+
if (!PDF_X_RULES[rule].standards.includes(this.standard))
|
|
424
|
+
return;
|
|
425
|
+
this.issue(this.report.notices, rule, message, page);
|
|
426
|
+
}
|
|
427
|
+
issue(list, rule, message, page) {
|
|
428
|
+
const key = `${list === this.report.violations}\n${rule}\n${message}\n${page}`;
|
|
429
|
+
if (this.reported.has(key))
|
|
430
|
+
return;
|
|
431
|
+
this.reported.add(key);
|
|
432
|
+
list.push(page === undefined ? { rule, message } : { rule, message, page });
|
|
433
|
+
}
|
|
434
|
+
trailer(catalog) {
|
|
435
|
+
const t = this.pdf.trailer;
|
|
436
|
+
if (t.has('Encrypt'))
|
|
437
|
+
this.violation('PDFX-ENCRYPT', 'the file is encrypted (the trailer has /Encrypt)');
|
|
438
|
+
const id = this.pdf.array(t.get('ID'));
|
|
439
|
+
if (id?.length !== 2 || !id.every((s) => this.pdf.resolve(s) instanceof PdfString))
|
|
440
|
+
this.violation('PDFX-TRAILER-ID', id ? 'the trailer’s /ID is not an array of two strings' : 'the trailer has no /ID');
|
|
441
|
+
for (const key of this.x4 ? (this.pdf.dict(catalog.get('Perms'))?.keys() ?? []) : [])
|
|
442
|
+
if (key !== 'UR' && key !== 'UR3')
|
|
443
|
+
this.violation('PDFX-ENCRYPT', `the permissions dictionary has /${key}, which controls access`);
|
|
444
|
+
}
|
|
445
|
+
/** An Info entry as text, `null` if absent, and `undefined` if not a string. */
|
|
446
|
+
infoText(key) {
|
|
447
|
+
const v = this.pdf.resolve(this.pdf.info?.get(key));
|
|
448
|
+
return v === null ? null : v instanceof PdfString ? v.text : undefined;
|
|
449
|
+
}
|
|
450
|
+
/** Info /GTS_PDFXVersion (and /GTS_PDFXConformance) as each standard writes it. */
|
|
451
|
+
identification() {
|
|
452
|
+
const version = this.infoText('GTS_PDFXVersion');
|
|
453
|
+
const shown = (v) => (v === null ? 'missing' : v === undefined ? 'not a string' : `(${v})`);
|
|
454
|
+
if (this.x4) {
|
|
455
|
+
if (version !== null && version !== 'PDF/X-4')
|
|
456
|
+
this.violation('PDFX-VERSION-ID', `Info /GTS_PDFXVersion is ${shown(version)}, not (PDF/X-4)`);
|
|
457
|
+
const raw = this.pdf.resolve(this.pdf.info?.get('GTS_PDFXVersion'));
|
|
458
|
+
if (raw instanceof PdfString && ((raw.bytes[0] === 0xfe && raw.bytes[1] === 0xff) || (raw.bytes[0] === 0xef && raw.bytes[1] === 0xbb)))
|
|
459
|
+
this.violation('PDFX-VERSION-ID', 'Info /GTS_PDFXVersion is in Unicode, not PDFDocEncoding');
|
|
460
|
+
if (this.pdf.info?.has('GTS_PDFXConformance'))
|
|
461
|
+
this.violation('PDFX-VERSION-ID', 'Info has /GTS_PDFXConformance, which PDF/X-4 doesn’t use');
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
const wanted = this.standard === 'PDF/X-1a:2001' ? 'PDF/X-1:2001' : this.standard;
|
|
465
|
+
if (version !== wanted)
|
|
466
|
+
this.violation('PDFX-VERSION-ID', `Info /GTS_PDFXVersion is ${shown(version)}, not (${wanted})`);
|
|
467
|
+
if (this.standard === 'PDF/X-1a:2001') {
|
|
468
|
+
const conformance = this.infoText('GTS_PDFXConformance');
|
|
469
|
+
if (conformance !== 'PDF/X-1a:2001')
|
|
470
|
+
this.violation('PDFX-VERSION-ID', `Info /GTS_PDFXConformance is ${shown(conformance)}, not (PDF/X-1a:2001)`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/** Before PDF/X-4, the metadata is the Info dictionary’s. */
|
|
474
|
+
infoMetadata() {
|
|
475
|
+
if (!this.infoText('Title'))
|
|
476
|
+
this.violation('PDFX-TITLE', 'Info has no /Title, or an empty one');
|
|
477
|
+
for (const key of ['CreationDate', 'ModDate'])
|
|
478
|
+
if (!this.infoText(key))
|
|
479
|
+
this.violation('PDFX-DATES', `Info has no /${key}, or an empty one`);
|
|
480
|
+
const trapped = this.pdf.resolve(this.pdf.info?.get('Trapped'));
|
|
481
|
+
if (trapped !== 'True' && trapped !== 'False')
|
|
482
|
+
this.violation('PDFX-TRAPPED', trapped === null ? 'Info has no /Trapped' : `Info /Trapped is ${describe(trapped)}, not /True or /False`);
|
|
483
|
+
else if (this.trapNet && trapped !== 'True')
|
|
484
|
+
this.violation('PDFX-TRAPPED', 'a page has a TrapNet annotation, but Info /Trapped is not /True');
|
|
485
|
+
}
|
|
486
|
+
/** PDF/X-4 carries its identification and metadata in XMP; Info, if present, must agree. */
|
|
487
|
+
xmpMetadata(catalog) {
|
|
488
|
+
const infoTrapped = this.pdf.resolve(this.pdf.info?.get('Trapped'));
|
|
489
|
+
if (infoTrapped !== null && infoTrapped !== 'True' && infoTrapped !== 'False')
|
|
490
|
+
this.violation('PDFX-TRAPPED', `Info /Trapped is ${describe(infoTrapped)}, not /True or /False`);
|
|
491
|
+
const meta = this.pdf.stream(catalog.get('Metadata'));
|
|
492
|
+
if (!meta)
|
|
493
|
+
return this.violation('PDFX-METADATA', 'the catalog has no XMP /Metadata stream');
|
|
494
|
+
if (meta.dict.has('Filter'))
|
|
495
|
+
this.violation('PDFX-METADATA', 'the XMP metadata stream has a /Filter');
|
|
496
|
+
let xmp;
|
|
497
|
+
try {
|
|
498
|
+
xmp = decodeXmp(this.pdf.decode(meta));
|
|
499
|
+
}
|
|
500
|
+
catch (e) {
|
|
501
|
+
if (!(e instanceof PdfFilterError))
|
|
502
|
+
throw e;
|
|
503
|
+
return this.notice('PDFX-METADATA', `the XMP metadata could not be read (${e.message}), so it was not checked`);
|
|
504
|
+
}
|
|
505
|
+
for (const p of xmpProblems(xmp))
|
|
506
|
+
this.violation('PDFX-METADATA', p);
|
|
507
|
+
const version = xmpProperty(xmp, XMP_NS.pdfxid, 'GTS_PDFXVersion');
|
|
508
|
+
if (version !== 'PDF/X-4')
|
|
509
|
+
this.violation('PDFX-VERSION-ID', version === undefined ? 'XMP has no pdfxid:GTS_PDFXVersion' : `XMP pdfxid:GTS_PDFXVersion is “${version}”, not “PDF/X-4”`);
|
|
510
|
+
const prefix = [...xmp.matchAll(/xmlns:([\w.-]+)\s*=\s*(["'])http:\/\/www\.npes\.org\/pdfx\/ns\/id\/\2/g)].map((m) => m[1]);
|
|
511
|
+
for (const p of prefix)
|
|
512
|
+
for (const m of xmp.matchAll(new RegExp(`[<\\s]${p}:([\\w.-]+)`, 'g')))
|
|
513
|
+
if (m[1] !== 'GTS_PDFXVersion')
|
|
514
|
+
this.violation('PDFX-VERSION-ID', `XMP has pdfxid:${m[1]}, a pdfxid property other than GTS_PDFXVersion`);
|
|
515
|
+
if (!xmpProperty(xmp, XMP_NS.dc, 'title'))
|
|
516
|
+
this.violation('PDFX-TITLE', 'XMP has no dc:title, or an empty one');
|
|
517
|
+
for (const date of ['CreateDate', 'ModifyDate', 'MetadataDate'])
|
|
518
|
+
if (!xmpProperty(xmp, XMP_NS.xmp, date))
|
|
519
|
+
this.violation('PDFX-DATES', `XMP has no xmp:${date}, or an empty one`);
|
|
520
|
+
for (const id of ['DocumentID', 'VersionID', 'RenditionClass'])
|
|
521
|
+
if (!xmpProperty(xmp, XMP_NS.xmpMM, id))
|
|
522
|
+
this.violation('PDFX-XMP-IDS', `XMP has no xmpMM:${id}`);
|
|
523
|
+
const trapped = xmpProperty(xmp, XMP_NS.pdf, 'Trapped');
|
|
524
|
+
if (trapped !== 'True' && trapped !== 'False')
|
|
525
|
+
this.violation('PDFX-TRAPPED', trapped === undefined ? 'XMP has no pdf:Trapped' : `XMP pdf:Trapped is “${trapped}”, not True or False`);
|
|
526
|
+
else if (this.trapNet && trapped !== 'True')
|
|
527
|
+
this.violation('PDFX-TRAPPED', 'a page has a TrapNet annotation, but XMP pdf:Trapped is not True');
|
|
528
|
+
else if (infoTrapped !== null && infoTrapped !== trapped)
|
|
529
|
+
this.violation('PDFX-TRAPPED', `XMP pdf:Trapped is “${trapped}”, but Info /Trapped is ${describe(infoTrapped)}`);
|
|
530
|
+
this.infoInXmp(xmp);
|
|
531
|
+
}
|
|
532
|
+
/** PDF/X-4: what the Info dictionary says, the XMP says the same (6.10.2, Table 3). */
|
|
533
|
+
infoInXmp(xmp) {
|
|
534
|
+
const info = this.pdf.info;
|
|
535
|
+
if (!info)
|
|
536
|
+
return;
|
|
537
|
+
// Trapped is PDFX-TRAPPED’s.
|
|
538
|
+
const crosswalk = [
|
|
539
|
+
['Title', XMP_NS.dc, 'title', 'text'],
|
|
540
|
+
['Author', XMP_NS.dc, 'creator', 'text'],
|
|
541
|
+
['Subject', XMP_NS.dc, 'description', 'text'],
|
|
542
|
+
['Keywords', XMP_NS.pdf, 'Keywords', 'text'],
|
|
543
|
+
['Creator', XMP_NS.xmp, 'CreatorTool', 'text'],
|
|
544
|
+
['Producer', XMP_NS.pdf, 'Producer', 'text'],
|
|
545
|
+
['CreationDate', XMP_NS.xmp, 'CreateDate', 'date'],
|
|
546
|
+
['ModDate', XMP_NS.xmp, 'ModifyDate', 'date'],
|
|
547
|
+
['GTS_PDFXVersion', XMP_NS.pdfxid, 'GTS_PDFXVersion', 'text'],
|
|
548
|
+
];
|
|
549
|
+
const prefixes = { [XMP_NS.dc]: 'dc', [XMP_NS.pdf]: 'pdf', [XMP_NS.xmp]: 'xmp', [XMP_NS.pdfxid]: 'pdfxid' };
|
|
550
|
+
for (const [key, ns, name, type] of crosswalk) {
|
|
551
|
+
const v = this.pdf.resolve(info.get(key));
|
|
552
|
+
if (v === null)
|
|
553
|
+
continue;
|
|
554
|
+
const value = v instanceof PdfString ? v.text : typeof v === 'string' ? v : undefined;
|
|
555
|
+
const property = `${prefixes[ns]}:${name}`;
|
|
556
|
+
const x = xmpProperty(xmp, ns, name);
|
|
557
|
+
if (value === undefined)
|
|
558
|
+
continue;
|
|
559
|
+
if (x === undefined) {
|
|
560
|
+
this.violation('PDFX-INFO-XMP', `Info has /${key}, but XMP has no ${property}`);
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
563
|
+
if (key === 'Author' && xmpItems(xmp, ns, name) > 1)
|
|
564
|
+
this.violation('PDFX-INFO-XMP', 'XMP dc:creator has more than one item, and Info has /Author');
|
|
565
|
+
const same = type === 'date' ? sameDate(value, x) : value === x;
|
|
566
|
+
if (!same)
|
|
567
|
+
this.violation('PDFX-INFO-XMP', `Info /${key} is (${value}), but XMP ${property} is “${x}”`);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
outputIntent(catalog) {
|
|
571
|
+
const intents = (this.pdf.array(catalog.get('OutputIntents')) ?? [])
|
|
572
|
+
.map((o) => this.pdf.dict(o))
|
|
573
|
+
.filter((d) => d && this.pdf.resolve(d.get('S')) === 'GTS_PDFX');
|
|
574
|
+
if (intents.length > 1)
|
|
575
|
+
this.violation('PDFX-OUTPUT-INTENT', `the catalog has ${intents.length} GTS_PDFX output intents; PDF/X allows one`);
|
|
576
|
+
const oi = intents[0];
|
|
577
|
+
if (!oi)
|
|
578
|
+
return this.violation('PDFX-OUTPUT-INTENT', 'the catalog has no GTS_PDFX output intent');
|
|
579
|
+
const id = this.pdf.resolve(oi.get('OutputConditionIdentifier'));
|
|
580
|
+
if (!(id instanceof PdfString) || !id.bytes.length)
|
|
581
|
+
this.violation('PDFX-OUTPUT-INTENT', 'the output intent has no /OutputConditionIdentifier string');
|
|
582
|
+
if (this.x4 && oi.has('DestOutputProfileRef'))
|
|
583
|
+
this.violation('PDFX-OUTPUT-PROFILE', 'the output intent refers to an external profile (/DestOutputProfileRef, PDF/X-4p’s)');
|
|
584
|
+
const profile = this.pdf.stream(oi.get('DestOutputProfile'));
|
|
585
|
+
if (!profile) {
|
|
586
|
+
// The ICC’s registry’s conditions need no profile before X-4.
|
|
587
|
+
const registry = this.pdf.resolve(oi.get('RegistryName'));
|
|
588
|
+
const registered = id instanceof PdfString && id.text !== 'Custom' && registry instanceof PdfString && /^http:\/\/www\.color\.org\/?$/.test(registry.text);
|
|
589
|
+
if (this.x4 || !registered)
|
|
590
|
+
return this.violation('PDFX-OUTPUT-PROFILE', 'the output intent has no embedded /DestOutputProfile');
|
|
591
|
+
// Then X-1a is CMYK by definition, and X-3 needs the profile only for device-independent colour.
|
|
592
|
+
if (this.x1a)
|
|
593
|
+
this.intent = 'CMYK';
|
|
594
|
+
else
|
|
595
|
+
this.profileMissing = true;
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
let icc;
|
|
599
|
+
try {
|
|
600
|
+
icc = this.pdf.decode(profile);
|
|
601
|
+
}
|
|
602
|
+
catch (e) {
|
|
603
|
+
if (!(e instanceof PdfFilterError))
|
|
604
|
+
throw e;
|
|
605
|
+
return this.notice('PDFX-OUTPUT-PROFILE', `the output profile could not be read (${e.message}), so it was not checked`);
|
|
606
|
+
}
|
|
607
|
+
const ascii = (from) => String.fromCharCode(...icc.subarray(from, from + 4));
|
|
608
|
+
if (icc.length < 128 || ascii(36) !== 'acsp')
|
|
609
|
+
return this.violation('PDFX-OUTPUT-PROFILE', 'the /DestOutputProfile is not an ICC profile');
|
|
610
|
+
const cls = ascii(12);
|
|
611
|
+
if (cls !== 'prtr')
|
|
612
|
+
this.violation('PDFX-OUTPUT-PROFILE', `the output profile’s device class is “${cls}”, not an output device’s “prtr”`);
|
|
613
|
+
const space = ascii(16).trim();
|
|
614
|
+
this.iccVersion(icc, 'the output profile');
|
|
615
|
+
this.intentProfile = icc;
|
|
616
|
+
this.intentProfileRef = oi.get('DestOutputProfile');
|
|
617
|
+
if (space !== 'GRAY' && space !== 'RGB' && space !== 'CMYK') {
|
|
618
|
+
if (this.x4)
|
|
619
|
+
this.violation('PDFX-OUTPUT-PROFILE', `the output profile’s colour space is “${space}”, not grey, RGB or CMYK`);
|
|
620
|
+
else if (this.x1a)
|
|
621
|
+
this.violation('PDFX-OUTPUT-PROFILE', `the output profile’s colour space is “${space}”; PDF/X-1a’s is CMYK`);
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
if (this.x1a && space !== 'CMYK')
|
|
625
|
+
this.violation('PDFX-OUTPUT-PROFILE', `the output profile’s colour space is ${space}; PDF/X-1a’s is CMYK`);
|
|
626
|
+
this.intent = space;
|
|
627
|
+
const wanted = this.options.outputColourSpace;
|
|
628
|
+
if (wanted && space !== wanted)
|
|
629
|
+
this.violation('PDFX-OUTPUT-PROFILE', `the output profile’s colour space is ${space}, not ${wanted}`);
|
|
630
|
+
}
|
|
631
|
+
/** What the catalog itself may not have: actions, JavaScript, embedded files, optional content, view areas, forms, presentations. */
|
|
632
|
+
documentLevel(catalog, pages) {
|
|
633
|
+
if (this.isAction(catalog.get('OpenAction')))
|
|
634
|
+
this.violation('PDFX-ACTIONS', 'the catalog has an /OpenAction action');
|
|
635
|
+
if (catalog.has('AA'))
|
|
636
|
+
this.violation('PDFX-ACTIONS', 'the catalog has additional actions (/AA)');
|
|
637
|
+
const names = this.pdf.dict(catalog.get('Names'));
|
|
638
|
+
if (names?.has('JavaScript'))
|
|
639
|
+
this.violation('PDFX-ACTIONS', 'the document has JavaScript (a /JavaScript name tree)');
|
|
640
|
+
if (names?.has('EmbeddedFiles') && !this.x4)
|
|
641
|
+
this.violation('PDFX-FILES', 'the document has embedded files (an /EmbeddedFiles name tree)');
|
|
642
|
+
if (names?.has('AlternatePresentations'))
|
|
643
|
+
this.violation('PDFX-ALTERNATE-PRESENTATIONS', 'the names dictionary has /AlternatePresentations');
|
|
644
|
+
this.optionalContent(catalog);
|
|
645
|
+
const boxes = pages.map((p) => p.dict.has('BleedBox'));
|
|
646
|
+
const bleedAllowed = this.x4 ? boxes.every(Boolean) : true;
|
|
647
|
+
const restricted = this.x4 || boxes.some(Boolean);
|
|
648
|
+
const prefs = this.pdf.dict(catalog.get('ViewerPreferences'));
|
|
649
|
+
for (const key of ['ViewArea', 'ViewClip', 'PrintArea', 'PrintClip']) {
|
|
650
|
+
const v = this.pdf.resolve(prefs?.get(key));
|
|
651
|
+
if (v === null || !restricted || v === 'MediaBox' || (v === 'BleedBox' && bleedAllowed))
|
|
652
|
+
continue;
|
|
653
|
+
this.violation('PDFX-VIEW-AREAS', v === 'BleedBox'
|
|
654
|
+
? `the viewer preferences’ /${key} is /BleedBox, but not every page has a bleed box`
|
|
655
|
+
: `the viewer preferences’ /${key} is ${describe(v)}, not /MediaBox or /BleedBox`);
|
|
656
|
+
}
|
|
657
|
+
// Outline items may go to a destination, but not by an action.
|
|
658
|
+
const seen = new Set();
|
|
659
|
+
const walk = (obj) => {
|
|
660
|
+
for (let item = this.pdf.dict(obj); item && !seen.has(item); item = this.pdf.dict(item.get('Next'))) {
|
|
661
|
+
seen.add(item);
|
|
662
|
+
if (item.has('A'))
|
|
663
|
+
this.violation('PDFX-ACTIONS', 'an outline item has an action (/A)');
|
|
664
|
+
walk(item.get('First'));
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
walk(this.pdf.dict(catalog.get('Outlines'))?.get('First'));
|
|
668
|
+
const form = this.pdf.dict(catalog.get('AcroForm'));
|
|
669
|
+
if (form?.has('XFA'))
|
|
670
|
+
this.violation('PDFX-XFA', 'the interactive form has /XFA');
|
|
671
|
+
// Form fields not merged with their widgets carry actions of their own.
|
|
672
|
+
const fields = new Set();
|
|
673
|
+
const field = (obj) => {
|
|
674
|
+
const f = this.pdf.dict(obj);
|
|
675
|
+
if (!f || fields.has(f))
|
|
676
|
+
return;
|
|
677
|
+
fields.add(f);
|
|
678
|
+
if (f.has('AA'))
|
|
679
|
+
this.violation('PDFX-ACTIONS', 'a form field has additional actions (/AA)');
|
|
680
|
+
if (f.has('A'))
|
|
681
|
+
this.violation('PDFX-ACTIONS', 'a form field has an action (/A)');
|
|
682
|
+
for (const kid of this.pdf.array(f.get('Kids')) ?? [])
|
|
683
|
+
field(kid);
|
|
684
|
+
};
|
|
685
|
+
for (const f of this.pdf.array(form?.get('Fields')) ?? [])
|
|
686
|
+
field(f);
|
|
687
|
+
}
|
|
688
|
+
/** Before X-4 none; in X-4, configurations that name their variants (6.24). */
|
|
689
|
+
optionalContent(catalog) {
|
|
690
|
+
const oc = this.pdf.dict(catalog.get('OCProperties'));
|
|
691
|
+
if (!oc)
|
|
692
|
+
return;
|
|
693
|
+
if (!this.x4)
|
|
694
|
+
return this.violation('PDFX-OPTIONAL-CONTENT', `the document has optional content, which ${this.standard} doesn’t allow`);
|
|
695
|
+
const groups = new Set((this.pdf.array(oc.get('OCGs')) ?? []).map((g) => this.pdf.resolve(g)));
|
|
696
|
+
const configs = [oc.get('D'), ...(this.pdf.array(oc.get('Configs')) ?? [])].map((c) => this.pdf.dict(c));
|
|
697
|
+
const names = new Set();
|
|
698
|
+
for (const [i, config] of configs.entries()) {
|
|
699
|
+
const which = i === 0 ? 'the default optional content configuration (/D)' : `optional content configuration ${i} in /Configs`;
|
|
700
|
+
if (!config) {
|
|
701
|
+
if (i === 0)
|
|
702
|
+
this.violation('PDFX-OPTIONAL-CONTENT', 'the optional content properties have no default configuration (/D)');
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
const name = this.pdf.resolve(config.get('Name'));
|
|
706
|
+
if (!(name instanceof PdfString))
|
|
707
|
+
this.violation('PDFX-OPTIONAL-CONTENT', `${which} has no /Name`);
|
|
708
|
+
else if (names.has(name.text))
|
|
709
|
+
this.violation('PDFX-OPTIONAL-CONTENT', `${which} has the /Name (${name.text}) another has`);
|
|
710
|
+
else
|
|
711
|
+
names.add(name.text);
|
|
712
|
+
if (config.has('AS'))
|
|
713
|
+
this.violation('PDFX-OPTIONAL-CONTENT', `${which} has /AS`);
|
|
714
|
+
const order = this.pdf.array(config.get('Order'));
|
|
715
|
+
if (order?.length) {
|
|
716
|
+
const listed = new Set();
|
|
717
|
+
const walk = (a) => {
|
|
718
|
+
for (const o of a) {
|
|
719
|
+
const v = this.pdf.resolve(o);
|
|
720
|
+
if (Array.isArray(v))
|
|
721
|
+
walk(v);
|
|
722
|
+
else
|
|
723
|
+
listed.add(v);
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
walk(order);
|
|
727
|
+
if ([...groups].some((g) => !listed.has(g)))
|
|
728
|
+
this.violation('PDFX-OPTIONAL-CONTENT', `${which} has an /Order that leaves out some optional content groups`);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
/** An action dictionary, not a destination. */
|
|
733
|
+
isAction(obj) {
|
|
734
|
+
return this.pdf.dict(obj)?.has('S') ?? false;
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* One of the trim and art boxes, within the bleed box if there is one;
|
|
738
|
+
* the trim, art and bleed boxes within the crop box if there is one; all
|
|
739
|
+
* within the media box.
|
|
740
|
+
*/
|
|
741
|
+
boxes(page) {
|
|
742
|
+
const n = page.number;
|
|
743
|
+
const box = (key, value) => {
|
|
744
|
+
if (value === undefined || value === null)
|
|
745
|
+
return undefined;
|
|
746
|
+
const r = rect(this.pdf.array(value)?.map((v) => this.pdf.resolve(v)));
|
|
747
|
+
if (!r)
|
|
748
|
+
this.violation(key === 'MediaBox' ? 'PDFX-SYNTAX' : 'PDFX-PAGE-BOX', `/${key} is not a rectangle`, n);
|
|
749
|
+
return r;
|
|
750
|
+
};
|
|
751
|
+
const media = box('MediaBox', page.mediaBox);
|
|
752
|
+
if (page.mediaBox === null)
|
|
753
|
+
this.violation('PDFX-SYNTAX', 'the page has no /MediaBox', n);
|
|
754
|
+
const crop = box('CropBox', page.cropBox);
|
|
755
|
+
const bleed = box('BleedBox', page.dict.get('BleedBox'));
|
|
756
|
+
const trim = box('TrimBox', page.dict.get('TrimBox'));
|
|
757
|
+
const art = box('ArtBox', page.dict.get('ArtBox'));
|
|
758
|
+
const hasTrim = page.dict.has('TrimBox');
|
|
759
|
+
const hasArt = page.dict.has('ArtBox');
|
|
760
|
+
if (!hasTrim && !hasArt)
|
|
761
|
+
this.violation('PDFX-PAGE-BOX', 'the page has neither a /TrimBox nor an /ArtBox', n);
|
|
762
|
+
if (hasTrim && hasArt)
|
|
763
|
+
this.violation('PDFX-PAGE-BOX', 'the page has both a /TrimBox and an /ArtBox', n);
|
|
764
|
+
const inside = (key, r, outerKey, outer) => {
|
|
765
|
+
if (r && outer && !within(r, outer))
|
|
766
|
+
this.violation('PDFX-BOX-NESTING', `the /${key} ${show(r)} extends beyond the /${outerKey} ${show(outer)}`, n);
|
|
767
|
+
};
|
|
768
|
+
for (const [key, r] of [['TrimBox', trim], ['ArtBox', art]])
|
|
769
|
+
inside(key, r, 'BleedBox', bleed);
|
|
770
|
+
for (const [key, r] of [['TrimBox', trim], ['ArtBox', art], ['BleedBox', bleed]])
|
|
771
|
+
inside(key, r, 'CropBox', crop);
|
|
772
|
+
for (const [key, r] of [['TrimBox', trim], ['ArtBox', art], ['BleedBox', bleed], ['CropBox', crop]])
|
|
773
|
+
inside(key, r, 'MediaBox', media);
|
|
774
|
+
if (page.dict.has('PresSteps'))
|
|
775
|
+
this.violation('PDFX-ALTERNATE-PRESENTATIONS', 'the page has /PresSteps', n);
|
|
776
|
+
this.annotations(page, bleed ?? trim ?? art, trim ?? art);
|
|
777
|
+
}
|
|
778
|
+
/** Annotations and form fields keep out of the printed area; TrapNets as the trapping rules say. */
|
|
779
|
+
annotations(page, printed, trimmed) {
|
|
780
|
+
if (page.dict.has('AA'))
|
|
781
|
+
this.violation('PDFX-ACTIONS', 'the page has additional actions (/AA)', page.number);
|
|
782
|
+
for (const a of this.pdf.array(page.dict.get('Annots')) ?? []) {
|
|
783
|
+
const annot = this.pdf.dict(a);
|
|
784
|
+
if (!annot)
|
|
785
|
+
continue;
|
|
786
|
+
const subtype = this.pdf.resolve(annot.get('Subtype'));
|
|
787
|
+
const name = typeof subtype === 'string' ? subtype : 'untyped';
|
|
788
|
+
if (annot.has('A') || annot.has('AA'))
|
|
789
|
+
this.violation('PDFX-ACTIONS', `a ${name} annotation has an action`, page.number);
|
|
790
|
+
if (name === 'FileAttachment' && !this.x4)
|
|
791
|
+
this.violation('PDFX-FILES', 'a file attachment annotation embeds a file', page.number);
|
|
792
|
+
const fs = this.pdf.resolve(annot.get('FS'));
|
|
793
|
+
if (this.x4 && fs instanceof PdfString)
|
|
794
|
+
this.violation('PDFX-FILES', `a ${name} annotation’s file specification is a string, which embeds no file`, page.number);
|
|
795
|
+
if (name === 'TrapNet')
|
|
796
|
+
this.trapNetAnnotation(annot, page.number);
|
|
797
|
+
if (name === 'TrapNet')
|
|
798
|
+
continue;
|
|
799
|
+
const r = rect(this.pdf.array(annot.get('Rect'))?.map((v) => this.pdf.resolve(v)));
|
|
800
|
+
const area = name === 'PrinterMark' ? trimmed : printed;
|
|
801
|
+
if (r && area && overlaps(r, area))
|
|
802
|
+
this.violation('PDFX-ANNOTATIONS', `a ${name} annotation ${show(r)} lies within the ${name === 'PrinterMark' ? 'trimmed' : 'printed'} area ${show(area)}`, page.number);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
/** A TrapNet annotation: the file is trapped, no font fauxing, and its appearance in the printing condition’s colour. */
|
|
806
|
+
trapNetAnnotation(annot, page) {
|
|
807
|
+
this.trapNet = true;
|
|
808
|
+
const fauxing = this.pdf.array(annot.get('FontFauxing'));
|
|
809
|
+
if (annot.has('FontFauxing') && fauxing?.length !== 0)
|
|
810
|
+
this.violation('PDFX-TRAPPED', 'a TrapNet annotation has a /FontFauxing that isn’t empty', page);
|
|
811
|
+
const wanted = this.x1a ? 'DeviceCMYK' : this.intent && INTENT_DEVICE[this.intent];
|
|
812
|
+
const normal = this.pdf.resolve(this.pdf.dict(annot.get('AP'))?.get('N'));
|
|
813
|
+
const appearances = normal instanceof PdfDict ? [...normal.values()].map((s) => this.pdf.stream(s)) : [this.pdf.stream(normal)];
|
|
814
|
+
for (const s of appearances) {
|
|
815
|
+
const pcm = this.pdf.resolve(s?.dict.get('PCM'));
|
|
816
|
+
if (s && wanted && pcm !== wanted)
|
|
817
|
+
this.violation('PDFX-TRAPPED', `a TrapNet annotation’s appearance has /PCM ${describe(pcm)}, not /${wanted}`, page);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
/** Everything a page paints: its content, its transparency group and its TrapNet and PrinterMark annotations’ appearances. */
|
|
821
|
+
page(page) {
|
|
822
|
+
const where = { page: page.number, resources: page.resources, what: 'the page’s content' };
|
|
823
|
+
this.group(page.dict, { ...where, what: 'the page’s transparency group' }, true);
|
|
824
|
+
this.defaults(where);
|
|
825
|
+
const contents = this.pdf.resolve(page.dict.get('Contents'));
|
|
826
|
+
const streams = (Array.isArray(contents) ? contents : [contents]).map((c) => this.pdf.stream(c)).filter((s) => s !== undefined);
|
|
827
|
+
for (const s of streams)
|
|
828
|
+
this.streamRules(s, where);
|
|
829
|
+
try {
|
|
830
|
+
// A page’s content streams are one stream, cut anywhere between tokens.
|
|
831
|
+
const parts = streams.flatMap((s) => [this.pdf.decode(s), new Uint8Array([10])]);
|
|
832
|
+
const all = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
|
|
833
|
+
parts.reduce((at, p) => (all.set(p, at), at + p.length), 0);
|
|
834
|
+
this.content(all, where);
|
|
835
|
+
}
|
|
836
|
+
catch (e) {
|
|
837
|
+
this.unreadable(e, where);
|
|
838
|
+
}
|
|
839
|
+
// Other annotations are non-print elements, whatever their flags: X-4
|
|
840
|
+
// holds their appearances to nothing (6.2), the 2003 parts to all but
|
|
841
|
+
// the colour rules (6.2.1).
|
|
842
|
+
for (const a of this.pdf.array(page.dict.get('Annots')) ?? []) {
|
|
843
|
+
const annot = this.pdf.dict(a);
|
|
844
|
+
const subtype = this.pdf.resolve(annot?.get('Subtype'));
|
|
845
|
+
const print = subtype === 'TrapNet' || subtype === 'PrinterMark';
|
|
846
|
+
if (!annot || (!print && this.x4))
|
|
847
|
+
continue;
|
|
848
|
+
for (const appearances of this.pdf.dict(annot.get('AP'))?.values() ?? []) {
|
|
849
|
+
const v = this.pdf.resolve(appearances);
|
|
850
|
+
const states = v instanceof PdfDict ? [...v.values()] : [v];
|
|
851
|
+
for (const s of states)
|
|
852
|
+
this.xobject(s, { ...where, resources: undefined, what: `a ${describe(subtype).slice(1)} annotation’s appearance`, ...(print ? {} : { nonPrint: true }) });
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
/** Default colour spaces: none in X-1a; in X-3 colorimetric; in X-4 held to the colour rules. */
|
|
857
|
+
defaults(where) {
|
|
858
|
+
if (where.nonPrint)
|
|
859
|
+
return;
|
|
860
|
+
const spaces = this.pdf.dict(where.resources?.get('ColorSpace'));
|
|
861
|
+
for (const key of ['DefaultGray', 'DefaultRGB', 'DefaultCMYK']) {
|
|
862
|
+
if (!spaces?.has(key))
|
|
863
|
+
continue;
|
|
864
|
+
if (this.x1a)
|
|
865
|
+
this.violation('PDFX-COLOUR-SPACE', `${where.what} has a /${key} colour space`, where.page);
|
|
866
|
+
else if (this.x4)
|
|
867
|
+
this.space(spaces.get(key), { ...where, what: `${where.what}’s /${key}`, isDefault: true });
|
|
868
|
+
else {
|
|
869
|
+
const cs = this.pdf.resolve(spaces.get(key));
|
|
870
|
+
const family = Array.isArray(cs) ? this.pdf.resolve(cs[0]) : cs;
|
|
871
|
+
if (typeof family !== 'string' || !INDEPENDENT.has(family))
|
|
872
|
+
this.violation('PDFX-DEVICE-COLOUR', `${where.what}’s /${key} is ${describe(family)}, not colorimetric`, where.page);
|
|
873
|
+
else
|
|
874
|
+
this.space(cs, where);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
/** The Default space that remaps a device space where it is used, if any. */
|
|
879
|
+
remapped(device, where) {
|
|
880
|
+
return this.pdf.dict(where.resources?.get('ColorSpace'))?.has(`Default${device.slice('Device'.length)}`) ?? false;
|
|
881
|
+
}
|
|
882
|
+
/** What any stream may not be: under a filter the standard lacks; in X-4, JPEG 2000 beyond 6.27. (External streams are {@link everyObject}’s.) */
|
|
883
|
+
streamRules(s, where) {
|
|
884
|
+
const filter = this.pdf.resolve(s.dict.get('Filter'));
|
|
885
|
+
const filters = (Array.isArray(filter) ? filter.map((f) => this.pdf.resolve(f)) : [filter]).filter((f) => typeof f === 'string');
|
|
886
|
+
this.filters(filters, where);
|
|
887
|
+
if (this.x4 && filters.includes('JPXDecode'))
|
|
888
|
+
this.jpx(s, where);
|
|
889
|
+
}
|
|
890
|
+
/** Filters: no LZW; before X-4 none PDF 1.4 lacks, nor JBIG2; in X-4 no Crypt and none the PDF Reference doesn’t list. */
|
|
891
|
+
filters(list, where) {
|
|
892
|
+
for (const f of list) {
|
|
893
|
+
if (typeof f !== 'string')
|
|
894
|
+
continue;
|
|
895
|
+
const name = f === 'LZW' ? 'LZWDecode' : f;
|
|
896
|
+
if (!FILTERS.has(f))
|
|
897
|
+
this.violation('PDFX-FILTERS', `${where.what} uses /${f}, which isn’t one of the PDF Reference’s filters`, where.page);
|
|
898
|
+
else if (name === 'LZWDecode' || name === 'Crypt' || (!this.x4 && (name === 'JBIG2Decode' || name === 'JPXDecode')))
|
|
899
|
+
this.violation('PDFX-FILTERS', `${where.what} uses ${name}, which ${this.standard} doesn’t allow`, where.page);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
/** PDF/X-4’s JPEG 2000: a JPX file, its channels, colour specifications and depths (6.27). */
|
|
903
|
+
jpx(s, where) {
|
|
904
|
+
if (this.once(s, 'jpx'))
|
|
905
|
+
return;
|
|
906
|
+
let data;
|
|
907
|
+
try {
|
|
908
|
+
// The JPX data itself, under any filters before JPXDecode.
|
|
909
|
+
data = this.pdf.decode(new PdfStream(withoutJpx(s.dict), s.raw));
|
|
910
|
+
}
|
|
911
|
+
catch {
|
|
912
|
+
return this.notice('PDFX-JPX', `${where.what} is JPEG 2000 that could not be read, so it was not checked`, where.page);
|
|
913
|
+
}
|
|
914
|
+
for (const problem of jpxProblems(data))
|
|
915
|
+
this.violation('PDFX-JPX', `${where.what} is JPEG 2000 ${problem}`, where.page);
|
|
916
|
+
}
|
|
917
|
+
/** A content stream that could not be read: say what wasn’t checked. */
|
|
918
|
+
unreadable(e, where) {
|
|
919
|
+
if (!(e instanceof Error) || e.name === 'TypeError' || e.name === 'RangeError')
|
|
920
|
+
throw e;
|
|
921
|
+
const message = `${where.what} could not be read (${e.message}), so its colours and fonts were not checked`;
|
|
922
|
+
this.notice(this.x1a ? 'PDFX-COLOUR-SPACE' : 'PDFX-DEVICE-COLOUR', message, where.page);
|
|
923
|
+
this.notice('PDFX-FONT-EMBEDDED', message, where.page);
|
|
924
|
+
}
|
|
925
|
+
content(data, where) {
|
|
926
|
+
// A named resource, unresolved, so that messages can give its reference.
|
|
927
|
+
const named = (category, name) => typeof name === 'string' ? this.pdf.dict(where.resources?.get(category))?.get(name) : undefined;
|
|
928
|
+
const resource = (category, name) => this.pdf.resolve(named(category, name));
|
|
929
|
+
let state = { ...(where.state ?? INITIAL) };
|
|
930
|
+
const stack = [];
|
|
931
|
+
let depth = 0;
|
|
932
|
+
for (const { op, operands } of contentOps(data, this.lexical)) {
|
|
933
|
+
if (!OPERATORS.has(op) && op !== 'PS')
|
|
934
|
+
this.violation('PDFX-OPERATORS', `${where.what} uses the operator ${op}, which the PDF Reference doesn’t describe`, where.page);
|
|
935
|
+
switch (op) {
|
|
936
|
+
case 'q':
|
|
937
|
+
stack.push(state);
|
|
938
|
+
state = { ...state };
|
|
939
|
+
if (++depth > 28)
|
|
940
|
+
this.violation('PDFX-LIMITS', `${where.what} nests q more than 28 deep`, where.page);
|
|
941
|
+
break;
|
|
942
|
+
case 'Q':
|
|
943
|
+
state = stack.pop() ?? state;
|
|
944
|
+
depth = Math.max(0, depth - 1);
|
|
945
|
+
break;
|
|
946
|
+
case 'd1':
|
|
947
|
+
where = { ...where, uncoloured: true };
|
|
948
|
+
break;
|
|
949
|
+
case 'g':
|
|
950
|
+
case 'G':
|
|
951
|
+
this.device('DeviceGray', where);
|
|
952
|
+
if (op === 'g')
|
|
953
|
+
state.fill = 'DeviceGray';
|
|
954
|
+
else
|
|
955
|
+
state.stroke = 'DeviceGray';
|
|
956
|
+
break;
|
|
957
|
+
case 'rg':
|
|
958
|
+
case 'RG':
|
|
959
|
+
this.device('DeviceRGB', where);
|
|
960
|
+
if (op === 'rg')
|
|
961
|
+
state.fill = 'DeviceRGB';
|
|
962
|
+
else
|
|
963
|
+
state.stroke = 'DeviceRGB';
|
|
964
|
+
break;
|
|
965
|
+
case 'k':
|
|
966
|
+
case 'K':
|
|
967
|
+
this.device('DeviceCMYK', where);
|
|
968
|
+
if (op === 'k')
|
|
969
|
+
state.fill = 'DeviceCMYK';
|
|
970
|
+
else
|
|
971
|
+
state.stroke = 'DeviceCMYK';
|
|
972
|
+
break;
|
|
973
|
+
case 'cs':
|
|
974
|
+
case 'CS': {
|
|
975
|
+
// Families by their full names; any other name is a resource (abbreviations are inline images’ alone).
|
|
976
|
+
const name = operands[0];
|
|
977
|
+
const family = typeof name === 'string' && /^(Device(Gray|RGB|CMYK)|Pattern)$/.test(name);
|
|
978
|
+
const space = family ? name : resource('ColorSpace', name);
|
|
979
|
+
this.space(space, where);
|
|
980
|
+
if (op === 'cs')
|
|
981
|
+
state.fill = space;
|
|
982
|
+
else
|
|
983
|
+
state.stroke = space;
|
|
984
|
+
break;
|
|
985
|
+
}
|
|
986
|
+
case 'scn':
|
|
987
|
+
case 'SCN':
|
|
988
|
+
this.pattern(resource('Pattern', operands.at(-1)), { ...where, state });
|
|
989
|
+
break;
|
|
990
|
+
case 'sh':
|
|
991
|
+
this.shading(resource('Shading', operands[0]), where);
|
|
992
|
+
break;
|
|
993
|
+
case 'Do': {
|
|
994
|
+
const x = named('XObject', operands[0]);
|
|
995
|
+
const s = this.pdf.stream(x);
|
|
996
|
+
if (s && this.pdf.resolve(s.dict.get('ImageMask')) === true)
|
|
997
|
+
this.overprint(state, 'fill', 'an image mask', where);
|
|
998
|
+
this.xobject(x, { ...where, state });
|
|
999
|
+
break;
|
|
1000
|
+
}
|
|
1001
|
+
case 'gs':
|
|
1002
|
+
this.extGState(resource('ExtGState', operands[0]), where, state);
|
|
1003
|
+
break;
|
|
1004
|
+
case 'Tf':
|
|
1005
|
+
state.font = named('Font', operands[0]);
|
|
1006
|
+
break;
|
|
1007
|
+
case 'Tr':
|
|
1008
|
+
if (typeof operands[0] === 'number')
|
|
1009
|
+
state.render = operands[0];
|
|
1010
|
+
break;
|
|
1011
|
+
case 'ri':
|
|
1012
|
+
this.intentName(operands[0], `${where.what}’s ri operator`, where);
|
|
1013
|
+
break;
|
|
1014
|
+
case 'BI': {
|
|
1015
|
+
const dict = operands[0];
|
|
1016
|
+
if (!(dict instanceof PdfDict))
|
|
1017
|
+
break;
|
|
1018
|
+
if (dict.get('IM') !== true && dict.get('ImageMask') !== true) {
|
|
1019
|
+
const cs = dict.get('CS') ?? dict.get('ColorSpace');
|
|
1020
|
+
this.space(typeof cs === 'string' && !DEVICE[cs] ? resource('ColorSpace', cs) : cs, { ...where, what: 'an inline image' });
|
|
1021
|
+
}
|
|
1022
|
+
else
|
|
1023
|
+
this.overprint(state, 'fill', 'an image mask', where);
|
|
1024
|
+
const f = dict.get('F') ?? dict.get('Filter');
|
|
1025
|
+
this.filters(Array.isArray(f) ? f : f === undefined ? [] : [f], { ...where, what: 'an inline image' });
|
|
1026
|
+
if (dict.has('Intent') || dict.has('Int'))
|
|
1027
|
+
this.intentName(dict.get('Intent') ?? dict.get('Int'), 'an inline image’s /Intent', where);
|
|
1028
|
+
break;
|
|
1029
|
+
}
|
|
1030
|
+
case 'PS':
|
|
1031
|
+
this.violation('PDFX-POSTSCRIPT', `${where.what} uses the PS operator`, where.page);
|
|
1032
|
+
break;
|
|
1033
|
+
case 'f':
|
|
1034
|
+
case 'F':
|
|
1035
|
+
case 'f*':
|
|
1036
|
+
this.overprint(state, 'fill', 'a fill', where);
|
|
1037
|
+
break;
|
|
1038
|
+
case 'S':
|
|
1039
|
+
case 's':
|
|
1040
|
+
this.overprint(state, 'stroke', 'a stroke', where);
|
|
1041
|
+
break;
|
|
1042
|
+
case 'B':
|
|
1043
|
+
case 'B*':
|
|
1044
|
+
case 'b':
|
|
1045
|
+
case 'b*':
|
|
1046
|
+
this.overprint(state, 'fill', 'a fill', where);
|
|
1047
|
+
this.overprint(state, 'stroke', 'a stroke', where);
|
|
1048
|
+
break;
|
|
1049
|
+
}
|
|
1050
|
+
if (SHOW.has(op))
|
|
1051
|
+
this.show(op, operands, state, where);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
/** Text shown: its font must be embedded (unless invisible, in X-4), and in X-4 not show .notdef. */
|
|
1055
|
+
show(op, operands, state, where) {
|
|
1056
|
+
const strings = (op === 'TJ' ? (Array.isArray(operands[0]) ? operands[0] : []) : operands.slice(-1)).filter((s) => s instanceof PdfString);
|
|
1057
|
+
const mode = state.render % 4;
|
|
1058
|
+
if (mode === 0 || mode === 2)
|
|
1059
|
+
this.overprint(state, 'fill', 'text', where);
|
|
1060
|
+
if (mode === 1 || mode === 2)
|
|
1061
|
+
this.overprint(state, 'stroke', 'text', where);
|
|
1062
|
+
if (!(this.x4 && state.render === 3))
|
|
1063
|
+
this.font(state.font, where);
|
|
1064
|
+
if (this.x4)
|
|
1065
|
+
this.notdef(state.font, strings, where);
|
|
1066
|
+
}
|
|
1067
|
+
/** PDF/X-4: four-colour ICC-based colour that overprints does so in overprint mode 0 (6.4.3.3). */
|
|
1068
|
+
overprint(state, paint, what, where) {
|
|
1069
|
+
if (!this.x4 || this.intent !== 'CMYK' || where.uncoloured)
|
|
1070
|
+
return;
|
|
1071
|
+
const on = paint === 'fill' ? state.op : state.OP;
|
|
1072
|
+
if (!on || state.opm !== 1)
|
|
1073
|
+
return;
|
|
1074
|
+
const cs = this.pdf.resolve(paint === 'fill' ? state.fill : state.stroke);
|
|
1075
|
+
if (!Array.isArray(cs) || this.pdf.resolve(cs[0]) !== 'ICCBased')
|
|
1076
|
+
return;
|
|
1077
|
+
if (this.pdf.resolve(this.pdf.stream(cs[1])?.dict.get('N')) !== 4)
|
|
1078
|
+
return;
|
|
1079
|
+
this.violation('PDFX-ICC-OVERPRINT', `${where.what} overprints ${what} in four-colour ICC-based colour in overprint mode 1`, where.page);
|
|
1080
|
+
}
|
|
1081
|
+
/** A rendering intent PDF/X-4 allows (6.23). */
|
|
1082
|
+
intentName(v, what, where) {
|
|
1083
|
+
const name = this.pdf.resolve(v);
|
|
1084
|
+
if (!(typeof name === 'string' && INTENTS.has(name)))
|
|
1085
|
+
this.violation('PDFX-RENDERING-INTENT', `${what} is ${describe(name)}, not one of the four rendering intents`, where.page);
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Checks a colour space, through the spaces it is built on: an Indexed or
|
|
1089
|
+
* Pattern space’s base and a Separation or DeviceN space’s alternate,
|
|
1090
|
+
* which is what prints where the colourant isn’t on press.
|
|
1091
|
+
*/
|
|
1092
|
+
space(obj, where, depth = 0) {
|
|
1093
|
+
const cs = this.pdf.resolve(obj);
|
|
1094
|
+
if (typeof cs === 'string') {
|
|
1095
|
+
const device = DEVICE[cs];
|
|
1096
|
+
if (device)
|
|
1097
|
+
this.device(device, where);
|
|
1098
|
+
if (INDEPENDENT.has(cs))
|
|
1099
|
+
this.independent(cs, where);
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
if (!Array.isArray(cs) || depth > 8)
|
|
1103
|
+
return;
|
|
1104
|
+
const family = this.pdf.resolve(cs[0]);
|
|
1105
|
+
if (family === 'Indexed' || family === 'I' || family === 'Pattern')
|
|
1106
|
+
this.space(cs[1], where, depth + 1);
|
|
1107
|
+
else if (family === 'Separation' || family === 'DeviceN') {
|
|
1108
|
+
this.space(cs[2], where, depth + 1);
|
|
1109
|
+
if (family === 'Separation')
|
|
1110
|
+
this.separation(cs, where);
|
|
1111
|
+
else
|
|
1112
|
+
this.deviceN(cs, where);
|
|
1113
|
+
}
|
|
1114
|
+
else if (typeof family === 'string' && INDEPENDENT.has(family)) {
|
|
1115
|
+
this.independent(family, where);
|
|
1116
|
+
const profile = family === 'ICCBased' ? this.pdf.stream(cs[1]) : undefined;
|
|
1117
|
+
if (profile && !this.once(profile, 'version'))
|
|
1118
|
+
this.iccVersion(profile, `${where.what}’s ICC-based colour space`, where.page);
|
|
1119
|
+
if (profile && this.x4 && this.intentProfile && this.pdf.resolve(profile.dict.get('N')) === 4 && this.sameProfile(cs[1], profile))
|
|
1120
|
+
this.violation('PDFX-PROFILE-REUSE', `${where.what} uses the output intent’s profile as a four-colour ICC-based colour space`, where.page);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* An ICC profile’s version (header bytes 8 and 9): 2 before X-4, whose
|
|
1125
|
+
* parts cite ICC.1:1998 alone and are PDF 1.3 or 1.4; in X-4, 2 or 4.0
|
|
1126
|
+
* to 4.2, ISO 15076-1:2005’s, and not ISO 15076-1:2010’s 4.3 or later.
|
|
1127
|
+
*/
|
|
1128
|
+
iccVersion(profile, what, page) {
|
|
1129
|
+
let icc;
|
|
1130
|
+
try {
|
|
1131
|
+
icc = profile instanceof PdfStream ? this.pdf.decode(profile) : profile;
|
|
1132
|
+
}
|
|
1133
|
+
catch {
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
if (icc.length < 128)
|
|
1137
|
+
return;
|
|
1138
|
+
const major = icc[8];
|
|
1139
|
+
const minor = icc[9] >> 4;
|
|
1140
|
+
if (this.x4 ? major === 2 || (major === 4 && minor <= 2) : major === 2)
|
|
1141
|
+
return;
|
|
1142
|
+
const allowed = this.x4 ? 'version 2 or 4.0 to 4.2' : 'version 2 (ICC.1:1998)';
|
|
1143
|
+
this.violation('PDFX-ICC-VERSION', `${what} is an ICC profile of version ${major}.${minor}; ${this.standard} takes ${allowed}`, page);
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* Whether an ICC-based space’s profile is the output intent’s: the same
|
|
1147
|
+
* stream, or the same MD5, from the profiles’ IDs where both have one,
|
|
1148
|
+
* else as ISO 15076-1 computes it (the bytes with the flags, rendering
|
|
1149
|
+
* intent and ID zeroed), compared here as those bytes.
|
|
1150
|
+
*/
|
|
1151
|
+
sameProfile(ref, s) {
|
|
1152
|
+
const intentRef = this.intentProfileRef;
|
|
1153
|
+
if (ref instanceof PdfRef && intentRef instanceof PdfRef && ref.num === intentRef.num)
|
|
1154
|
+
return true;
|
|
1155
|
+
let icc;
|
|
1156
|
+
try {
|
|
1157
|
+
icc = this.pdf.decode(s);
|
|
1158
|
+
}
|
|
1159
|
+
catch {
|
|
1160
|
+
return false;
|
|
1161
|
+
}
|
|
1162
|
+
const intent = this.intentProfile;
|
|
1163
|
+
const id = (p) => p.subarray(84, 100);
|
|
1164
|
+
const zero = (b) => b.every((x) => x === 0);
|
|
1165
|
+
if (!zero(id(icc)) && !zero(id(intent)))
|
|
1166
|
+
return id(icc).every((b, i) => b === id(intent)[i]);
|
|
1167
|
+
const masked = (p) => p.map((b, i) => ((i >= 44 && i < 48) || (i >= 64 && i < 68) || (i >= 84 && i < 100) ? 0 : b));
|
|
1168
|
+
const a = masked(icc);
|
|
1169
|
+
const b = masked(intent);
|
|
1170
|
+
return a.length === b.length && a.every((x, i) => x === b[i]);
|
|
1171
|
+
}
|
|
1172
|
+
/** ICC-based and CIE colour: none in X-1a; an X-3 file using it needs the output profile. */
|
|
1173
|
+
independent(family, where) {
|
|
1174
|
+
if (where.nonPrint)
|
|
1175
|
+
return;
|
|
1176
|
+
this.independentColour = true;
|
|
1177
|
+
if (this.x1a)
|
|
1178
|
+
this.violation('PDFX-COLOUR-SPACE', `${where.what} uses ${family} colour, which PDF/X-1a doesn’t allow`, where.page);
|
|
1179
|
+
}
|
|
1180
|
+
/** PDF/X-4: one Separation name, one alternate and tint transform (6.4.3.4); its name, UTF-8 and escaped (6.6). */
|
|
1181
|
+
separation(cs, where) {
|
|
1182
|
+
if (!this.x4)
|
|
1183
|
+
return;
|
|
1184
|
+
const name = this.pdf.resolve(cs[1]);
|
|
1185
|
+
if (typeof name !== 'string')
|
|
1186
|
+
return;
|
|
1187
|
+
this.name(name, 'separation', where);
|
|
1188
|
+
const first = this.separations.get(name);
|
|
1189
|
+
if (!first)
|
|
1190
|
+
this.separations.set(name, [cs[2], cs[3]]);
|
|
1191
|
+
else if (!this.same(first[0], cs[2]) || !this.same(first[1], cs[3]))
|
|
1192
|
+
this.violation('PDFX-SPOT-COLOURS', `${where.what} uses a Separation /${name} whose alternate space or tint transform differs from another /${name}’s`, where.page);
|
|
1193
|
+
}
|
|
1194
|
+
/** A DeviceN space: its spot colorants in /Colorants, its process space and mixing hints (X-4), at most 32 colorants. */
|
|
1195
|
+
deviceN(cs, where) {
|
|
1196
|
+
if (!this.x4)
|
|
1197
|
+
return;
|
|
1198
|
+
const names = this.pdf.array(cs[1])?.map((n) => this.pdf.resolve(n)) ?? [];
|
|
1199
|
+
if (names.length > 32)
|
|
1200
|
+
this.violation('PDFX-LIMITS', `${where.what} uses a DeviceN space of ${names.length} colorants, more than 32`, where.page);
|
|
1201
|
+
const attributes = this.pdf.dict(cs[4]);
|
|
1202
|
+
const colorants = this.pdf.dict(attributes?.get('Colorants'));
|
|
1203
|
+
for (const n of names) {
|
|
1204
|
+
if (typeof n !== 'string')
|
|
1205
|
+
continue;
|
|
1206
|
+
this.name(n, 'separation', where);
|
|
1207
|
+
if (!PROCESS.has(n) && !colorants?.has(n))
|
|
1208
|
+
this.violation('PDFX-SPOT-COLOURS', `${where.what} uses a DeviceN space whose colorant /${n} is not in its /Colorants`, where.page);
|
|
1209
|
+
}
|
|
1210
|
+
for (const sep of colorants?.values() ?? []) {
|
|
1211
|
+
const s = this.pdf.array(sep);
|
|
1212
|
+
if (s && this.pdf.resolve(s[0]) === 'Separation')
|
|
1213
|
+
this.space(s, where);
|
|
1214
|
+
}
|
|
1215
|
+
const process = this.pdf.resolve(this.pdf.dict(attributes?.get('Process'))?.get('ColorSpace'));
|
|
1216
|
+
if (process !== null && this.intent) {
|
|
1217
|
+
const family = Array.isArray(process) ? this.pdf.resolve(process[0]) : process;
|
|
1218
|
+
const wanted = INTENT_DEVICE[this.intent];
|
|
1219
|
+
if (family !== wanted && !(family === 'ICCBased' && Array.isArray(process) && this.pdf.resolve(this.pdf.stream(process[1])?.dict.get('N')) === { GRAY: 1, RGB: 3, CMYK: 4 }[this.intent]))
|
|
1220
|
+
this.violation('PDFX-SPOT-COLOURS', `${where.what} uses a DeviceN space whose /Process colour space is ${describe(family)}, not the output intent’s ${wanted}`, where.page);
|
|
1221
|
+
}
|
|
1222
|
+
const hints = this.pdf.dict(attributes?.get('MixingHints'));
|
|
1223
|
+
if (!hints)
|
|
1224
|
+
return;
|
|
1225
|
+
if (hints.has('DotGain'))
|
|
1226
|
+
this.violation('PDFX-SPOT-COLOURS', `${where.what} uses a DeviceN space whose /MixingHints have /DotGain`, where.page);
|
|
1227
|
+
const order = this.pdf.array(hints.get('PrintingOrder'))?.map((n) => describe(this.pdf.resolve(n))).join(' ');
|
|
1228
|
+
if (order !== undefined) {
|
|
1229
|
+
if (this.printingOrder === undefined)
|
|
1230
|
+
this.printingOrder = order;
|
|
1231
|
+
else if (order !== this.printingOrder)
|
|
1232
|
+
this.violation('PDFX-SPOT-COLOURS', `${where.what} uses a /PrintingOrder (${order}) another DeviceN space’s (${this.printingOrder}) differs from`, where.page);
|
|
1233
|
+
}
|
|
1234
|
+
for (const [ink, v] of this.pdf.dict(hints.get('Solidities')) ?? []) {
|
|
1235
|
+
const solidity = this.pdf.resolve(v);
|
|
1236
|
+
if (typeof solidity !== 'number')
|
|
1237
|
+
continue;
|
|
1238
|
+
const first = this.solidities.get(ink);
|
|
1239
|
+
if (first === undefined)
|
|
1240
|
+
this.solidities.set(ink, solidity);
|
|
1241
|
+
else if (first !== solidity)
|
|
1242
|
+
this.violation('PDFX-SPOT-COLOURS', `${where.what} gives /${ink} a solidity of ${solidity}, and another DeviceN space ${first}`, where.page);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
/** Two objects the same, as PDF/X-4 compares Separations: by value, whether direct or indirect, compressed or not. */
|
|
1246
|
+
same(a, b, depth = 0) {
|
|
1247
|
+
const x = this.pdf.resolve(a);
|
|
1248
|
+
const y = this.pdf.resolve(b);
|
|
1249
|
+
if (x === y)
|
|
1250
|
+
return true;
|
|
1251
|
+
if (depth > 16)
|
|
1252
|
+
return false;
|
|
1253
|
+
if (x instanceof PdfString && y instanceof PdfString)
|
|
1254
|
+
return x.text === y.text;
|
|
1255
|
+
if (Array.isArray(x) && Array.isArray(y))
|
|
1256
|
+
return x.length === y.length && x.every((v, i) => this.same(v, y[i], depth + 1));
|
|
1257
|
+
if (x instanceof PdfStream && y instanceof PdfStream) {
|
|
1258
|
+
try {
|
|
1259
|
+
const p = this.pdf.decode(x);
|
|
1260
|
+
const q = this.pdf.decode(y);
|
|
1261
|
+
if (p.length !== q.length || !p.every((v, i) => v === q[i]))
|
|
1262
|
+
return false;
|
|
1263
|
+
}
|
|
1264
|
+
catch {
|
|
1265
|
+
return false;
|
|
1266
|
+
}
|
|
1267
|
+
return this.sameDict(x.dict, y.dict, depth, ['Length', 'Filter', 'DecodeParms']);
|
|
1268
|
+
}
|
|
1269
|
+
if (x instanceof PdfDict && y instanceof PdfDict)
|
|
1270
|
+
return this.sameDict(x, y, depth, []);
|
|
1271
|
+
return false;
|
|
1272
|
+
}
|
|
1273
|
+
sameDict(x, y, depth, ignore) {
|
|
1274
|
+
const keys = (d) => [...d.keys()].filter((k) => !ignore.includes(k)).sort();
|
|
1275
|
+
const k = keys(x);
|
|
1276
|
+
const l = keys(y);
|
|
1277
|
+
return k.length === l.length && k.every((key, i) => key === l[i] && this.same(x.get(key), y.get(key), depth + 1));
|
|
1278
|
+
}
|
|
1279
|
+
/** PDF/X-4: a font or separation name is UTF-8, its bytes outside 33 to 126 escaped (6.6). */
|
|
1280
|
+
name(name, kind, where) {
|
|
1281
|
+
if (!this.x4)
|
|
1282
|
+
return;
|
|
1283
|
+
const bytes = Uint8Array.from(name, (c) => c.charCodeAt(0));
|
|
1284
|
+
try {
|
|
1285
|
+
new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
1286
|
+
}
|
|
1287
|
+
catch {
|
|
1288
|
+
this.violation('PDFX-NAMES', `the ${kind} name /${escapeName(name)} is not UTF-8`, where.page);
|
|
1289
|
+
}
|
|
1290
|
+
if (this.pdf.lexical.unescapedNames.has(name) || this.lexical.unescapedNames.has(name))
|
|
1291
|
+
this.violation('PDFX-NAMES', `the ${kind} name /${escapeName(name)} has a byte outside ! to ~ written as itself, not #xx`, where.page);
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* A device colour space. In X-1a, DeviceRGB is never allowed and the
|
|
1295
|
+
* others always are. In X-3 and X-4, one is allowed where the output
|
|
1296
|
+
* intent describes it, DeviceGray under a grey or CMYK one; a Default
|
|
1297
|
+
* colour space in the resources remaps it, so it is allowed then too
|
|
1298
|
+
* (ISO 15930-7 6.4.3.1), the Default space being checked itself.
|
|
1299
|
+
*/
|
|
1300
|
+
device(device, where) {
|
|
1301
|
+
if (where.uncoloured || where.nonPrint)
|
|
1302
|
+
return;
|
|
1303
|
+
if (this.x1a) {
|
|
1304
|
+
if (device === 'DeviceRGB')
|
|
1305
|
+
this.violation('PDFX-COLOUR-SPACE', `${where.what} uses DeviceRGB, which PDF/X-1a doesn’t allow`, where.page);
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
const intent = this.intent;
|
|
1309
|
+
if (!intent)
|
|
1310
|
+
return;
|
|
1311
|
+
if (device === 'DeviceGray' && (intent === 'GRAY' || intent === 'CMYK'))
|
|
1312
|
+
return;
|
|
1313
|
+
if ((device === 'DeviceRGB' && intent === 'RGB') || (device === 'DeviceCMYK' && intent === 'CMYK'))
|
|
1314
|
+
return;
|
|
1315
|
+
if (!where.isDefault && this.remapped(device, where))
|
|
1316
|
+
return;
|
|
1317
|
+
this.violation('PDFX-DEVICE-COLOUR', `${where.what} uses ${device}, which a ${intent} output intent doesn’t characterise`, where.page);
|
|
1318
|
+
}
|
|
1319
|
+
/** A transparency group: before X-4 none that is a form XObject; its blending space is a colour space like any other. */
|
|
1320
|
+
group(dict, where, isPage = false) {
|
|
1321
|
+
const group = this.pdf.dict(dict.get('Group'));
|
|
1322
|
+
if (!group || this.pdf.resolve(group.get('S')) !== 'Transparency')
|
|
1323
|
+
return;
|
|
1324
|
+
if (!isPage && !this.x4)
|
|
1325
|
+
this.violation('PDFX-TRANSPARENCY', `${where.what} is a transparency group`, where.page);
|
|
1326
|
+
this.space(group.get('CS'), where);
|
|
1327
|
+
}
|
|
1328
|
+
/** Whether `obj` has been checked (for this purpose); marks it checked. */
|
|
1329
|
+
purposes = new Map();
|
|
1330
|
+
once(obj, purpose) {
|
|
1331
|
+
const seen = purpose ? (this.purposes.get(purpose) ?? this.purposes.set(purpose, new Set()).get(purpose)) : this.seen;
|
|
1332
|
+
if (!obj || seen.has(obj))
|
|
1333
|
+
return true;
|
|
1334
|
+
seen.add(obj);
|
|
1335
|
+
return false;
|
|
1336
|
+
}
|
|
1337
|
+
xobject(obj, where) {
|
|
1338
|
+
const s = this.pdf.stream(obj);
|
|
1339
|
+
if (this.once(s) || !s)
|
|
1340
|
+
return;
|
|
1341
|
+
const name = obj instanceof PdfRef ? ` ${obj.toString()}` : '';
|
|
1342
|
+
const subtype = this.pdf.resolve(s.dict.get('Subtype'));
|
|
1343
|
+
if (s.dict.has('OPI'))
|
|
1344
|
+
this.violation('PDFX-OPI', `XObject${name} has OPI comments`, where.page);
|
|
1345
|
+
if (subtype === 'Image') {
|
|
1346
|
+
const image = { ...where, what: `image${name}` };
|
|
1347
|
+
this.streamRules(s, image);
|
|
1348
|
+
if (this.pdf.resolve(s.dict.get('ImageMask')) !== true)
|
|
1349
|
+
this.space(s.dict.get('ColorSpace'), image);
|
|
1350
|
+
for (const alt of this.pdf.array(s.dict.get('Alternates')) ?? [])
|
|
1351
|
+
if (this.pdf.resolve(this.pdf.dict(alt)?.get('DefaultForPrinting')) === true)
|
|
1352
|
+
this.violation('PDFX-ALTERNATES', `image${name} has an alternate with /DefaultForPrinting true`, where.page);
|
|
1353
|
+
const smask = this.pdf.resolve(s.dict.get('SMask'));
|
|
1354
|
+
if (smask !== null && smask !== 'None' && !this.x4)
|
|
1355
|
+
this.violation('PDFX-TRANSPARENCY', `image${name} has a soft mask (/SMask)`, where.page);
|
|
1356
|
+
if (s.dict.has('Intent'))
|
|
1357
|
+
this.intentName(s.dict.get('Intent'), `image${name}’s /Intent`, where);
|
|
1358
|
+
}
|
|
1359
|
+
else if (subtype === 'Form') {
|
|
1360
|
+
if (s.dict.has('Ref'))
|
|
1361
|
+
this.violation('PDFX-FILES', `form XObject${name} is a reference XObject (/Ref), whose file is outside`, where.page);
|
|
1362
|
+
if (this.pdf.resolve(s.dict.get('Subtype2')) === 'PS')
|
|
1363
|
+
this.violation('PDFX-POSTSCRIPT', `form XObject${name} has /Subtype2 /PS`, where.page);
|
|
1364
|
+
this.form(s, { ...where, what: `form XObject${name}` });
|
|
1365
|
+
}
|
|
1366
|
+
else if (subtype === 'PS')
|
|
1367
|
+
this.violation('PDFX-POSTSCRIPT', `a PostScript XObject${name} is used`, where.page);
|
|
1368
|
+
}
|
|
1369
|
+
/** A form, tiling pattern or glyph: content with its own resources, else those it is used from. */
|
|
1370
|
+
form(s, where) {
|
|
1371
|
+
const inner = { ...where, resources: this.pdf.dict(s.dict.get('Resources')) ?? where.resources };
|
|
1372
|
+
this.streamRules(s, where);
|
|
1373
|
+
this.group(s.dict, { ...inner, what: `${where.what}’s transparency group` });
|
|
1374
|
+
this.defaults(inner);
|
|
1375
|
+
try {
|
|
1376
|
+
this.content(this.pdf.decode(s), inner);
|
|
1377
|
+
}
|
|
1378
|
+
catch (e) {
|
|
1379
|
+
this.unreadable(e, inner);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
pattern(obj, where) {
|
|
1383
|
+
const s = this.pdf.stream(obj);
|
|
1384
|
+
const d = s?.dict ?? this.pdf.dict(obj);
|
|
1385
|
+
if (this.once(d) || !d)
|
|
1386
|
+
return;
|
|
1387
|
+
if (s)
|
|
1388
|
+
this.form(s, { ...where, what: 'a tiling pattern' });
|
|
1389
|
+
else {
|
|
1390
|
+
this.shading(d.get('Shading'), where);
|
|
1391
|
+
this.extGState(this.pdf.resolve(d.get('ExtGState')), where);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
shading(obj, where) {
|
|
1395
|
+
const v = this.pdf.resolve(obj);
|
|
1396
|
+
const d = v instanceof PdfStream ? v.dict : v instanceof PdfDict ? v : undefined;
|
|
1397
|
+
if (this.once(d))
|
|
1398
|
+
return;
|
|
1399
|
+
if (v instanceof PdfStream)
|
|
1400
|
+
this.streamRules(v, { ...where, what: 'a shading' });
|
|
1401
|
+
this.space(d?.get('ColorSpace'), { ...where, what: 'a shading' });
|
|
1402
|
+
}
|
|
1403
|
+
/**
|
|
1404
|
+
* A graphics state: no transfer functions, halftones PDF/X allows, its
|
|
1405
|
+
* rendering intent, before X-4 no transparency and in X-4 the PDF
|
|
1406
|
+
* Reference’s blend modes; and its overprint, into the content’s state.
|
|
1407
|
+
*/
|
|
1408
|
+
extGState(obj, where, state) {
|
|
1409
|
+
const gs = this.pdf.dict(obj);
|
|
1410
|
+
if (!gs)
|
|
1411
|
+
return;
|
|
1412
|
+
if (state) {
|
|
1413
|
+
const flag = (k) => this.pdf.resolve(gs.get(k));
|
|
1414
|
+
const OP = flag('OP');
|
|
1415
|
+
const op = flag('op');
|
|
1416
|
+
if (typeof OP === 'boolean') {
|
|
1417
|
+
state.OP = OP;
|
|
1418
|
+
if (!gs.has('op'))
|
|
1419
|
+
state.op = OP;
|
|
1420
|
+
}
|
|
1421
|
+
if (typeof op === 'boolean')
|
|
1422
|
+
state.op = op;
|
|
1423
|
+
const opm = flag('OPM');
|
|
1424
|
+
if (typeof opm === 'number')
|
|
1425
|
+
state.opm = opm;
|
|
1426
|
+
}
|
|
1427
|
+
if (this.once(gs))
|
|
1428
|
+
return;
|
|
1429
|
+
const tr = this.pdf.resolve(gs.get('TR'));
|
|
1430
|
+
if (gs.has('TR'))
|
|
1431
|
+
this.violation('PDFX-TRANSFER', `${where.what} sets a transfer function (/TR ${describe(tr)})`, where.page);
|
|
1432
|
+
const tr2 = this.pdf.resolve(gs.get('TR2'));
|
|
1433
|
+
if (gs.has('TR2') && !(this.x4 && tr2 === 'Default'))
|
|
1434
|
+
this.violation('PDFX-TRANSFER', `${where.what} sets a transfer function (/TR2 ${describe(tr2)})`, where.page);
|
|
1435
|
+
this.halftone(gs.get('HT'), where);
|
|
1436
|
+
if (gs.has('HTP'))
|
|
1437
|
+
this.violation('PDFX-HALFTONE', `${where.what} sets a halftone phase (/HTP)`, where.page);
|
|
1438
|
+
if (gs.has('RI'))
|
|
1439
|
+
this.intentName(gs.get('RI'), `${where.what}’s /RI`, where);
|
|
1440
|
+
const bm = this.pdf.resolve(gs.get('BM'));
|
|
1441
|
+
const modes = (Array.isArray(bm) ? bm.map((m) => this.pdf.resolve(m)) : [bm]).filter((m) => m !== null);
|
|
1442
|
+
if (this.x4) {
|
|
1443
|
+
for (const m of modes)
|
|
1444
|
+
if (typeof m !== 'string' || !BLEND_MODES.has(m))
|
|
1445
|
+
this.violation('PDFX-TRANSPARENCY', `${where.what} sets the blend mode ${describe(m)}, which the PDF Reference doesn’t define`, where.page);
|
|
1446
|
+
}
|
|
1447
|
+
else {
|
|
1448
|
+
const smask = this.pdf.resolve(gs.get('SMask'));
|
|
1449
|
+
if (smask !== null && smask !== 'None')
|
|
1450
|
+
this.violation('PDFX-TRANSPARENCY', `${where.what} sets a soft mask (/SMask)`, where.page);
|
|
1451
|
+
for (const key of ['CA', 'ca']) {
|
|
1452
|
+
const alpha = this.pdf.resolve(gs.get(key));
|
|
1453
|
+
if (typeof alpha === 'number' && alpha !== 1)
|
|
1454
|
+
this.violation('PDFX-TRANSPARENCY', `${where.what} sets an alpha (/${key} ${alpha})`, where.page);
|
|
1455
|
+
}
|
|
1456
|
+
if (modes.length && !modes.some((m) => m === 'Normal' || m === 'Compatible'))
|
|
1457
|
+
this.violation('PDFX-TRANSPARENCY', `${where.what} sets the blend mode ${modes.map(describe).join(', ')}`, where.page);
|
|
1458
|
+
}
|
|
1459
|
+
const mask = this.pdf.dict(gs.get('SMask'));
|
|
1460
|
+
const g = this.pdf.stream(mask?.get('G'));
|
|
1461
|
+
if (!this.once(g) && g)
|
|
1462
|
+
this.form(g, { ...where, what: 'a soft mask' });
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* A halftone of type 1 or 5 (the latter’s components each one too), with
|
|
1466
|
+
* no /HalftoneName, and a /TransferFunction only in a type 5 halftone’s
|
|
1467
|
+
* component for a colorant other than the primaries, where the PDF
|
|
1468
|
+
* Reference requires one.
|
|
1469
|
+
*/
|
|
1470
|
+
halftone(obj, where, component, depth = 0) {
|
|
1471
|
+
const v = this.pdf.resolve(obj);
|
|
1472
|
+
const d = v instanceof PdfStream ? v.dict : v instanceof PdfDict ? v : undefined;
|
|
1473
|
+
if (!d || depth > 4)
|
|
1474
|
+
return;
|
|
1475
|
+
const type = this.pdf.resolve(d.get('HalftoneType'));
|
|
1476
|
+
if (type !== 1 && type !== 5)
|
|
1477
|
+
this.violation('PDFX-HALFTONE', `${where.what} uses a halftone of type ${String(type)}, not 1 or 5`, where.page);
|
|
1478
|
+
if (d.has('HalftoneName'))
|
|
1479
|
+
this.violation('PDFX-HALFTONE', `${where.what} uses a halftone with a /HalftoneName`, where.page);
|
|
1480
|
+
if (d.has('TransferFunction') && (component === undefined || PRIMARY.has(component)))
|
|
1481
|
+
this.violation('PDFX-HALFTONE', `${where.what} uses a halftone with a /TransferFunction${component ? ` for /${component}, a primary` : ''}, which the PDF Reference doesn’t require`, where.page);
|
|
1482
|
+
if (type === 5)
|
|
1483
|
+
for (const [k, sub] of d)
|
|
1484
|
+
if (k !== 'Type' && k !== 'HalftoneType' && k !== 'HalftoneName')
|
|
1485
|
+
this.halftone(sub, where, k, depth + 1);
|
|
1486
|
+
}
|
|
1487
|
+
/** A font text is shown in must be embedded; a Type 3 font’s glyphs are content, checked as such. */
|
|
1488
|
+
font(obj, where) {
|
|
1489
|
+
const font = this.pdf.dict(obj);
|
|
1490
|
+
if (this.once(font) || !font)
|
|
1491
|
+
return;
|
|
1492
|
+
const subtype = this.pdf.resolve(font.get('Subtype'));
|
|
1493
|
+
if (subtype === 'Type3') {
|
|
1494
|
+
const glyphs = { ...where, resources: this.pdf.dict(font.get('Resources')) ?? where.resources, what: 'a Type 3 glyph' };
|
|
1495
|
+
for (const g of this.pdf.dict(font.get('CharProcs'))?.values() ?? []) {
|
|
1496
|
+
const s = this.pdf.stream(g);
|
|
1497
|
+
if (s && !this.once(s))
|
|
1498
|
+
try {
|
|
1499
|
+
this.content(this.pdf.decode(s), glyphs);
|
|
1500
|
+
}
|
|
1501
|
+
catch (e) {
|
|
1502
|
+
this.unreadable(e, glyphs);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
const descendant = subtype === 'Type0' ? this.pdf.dict(this.pdf.array(font.get('DescendantFonts'))?.[0]) : font;
|
|
1508
|
+
const descriptor = this.pdf.dict(descendant?.get('FontDescriptor'));
|
|
1509
|
+
const name = this.pdf.resolve(font.get('BaseFont'));
|
|
1510
|
+
for (const n of [name, this.pdf.resolve(descendant?.get('BaseFont')), this.pdf.resolve(descriptor?.get('FontName'))])
|
|
1511
|
+
if (typeof n === 'string')
|
|
1512
|
+
this.name(n, 'font', where);
|
|
1513
|
+
const program = ['FontFile', 'FontFile2', 'FontFile3'].map((k) => this.pdf.stream(descriptor?.get(k))).find((s) => s);
|
|
1514
|
+
if (!program)
|
|
1515
|
+
this.violation('PDFX-FONT-EMBEDDED', `the font ${typeof name === 'string' ? `/${name}` : '(unnamed)'} is not embedded`, where.page);
|
|
1516
|
+
if (this.x4 && subtype === 'TrueType')
|
|
1517
|
+
this.trueTypeEncoding(font, descriptor, where);
|
|
1518
|
+
}
|
|
1519
|
+
/** PDF/X-4: a simple TrueType font’s encoding, by whether it is symbolic (6.5.4). */
|
|
1520
|
+
trueTypeEncoding(font, descriptor, where) {
|
|
1521
|
+
const flags = this.pdf.resolve(descriptor?.get('Flags'));
|
|
1522
|
+
const symbolic = typeof flags === 'number' && (flags & 4) !== 0;
|
|
1523
|
+
const encoding = this.pdf.resolve(font.get('Encoding'));
|
|
1524
|
+
const name = describe(this.pdf.resolve(font.get('BaseFont')));
|
|
1525
|
+
const standard = (e) => e === 'MacRomanEncoding' || e === 'WinAnsiEncoding';
|
|
1526
|
+
if (symbolic) {
|
|
1527
|
+
if (encoding !== null)
|
|
1528
|
+
this.violation('PDFX-TRUETYPE-ENCODING', `the symbolic TrueType font ${name} has an /Encoding`, where.page);
|
|
1529
|
+
const program = this.pdf.stream(descriptor?.get('FontFile2'));
|
|
1530
|
+
if (!program)
|
|
1531
|
+
return;
|
|
1532
|
+
let tables;
|
|
1533
|
+
try {
|
|
1534
|
+
tables = cmapTables(this.pdf.decode(program));
|
|
1535
|
+
}
|
|
1536
|
+
catch {
|
|
1537
|
+
tables = undefined;
|
|
1538
|
+
}
|
|
1539
|
+
if (tables === undefined)
|
|
1540
|
+
this.notice('PDFX-TRUETYPE-ENCODING', `the symbolic TrueType font ${name}’s cmap table could not be read, so it was not checked`, where.page);
|
|
1541
|
+
else if (tables !== 1)
|
|
1542
|
+
this.violation('PDFX-TRUETYPE-ENCODING', `the symbolic TrueType font ${name}’s cmap table has ${tables} subtables, not one`, where.page);
|
|
1543
|
+
}
|
|
1544
|
+
else if (encoding instanceof PdfDict) {
|
|
1545
|
+
if (!standard(this.pdf.resolve(encoding.get('BaseEncoding'))))
|
|
1546
|
+
this.violation('PDFX-TRUETYPE-ENCODING', `the TrueType font ${name}’s /BaseEncoding is not /MacRomanEncoding or /WinAnsiEncoding`, where.page);
|
|
1547
|
+
if (encoding.has('Differences'))
|
|
1548
|
+
this.violation('PDFX-TRUETYPE-ENCODING', `the TrueType font ${name}’s encoding has /Differences`, where.page);
|
|
1549
|
+
}
|
|
1550
|
+
else if (!standard(encoding))
|
|
1551
|
+
this.violation('PDFX-TRUETYPE-ENCODING', `the TrueType font ${name}’s /Encoding is ${describe(encoding)}, not /MacRomanEncoding or /WinAnsiEncoding`, where.page);
|
|
1552
|
+
}
|
|
1553
|
+
/** PDF/X-4: no text shows .notdef, where the font dictionary shows which codes are it (6.5.2). */
|
|
1554
|
+
notdef(obj, strings, where) {
|
|
1555
|
+
const font = this.pdf.dict(obj);
|
|
1556
|
+
if (!font || !strings.length)
|
|
1557
|
+
return;
|
|
1558
|
+
const subtype = this.pdf.resolve(font.get('Subtype'));
|
|
1559
|
+
const name = describe(this.pdf.resolve(font.get('BaseFont')));
|
|
1560
|
+
if (subtype === 'Type0') {
|
|
1561
|
+
const encoding = this.pdf.resolve(font.get('Encoding'));
|
|
1562
|
+
if (encoding !== 'Identity-H' && encoding !== 'Identity-V')
|
|
1563
|
+
return;
|
|
1564
|
+
const cid = this.pdf.dict(this.pdf.array(font.get('DescendantFonts'))?.[0]);
|
|
1565
|
+
const map = this.pdf.resolve(cid?.get('CIDToGIDMap'));
|
|
1566
|
+
const cff = this.pdf.resolve(cid?.get('Subtype')) === 'CIDFontType0';
|
|
1567
|
+
if (!cff && map !== null && map !== 'Identity')
|
|
1568
|
+
return;
|
|
1569
|
+
for (const s of strings)
|
|
1570
|
+
for (let i = 0; i + 1 < s.bytes.length; i += 2)
|
|
1571
|
+
if (s.bytes[i] === 0 && s.bytes[i + 1] === 0)
|
|
1572
|
+
return this.violation('PDFX-NOTDEF', `text in the font ${name} shows .notdef (code 0)`, where.page);
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1575
|
+
const encoding = this.pdf.dict(font.get('Encoding'));
|
|
1576
|
+
const differences = this.pdf.array(encoding?.get('Differences'));
|
|
1577
|
+
if (!differences)
|
|
1578
|
+
return;
|
|
1579
|
+
const notdef = new Set();
|
|
1580
|
+
let code = 0;
|
|
1581
|
+
for (const d of differences) {
|
|
1582
|
+
const v = this.pdf.resolve(d);
|
|
1583
|
+
if (typeof v === 'number')
|
|
1584
|
+
code = v;
|
|
1585
|
+
else if (typeof v === 'string') {
|
|
1586
|
+
if (v === '.notdef')
|
|
1587
|
+
notdef.add(code);
|
|
1588
|
+
code++;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
for (const s of strings)
|
|
1592
|
+
for (const b of s.bytes)
|
|
1593
|
+
if (notdef.has(b))
|
|
1594
|
+
return this.violation('PDFX-NOTDEF', `text in the font ${name} shows .notdef (code ${b}, by its /Differences)`, where.page);
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
* What only a walk over every object finds: file specifications (none
|
|
1598
|
+
* before X-4, embedded in X-4), action dictionaries anywhere.
|
|
1599
|
+
*/
|
|
1600
|
+
everyObject() {
|
|
1601
|
+
const seen = new Set();
|
|
1602
|
+
const walk = (v, depth) => {
|
|
1603
|
+
if (depth > 64 || v === null || typeof v !== 'object' || v instanceof PdfRef || v instanceof PdfString || seen.has(v))
|
|
1604
|
+
return;
|
|
1605
|
+
seen.add(v);
|
|
1606
|
+
if (Array.isArray(v))
|
|
1607
|
+
return v.forEach((x) => walk(x, depth + 1));
|
|
1608
|
+
const d = v instanceof PdfStream ? v.dict : v;
|
|
1609
|
+
const type = this.pdf.resolve(d.get('Type'));
|
|
1610
|
+
if (type === 'Filespec' || d.has('EF')) {
|
|
1611
|
+
if (!this.x4)
|
|
1612
|
+
this.violation('PDFX-FILES', 'the file has a file specification');
|
|
1613
|
+
else if (!d.has('EF'))
|
|
1614
|
+
this.violation('PDFX-FILES', 'a file specification doesn’t embed its file (/EF)');
|
|
1615
|
+
}
|
|
1616
|
+
if (type === 'Action')
|
|
1617
|
+
this.violation('PDFX-ACTIONS', 'the file has an action dictionary');
|
|
1618
|
+
if (v instanceof PdfStream && d.has('F'))
|
|
1619
|
+
this.violation('PDFX-FILES', 'a stream has its data in an external file');
|
|
1620
|
+
for (const x of d.values())
|
|
1621
|
+
walk(x, depth + 1);
|
|
1622
|
+
};
|
|
1623
|
+
for (const [, v] of this.pdf.objects())
|
|
1624
|
+
walk(v, 0);
|
|
1625
|
+
}
|
|
1626
|
+
/** PDF/X-4: the PDF Reference’s architectural limits (Table C.1, 6.25), from how objects and content were written. */
|
|
1627
|
+
limits() {
|
|
1628
|
+
for (const lexical of [this.pdf.lexical, this.lexical]) {
|
|
1629
|
+
for (const n of lexical.outOfRange)
|
|
1630
|
+
this.violation('PDFX-LIMITS', `the number ${n} is beyond the PDF Reference’s limits`);
|
|
1631
|
+
for (const n of lexical.longNames)
|
|
1632
|
+
this.violation('PDFX-LIMITS', `a name of ${n.length} bytes is longer than 127`);
|
|
1633
|
+
}
|
|
1634
|
+
if (this.lexical.longestString > 32767)
|
|
1635
|
+
this.violation('PDFX-LIMITS', `a content stream has a string of ${this.lexical.longestString} bytes, more than 32,767`);
|
|
1636
|
+
if (this.pdf.maxObject > 8388607)
|
|
1637
|
+
this.violation('PDFX-LIMITS', `the file has object ${this.pdf.maxObject}, beyond 8,388,607`);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
/** A rectangle with its corners in order, as PDF allows them either way round. */
|
|
1641
|
+
function rect(a) {
|
|
1642
|
+
if (a?.length !== 4 || !a.every((n) => typeof n === 'number'))
|
|
1643
|
+
return undefined;
|
|
1644
|
+
const [x0, y0, x1, y1] = a;
|
|
1645
|
+
return [Math.min(x0, x1), Math.min(y0, y1), Math.max(x0, x1), Math.max(y0, y1)];
|
|
1646
|
+
}
|
|
1647
|
+
function within(r, outer) {
|
|
1648
|
+
return r[0] >= outer[0] - EPSILON && r[1] >= outer[1] - EPSILON && r[2] <= outer[2] + EPSILON && r[3] <= outer[3] + EPSILON;
|
|
1649
|
+
}
|
|
1650
|
+
/** Whether two rectangles share some area, not just an edge. */
|
|
1651
|
+
function overlaps(a, b) {
|
|
1652
|
+
return a[0] < b[2] - EPSILON && b[0] < a[2] - EPSILON && a[1] < b[3] - EPSILON && b[1] < a[3] - EPSILON;
|
|
1653
|
+
}
|
|
1654
|
+
const show = (r) => `[${r.join(' ')}]`;
|
|
1655
|
+
/** An object as a message shows it. */
|
|
1656
|
+
function describe(v) {
|
|
1657
|
+
if (v === null || v === undefined)
|
|
1658
|
+
return 'missing';
|
|
1659
|
+
if (typeof v === 'string')
|
|
1660
|
+
return `/${v}`;
|
|
1661
|
+
if (v instanceof PdfString)
|
|
1662
|
+
return `(${v.text})`;
|
|
1663
|
+
return typeof v === 'object' ? 'not a name' : String(v);
|
|
1664
|
+
}
|
|
1665
|
+
/** A name as PDF writes it, its bytes outside ! to ~ escaped. */
|
|
1666
|
+
function escapeName(name) {
|
|
1667
|
+
return [...name].map((c) => (c.charCodeAt(0) < 33 || c.charCodeAt(0) > 126 || c === '#' ? `#${c.charCodeAt(0).toString(16).padStart(2, '0')}` : c)).join('');
|
|
1668
|
+
}
|
|
1669
|
+
/** A stream dictionary without its last filter, JPXDecode, so that decoding stops at the JPX data. */
|
|
1670
|
+
function withoutJpx(dict) {
|
|
1671
|
+
const d = new PdfDict(dict);
|
|
1672
|
+
const f = d.get('Filter');
|
|
1673
|
+
const p = d.get('DecodeParms');
|
|
1674
|
+
if (Array.isArray(f)) {
|
|
1675
|
+
d.set('Filter', f.slice(0, -1));
|
|
1676
|
+
if (Array.isArray(p))
|
|
1677
|
+
d.set('DecodeParms', p.slice(0, -1));
|
|
1678
|
+
}
|
|
1679
|
+
else {
|
|
1680
|
+
d.delete('Filter');
|
|
1681
|
+
d.delete('DecodeParms');
|
|
1682
|
+
}
|
|
1683
|
+
return d;
|
|
1684
|
+
}
|
|
1685
|
+
/** What PDF/X-4 (6.27) finds wrong with JPEG 2000 data: its file format, channels, colour specifications and depths. */
|
|
1686
|
+
export function jpxProblems(data) {
|
|
1687
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
1688
|
+
const u32 = (at) => (at + 4 <= data.length ? view.getUint32(at) : 0);
|
|
1689
|
+
const tag = (at) => String.fromCharCode(...data.subarray(at + 4, at + 8));
|
|
1690
|
+
// The JP2 signature box: length 12, type jP␠␠, then 0D 0A 87 0A.
|
|
1691
|
+
if (u32(0) !== 12 || tag(0) !== 'jP ' || u32(8) !== 0x0d0a870a)
|
|
1692
|
+
return ['as a bare codestream, not a JPX file'];
|
|
1693
|
+
/** The boxes in data[from, to): their types and where their contents are. */
|
|
1694
|
+
const boxes = (from, to) => {
|
|
1695
|
+
const out = [];
|
|
1696
|
+
for (let at = from; at + 8 <= to;) {
|
|
1697
|
+
let length = u32(at);
|
|
1698
|
+
let header = 8;
|
|
1699
|
+
if (length === 1) {
|
|
1700
|
+
length = Number(view.getBigUint64(at + 8));
|
|
1701
|
+
header = 16;
|
|
1702
|
+
}
|
|
1703
|
+
else if (length === 0)
|
|
1704
|
+
length = to - at;
|
|
1705
|
+
if (length < header)
|
|
1706
|
+
break;
|
|
1707
|
+
out.push({ type: tag(at), start: at + header, end: Math.min(at + length, to) });
|
|
1708
|
+
at += length;
|
|
1709
|
+
}
|
|
1710
|
+
return out;
|
|
1711
|
+
};
|
|
1712
|
+
const header = boxes(0, data.length).find((b) => b.type === 'jp2h');
|
|
1713
|
+
if (!header)
|
|
1714
|
+
return ['without a JP2 header box'];
|
|
1715
|
+
const inner = boxes(header.start, header.end);
|
|
1716
|
+
const problems = [];
|
|
1717
|
+
const ihdr = inner.find((b) => b.type === 'ihdr');
|
|
1718
|
+
if (!ihdr)
|
|
1719
|
+
return ['without an image header box'];
|
|
1720
|
+
const channels = view.getUint16(ihdr.start + 8);
|
|
1721
|
+
if (![1, 3, 4].includes(channels))
|
|
1722
|
+
problems.push(`with ${channels} channels, not 1, 3 or 4`);
|
|
1723
|
+
const bpc = data[ihdr.start + 10];
|
|
1724
|
+
const depths = bpc === 255
|
|
1725
|
+
? [...data.subarray((inner.find((b) => b.type === 'bpcc')?.start ?? 0), inner.find((b) => b.type === 'bpcc')?.end ?? 0)].map((b) => (b & 0x7f) + 1)
|
|
1726
|
+
: [(bpc & 0x7f) + 1];
|
|
1727
|
+
if (new Set(depths).size > 1)
|
|
1728
|
+
problems.push(`with channels of different depths (${[...new Set(depths)].join(', ')} bits)`);
|
|
1729
|
+
else if (depths.length && ![1, 8, 16].includes(depths[0]))
|
|
1730
|
+
problems.push(`${depths[0]} bits deep, not 1, 8 or 16`);
|
|
1731
|
+
const colours = inner.filter((b) => b.type === 'colr');
|
|
1732
|
+
if (colours.length > 1)
|
|
1733
|
+
problems.push(`with ${colours.length} colour specifications, not one`);
|
|
1734
|
+
for (const c of colours)
|
|
1735
|
+
if (data[c.start] === 1 && u32(c.start + 3) === 19)
|
|
1736
|
+
problems.push('in the enumerated colour space 19 (CIEJab)');
|
|
1737
|
+
return problems;
|
|
1738
|
+
}
|
|
1739
|
+
/** The number of subtables in a TrueType program’s cmap table, or undefined without one. */
|
|
1740
|
+
export function cmapTables(font) {
|
|
1741
|
+
const view = new DataView(font.buffer, font.byteOffset, font.byteLength);
|
|
1742
|
+
const tables = view.getUint16(4);
|
|
1743
|
+
for (let i = 0; i < tables; i++) {
|
|
1744
|
+
const record = 12 + 16 * i;
|
|
1745
|
+
if (String.fromCharCode(...font.subarray(record, record + 4)) === 'cmap')
|
|
1746
|
+
return view.getUint16(view.getUint32(record + 8) + 2);
|
|
1747
|
+
}
|
|
1748
|
+
return undefined;
|
|
1749
|
+
}
|
|
1750
|
+
/** How many items an XMP array property has. */
|
|
1751
|
+
function xmpItems(xmp, ns, name) {
|
|
1752
|
+
for (const m of xmp.matchAll(/xmlns:([\w.-]+)\s*=\s*(["'])(.*?)\2/g)) {
|
|
1753
|
+
if (m[3] !== ns)
|
|
1754
|
+
continue;
|
|
1755
|
+
const el = new RegExp(`<${m[1]}:${name}(?:\\s[^>]*)?>([\\s\\S]*?)</${m[1]}:${name}\\s*>`).exec(xmp);
|
|
1756
|
+
if (el)
|
|
1757
|
+
return [...el[1].matchAll(/<(?:[\w.-]+:)?li[\s>/]/g)].length;
|
|
1758
|
+
}
|
|
1759
|
+
return 0;
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Whether a PDF date (`D:YYYYMMDDHHmmSSOHH'mm'`) and an XMP date
|
|
1763
|
+
* (ISO 8601) are the same: the same components, the same in UTC.
|
|
1764
|
+
*/
|
|
1765
|
+
export function sameDate(pdf, xmp) {
|
|
1766
|
+
const p = /^(?:D:)?(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?(?:([Zz+-])(?:(\d{2})'?(?:(\d{2})'?)?)?)?$/.exec(pdf);
|
|
1767
|
+
const x = /^(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?([Zz]|[+-]\d{2}:\d{2})?)?)?)?$/.exec(xmp);
|
|
1768
|
+
if (!p || !x)
|
|
1769
|
+
return false;
|
|
1770
|
+
const parts = (m) => m.slice(1, 7).filter((v) => v !== undefined).length;
|
|
1771
|
+
if (parts(p) !== parts(x))
|
|
1772
|
+
return false;
|
|
1773
|
+
const offset = (sign, h = '0', m = '0') => (!sign || sign === 'Z' || sign === 'z' ? 0 : (sign === '-' ? -1 : 1) * (Number(h) * 60 + Number(m)));
|
|
1774
|
+
const utc = (m, minutes) => Date.UTC(Number(m[1]), Number(m[2] ?? 1) - 1, Number(m[3] ?? 1), Number(m[4] ?? 0), Number(m[5] ?? 0) - minutes, Number(m[6] ?? 0));
|
|
1775
|
+
const xz = x[7];
|
|
1776
|
+
const xOffset = !xz || xz === 'Z' || xz === 'z' ? 0 : offset(xz[0], xz.slice(1, 3), xz.slice(4, 6));
|
|
1777
|
+
return utc(p, offset(p[7], p[8], p[9])) === utc(x, xOffset);
|
|
1778
|
+
}
|
|
1779
|
+
//# sourceMappingURL=pdfx.js.map
|