@awacloud/pdf 0.0.0-stage → 1.0.0
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/CHANGELOG.md +609 -0
- package/LICENSE +661 -0
- package/NOTICE +77 -0
- package/README.md +363 -2
- package/dist/build/index.js +21 -0
- package/dist/build/pdf-full-rw.js +10972 -0
- package/dist/build/pdf-full-rw.meta.json +105 -0
- package/dist/build/pdf-full-rw.min.js +53 -0
- package/dist/build/pdf-full.js +6078 -0
- package/dist/build/pdf-full.meta.json +90 -0
- package/dist/build/pdf-full.min.js +32 -0
- package/dist/build/pdf-large-rw.js +10367 -0
- package/dist/build/pdf-large-rw.meta.json +99 -0
- package/dist/build/pdf-large-rw.min.js +53 -0
- package/dist/build/pdf-large.js +5473 -0
- package/dist/build/pdf-large.meta.json +84 -0
- package/dist/build/pdf-large.min.js +32 -0
- package/dist/build/pdf-legacy-rw.js +12402 -0
- package/dist/build/pdf-legacy-rw.meta.json +110 -0
- package/dist/build/pdf-legacy-rw.min.js +53 -0
- package/dist/build/pdf-legacy.js +7508 -0
- package/dist/build/pdf-legacy.meta.json +95 -0
- package/dist/build/pdf-legacy.min.js +32 -0
- package/dist/build/pdf-rw.js +7578 -0
- package/dist/build/pdf-rw.meta.json +77 -0
- package/dist/build/pdf-rw.min.js +53 -0
- package/dist/build/pdf.js +2684 -0
- package/dist/build/pdf.meta.json +62 -0
- package/dist/build/pdf.min.js +32 -0
- package/dist/standalone/pdf-full-rw.js +16798 -0
- package/dist/standalone/pdf-full-rw.meta.json +78 -0
- package/dist/standalone/pdf-full-rw.min.js +56 -0
- package/dist/standalone/pdf-full.js +11904 -0
- package/dist/standalone/pdf-full.meta.json +63 -0
- package/dist/standalone/pdf-full.min.js +35 -0
- package/dist/standalone/pdf-large-rw.js +16193 -0
- package/dist/standalone/pdf-large-rw.meta.json +72 -0
- package/dist/standalone/pdf-large-rw.min.js +56 -0
- package/dist/standalone/pdf-large.js +11299 -0
- package/dist/standalone/pdf-large.meta.json +57 -0
- package/dist/standalone/pdf-large.min.js +35 -0
- package/dist/standalone/pdf-legacy-rw.js +18228 -0
- package/dist/standalone/pdf-legacy-rw.meta.json +83 -0
- package/dist/standalone/pdf-legacy-rw.min.js +56 -0
- package/dist/standalone/pdf-legacy.js +13334 -0
- package/dist/standalone/pdf-legacy.meta.json +68 -0
- package/dist/standalone/pdf-legacy.min.js +35 -0
- package/dist/standalone/pdf-rw.js +13404 -0
- package/dist/standalone/pdf-rw.meta.json +50 -0
- package/dist/standalone/pdf-rw.min.js +56 -0
- package/dist/standalone/pdf.js +8510 -0
- package/dist/standalone/pdf.meta.json +35 -0
- package/dist/standalone/pdf.min.js +35 -0
- package/docs/README.md +53 -0
- package/docs/api/README.md +38 -0
- package/docs/api/_shared/README.md +91 -0
- package/docs/api/action/README.md +29 -0
- package/docs/api/action/action.md +81 -0
- package/docs/api/action/goTo.md +66 -0
- package/docs/api/action/launch.md +58 -0
- package/docs/api/action/named.md +55 -0
- package/docs/api/action/uri.md +54 -0
- package/docs/api/annot/README.md +53 -0
- package/docs/api/annot/annot.md +114 -0
- package/docs/api/annot/fileAttach.md +53 -0
- package/docs/api/annot/freeText.md +68 -0
- package/docs/api/annot/ink.md +69 -0
- package/docs/api/annot/link.md +74 -0
- package/docs/api/annot/markup.md +83 -0
- package/docs/api/annot/popup.md +52 -0
- package/docs/api/annot/projection.md +56 -0
- package/docs/api/annot/redact.md +67 -0
- package/docs/api/annot/square.md +87 -0
- package/docs/api/annot/stamp.md +54 -0
- package/docs/api/annot/text.md +69 -0
- package/docs/api/annot/widget.md +69 -0
- package/docs/api/associatedFiles/README.md +9 -0
- package/docs/api/associatedFiles/associatedFiles.md +78 -0
- package/docs/api/bundles/README.md +68 -0
- package/docs/api/bundles/dist-matrix.md +165 -0
- package/docs/api/bundles/pdf-full.md +148 -0
- package/docs/api/bundles/pdf-large.md +144 -0
- package/docs/api/bundles/pdf-legacy.md +169 -0
- package/docs/api/content/README.md +29 -0
- package/docs/api/content/color.md +99 -0
- package/docs/api/content/graphics.md +114 -0
- package/docs/api/content/images.md +124 -0
- package/docs/api/content/ops.md +100 -0
- package/docs/api/content/stream.md +107 -0
- package/docs/api/content/text.md +98 -0
- package/docs/api/crypto/README.md +29 -0
- package/docs/api/crypto/aesGcm.md +72 -0
- package/docs/api/crypto/permissions.md +79 -0
- package/docs/api/crypto/security.md +98 -0
- package/docs/api/crypto/standardV4.md +104 -0
- package/docs/api/crypto/standardV5.md +84 -0
- package/docs/api/crypto/standardV6.md +93 -0
- package/docs/api/destination/README.md +9 -0
- package/docs/api/destination/destination.md +79 -0
- package/docs/api/document/README.md +29 -0
- package/docs/api/document/builder.md +281 -0
- package/docs/api/document/catalog.md +98 -0
- package/docs/api/document/document.md +187 -0
- package/docs/api/document/encryptedWriter.md +149 -0
- package/docs/api/document/incrementalWriter.md +148 -0
- package/docs/api/document/page.md +99 -0
- package/docs/api/document/pages.md +82 -0
- package/docs/api/document/resources.md +102 -0
- package/docs/api/document/writer.md +157 -0
- package/docs/api/document/xrefStreamWriter.md +122 -0
- package/docs/api/embedded/README.md +13 -0
- package/docs/api/embedded/collection.md +80 -0
- package/docs/api/embedded/embeddedFile.md +86 -0
- package/docs/api/embedded/fileSpec.md +87 -0
- package/docs/api/errors.md +110 -0
- package/docs/api/extra/3d-richmedia.md +76 -0
- package/docs/api/extra/README.md +99 -0
- package/docs/api/extra/annot-extended.md +71 -0
- package/docs/api/extra/associated-files.md +70 -0
- package/docs/api/extra/ccitt-fax-decoder.md +74 -0
- package/docs/api/extra/color-spaces-extended.md +72 -0
- package/docs/api/extra/content-ops-extended.md +82 -0
- package/docs/api/extra/document-parts.md +69 -0
- package/docs/api/extra/embedded-files-portfolio.md +87 -0
- package/docs/api/extra/font-cid-typed.md +77 -0
- package/docs/api/extra/font-color-tagging.md +76 -0
- package/docs/api/extra/form-actions-extended.md +75 -0
- package/docs/api/extra/info-dict-deprecated.md +72 -0
- package/docs/api/extra/jbig2-read.md +80 -0
- package/docs/api/extra/legacy-deprecated-annots.md +89 -0
- package/docs/api/extra/legacy-deprecated-filters.md +78 -0
- package/docs/api/extra/legacy-rc4-read.md +74 -0
- package/docs/api/extra/legacy-xfa-read.md +65 -0
- package/docs/api/extra/linearization-write.md +71 -0
- package/docs/api/extra/misc.md +93 -0
- package/docs/api/extra/optional-content-extended.md +83 -0
- package/docs/api/extra/pdf-a-output-intent.md +65 -0
- package/docs/api/extra/pdf-sandbox.md +76 -0
- package/docs/api/extra/pdf-ua-tagged.md +63 -0
- package/docs/api/extra/pdf-x-prepress.md +65 -0
- package/docs/api/extra/redaction-iso32005.md +65 -0
- package/docs/api/extra/shading-typed.md +73 -0
- package/docs/api/extra/sig-aes-gcm.md +69 -0
- package/docs/api/extra/sig-pades.md +103 -0
- package/docs/api/extra/tagged-pdf-typed.md +78 -0
- package/docs/api/extra/transparency-typed.md +74 -0
- package/docs/api/extra/well-tagged-pdf.md +61 -0
- package/docs/api/extra/xmp-extended.md +65 -0
- package/docs/api/font/README.md +25 -0
- package/docs/api/font/embed.md +157 -0
- package/docs/api/font/encoding.md +95 -0
- package/docs/api/font/font.md +97 -0
- package/docs/api/font/type3.md +89 -0
- package/docs/api/form/README.md +35 -0
- package/docs/api/form/acroform.md +88 -0
- package/docs/api/form/appearance.md +87 -0
- package/docs/api/form/button.md +97 -0
- package/docs/api/form/choice.md +96 -0
- package/docs/api/form/fieldTree.md +93 -0
- package/docs/api/form/signature.md +90 -0
- package/docs/api/form/text.md +88 -0
- package/docs/api/linearization/README.md +11 -0
- package/docs/api/linearization/linearization.md +81 -0
- package/docs/api/main.md +116 -0
- package/docs/api/metadata/README.md +10 -0
- package/docs/api/metadata/info.md +70 -0
- package/docs/api/metadata/xmp.md +62 -0
- package/docs/api/ocg/README.md +23 -0
- package/docs/api/ocg/config.md +95 -0
- package/docs/api/ocg/ocg.md +77 -0
- package/docs/api/outline/README.md +11 -0
- package/docs/api/outline/outline.md +107 -0
- package/docs/api/pdf.md +152 -0
- package/docs/api/prepress/README.md +10 -0
- package/docs/api/prepress/outputIntent.md +79 -0
- package/docs/api/prepress/pageBoundary.md +75 -0
- package/docs/api/sig/README.md +32 -0
- package/docs/api/sig/byteRange.md +120 -0
- package/docs/api/sig/certChain.md +84 -0
- package/docs/api/sig/dss.md +111 -0
- package/docs/api/sig/oids.md +76 -0
- package/docs/api/sig/sha1.md +72 -0
- package/docs/api/sig/sign.md +317 -0
- package/docs/api/sig/signature.md +178 -0
- package/docs/api/sig/timestamp.md +84 -0
- package/docs/api/syntax/README.md +29 -0
- package/docs/api/syntax/crossRefStream.md +115 -0
- package/docs/api/syntax/filters/README.md +50 -0
- package/docs/api/syntax/filters/ascii85.md +76 -0
- package/docs/api/syntax/filters/asciiHex.md +73 -0
- package/docs/api/syntax/filters/dispatch.md +125 -0
- package/docs/api/syntax/filters/flate.md +134 -0
- package/docs/api/syntax/filters/runLength.md +78 -0
- package/docs/api/syntax/objStream.md +88 -0
- package/docs/api/syntax/parser-obj.md +97 -0
- package/docs/api/syntax/parser.md +151 -0
- package/docs/api/syntax/serializer.md +109 -0
- package/docs/api/syntax/tokenizer.md +104 -0
- package/docs/api/syntax/trailer.md +85 -0
- package/docs/api/syntax/xref.md +139 -0
- package/docs/api/tagged/README.md +25 -0
- package/docs/api/tagged/classMap.md +67 -0
- package/docs/api/tagged/markedContent.md +62 -0
- package/docs/api/tagged/parentTree.md +67 -0
- package/docs/api/tagged/roleMap.md +67 -0
- package/docs/api/tagged/structElement.md +76 -0
- package/docs/api/tagged/structTree.md +75 -0
- package/docs/guide/coverage.md +113 -0
- package/docs/guide/crypto.md +121 -0
- package/docs/guide/extending.md +76 -0
- package/docs/guide/getting-started.md +75 -0
- package/docs/guide/legacy-1.7.md +42 -0
- package/docs/guide/pades-integration.md +579 -0
- package/docs/guide/read-pdf.md +89 -0
- package/package.json +97 -4
- package/src/_shared/index.js +179 -0
- package/src/action/action.js +119 -0
- package/src/action/goTo.js +89 -0
- package/src/action/launch.js +61 -0
- package/src/action/named.js +54 -0
- package/src/action/uri.js +51 -0
- package/src/annot/annot.js +212 -0
- package/src/annot/fileAttach.js +55 -0
- package/src/annot/freeText.js +82 -0
- package/src/annot/ink.js +77 -0
- package/src/annot/link.js +77 -0
- package/src/annot/markup.js +91 -0
- package/src/annot/popup.js +53 -0
- package/src/annot/projection.js +52 -0
- package/src/annot/redact.js +87 -0
- package/src/annot/square.js +132 -0
- package/src/annot/stamp.js +48 -0
- package/src/annot/text.js +54 -0
- package/src/annot/widget.js +61 -0
- package/src/associatedFiles/associatedFiles.js +86 -0
- package/src/bundles/pdf-full.js +91 -0
- package/src/bundles/pdf-large.js +81 -0
- package/src/bundles/pdf-legacy.js +107 -0
- package/src/content/color.js +114 -0
- package/src/content/graphics.js +192 -0
- package/src/content/images.js +160 -0
- package/src/content/ops.js +137 -0
- package/src/content/stream.js +154 -0
- package/src/content/text.js +125 -0
- package/src/crypto/aesGcm.js +123 -0
- package/src/crypto/permissions.js +112 -0
- package/src/crypto/security.js +327 -0
- package/src/crypto/standardV4.js +443 -0
- package/src/crypto/standardV5.js +306 -0
- package/src/crypto/standardV6.js +334 -0
- package/src/destination/destination.js +183 -0
- package/src/document/builder.js +618 -0
- package/src/document/catalog.js +100 -0
- package/src/document/document.js +472 -0
- package/src/document/encryptedWriter.js +554 -0
- package/src/document/incrementalWriter.js +514 -0
- package/src/document/page.js +131 -0
- package/src/document/pages.js +103 -0
- package/src/document/resources.js +146 -0
- package/src/document/writer.js +211 -0
- package/src/document/xrefStreamWriter.js +353 -0
- package/src/embedded/collection.js +102 -0
- package/src/embedded/embeddedFile.js +99 -0
- package/src/embedded/fileSpec.js +137 -0
- package/src/errors.js +78 -0
- package/src/extra/3d-richmedia.js +171 -0
- package/src/extra/annot-extended.js +200 -0
- package/src/extra/associated-files.js +131 -0
- package/src/extra/ccitt-fax-decoder.js +776 -0
- package/src/extra/color-spaces-extended.js +196 -0
- package/src/extra/content-ops-extended.js +153 -0
- package/src/extra/document-parts.js +149 -0
- package/src/extra/embedded-files-portfolio.js +234 -0
- package/src/extra/font-cid-typed.js +185 -0
- package/src/extra/font-color-tagging.js +144 -0
- package/src/extra/form-actions-extended.js +196 -0
- package/src/extra/info-dict-deprecated.js +137 -0
- package/src/extra/jbig2-read.js +169 -0
- package/src/extra/legacy-deprecated-annots.js +198 -0
- package/src/extra/legacy-deprecated-filters.js +167 -0
- package/src/extra/legacy-rc4-read.js +235 -0
- package/src/extra/legacy-xfa-read.js +104 -0
- package/src/extra/linearization-write.js +97 -0
- package/src/extra/misc.js +217 -0
- package/src/extra/optional-content-extended.js +142 -0
- package/src/extra/pdf-a-output-intent.js +112 -0
- package/src/extra/pdf-sandbox.js +88 -0
- package/src/extra/pdf-ua-tagged.js +116 -0
- package/src/extra/pdf-x-prepress.js +114 -0
- package/src/extra/redaction-iso32005.js +136 -0
- package/src/extra/shading-typed.js +222 -0
- package/src/extra/sig-aes-gcm.js +135 -0
- package/src/extra/sig-pades.js +242 -0
- package/src/extra/tagged-pdf-typed.js +203 -0
- package/src/extra/transparency-typed.js +135 -0
- package/src/extra/well-tagged-pdf.js +138 -0
- package/src/extra/xmp-extended.js +190 -0
- package/src/font/embed.js +480 -0
- package/src/font/encoding.js +92 -0
- package/src/font/font.js +101 -0
- package/src/font/type3.js +75 -0
- package/src/form/acroform.js +94 -0
- package/src/form/appearance.js +90 -0
- package/src/form/button.js +105 -0
- package/src/form/choice.js +152 -0
- package/src/form/fieldTree.js +120 -0
- package/src/form/signature.js +100 -0
- package/src/form/text.js +101 -0
- package/src/linearization/linearization.js +107 -0
- package/src/main.js +411 -0
- package/src/metadata/info.js +87 -0
- package/src/metadata/xmp.js +62 -0
- package/src/ocg/config.js +156 -0
- package/src/ocg/ocg.js +124 -0
- package/src/outline/outline.js +157 -0
- package/src/pdf.js +133 -0
- package/src/prepress/outputIntent.js +118 -0
- package/src/prepress/pageBoundary.js +108 -0
- package/src/sig/byteRange.js +306 -0
- package/src/sig/certChain.js +247 -0
- package/src/sig/dss.js +317 -0
- package/src/sig/oids.js +157 -0
- package/src/sig/sha1.js +142 -0
- package/src/sig/sign.js +1899 -0
- package/src/sig/signature.js +1441 -0
- package/src/sig/timestamp.js +236 -0
- package/src/syntax/crossRefStream.js +133 -0
- package/src/syntax/filters/ascii85.js +122 -0
- package/src/syntax/filters/asciiHex.js +83 -0
- package/src/syntax/filters/dispatch.js +176 -0
- package/src/syntax/filters/flate.js +316 -0
- package/src/syntax/filters/runLength.js +96 -0
- package/src/syntax/objStream.js +99 -0
- package/src/syntax/parser-obj.js +52 -0
- package/src/syntax/parser.js +321 -0
- package/src/syntax/serializer.js +221 -0
- package/src/syntax/tokenizer.js +290 -0
- package/src/syntax/trailer.js +76 -0
- package/src/syntax/xref.js +341 -0
- package/src/tagged/classMap.js +81 -0
- package/src/tagged/markedContent.js +123 -0
- package/src/tagged/parentTree.js +126 -0
- package/src/tagged/roleMap.js +107 -0
- package/src/tagged/structElement.js +138 -0
- package/src/tagged/structTree.js +94 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfLegacyRc4Read
|
|
3
|
+
category: pdf/extra
|
|
4
|
+
dependencies: [pdfErrors]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfLegacyRc4Read
|
|
11
|
+
|
|
12
|
+
> RC4 v2/v3 password validation + stream decrypt, read-only — legacy.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfLegacyRc4Read` | **Source** `packages/front/office/pdf/src/extra/legacy-rc4-read.js` | **Deps** `pdfErrors` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Implements the RC4 stream cipher locally plus the read side of the Standard Security Handler PDF 1.7 §7.6.3.3-4: 40-bit RC4 (revision 2, V=1) and 128-bit RC4 (revision 3, V=2), password validation against `/O`/`/U`, per-object key derivation (file-key ‖ objectId/MD5) for `/Encrypt V <= 2`. PDF 2.0 forbids RC4 on write; this module is intentionally read-only.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const ext = runtime.resolve('pdfLegacyRc4Read');
|
|
22
|
+
// Returns: { rc4, md5, padPassword, computeFileKey, computeU,
|
|
23
|
+
// validateUserPassword, objectKey, decryptString,
|
|
24
|
+
// decryptStream, PASSWORD_PADDING }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
| Member | Signature | Returns |
|
|
30
|
+
|--------|-----------|---------|
|
|
31
|
+
| `rc4` | `(key: Uint8Array, data: Uint8Array) => Uint8Array` | Stream cipher. |
|
|
32
|
+
| `md5` | `(bytes) => Uint8Array(16)` | Hash. |
|
|
33
|
+
| `padPassword` | `(password) => Uint8Array(32)` | §7.6.3.3 step 1. |
|
|
34
|
+
| `computeFileKey` | `(password, params: { O, P, idFirst, revision, keyLength, encryptMetadata }) => Uint8Array` | File-key derivation, §7.6.3.3 Algorithm 2. |
|
|
35
|
+
| `computeU` | `(fileKey, idFirst, revision) => Uint8Array` | Computes the `/U` value. |
|
|
36
|
+
| `validateUserPassword` | `(password, params: { O, P, idFirst, revision, keyLength, encryptMetadata, U }) => { ok: true, fileKey } \| { ok: false }` | |
|
|
37
|
+
| `objectKey` | `(fileKey, objNum, gen) => Uint8Array` | Per-object key. |
|
|
38
|
+
| `decryptString` / `decryptStream` | `(fileKey, objNum, gen, bytes) => Uint8Array` | |
|
|
39
|
+
| `PASSWORD_PADDING` | `Uint8Array(32)` | Padding constant, §7.6.3.3. |
|
|
40
|
+
|
|
41
|
+
## Examples
|
|
42
|
+
|
|
43
|
+
### Validate a password
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const ext = runtime.resolve('pdfLegacyRc4Read');
|
|
47
|
+
const r = ext.validateUserPassword('', {
|
|
48
|
+
O, P, idFirst, revision: 3, keyLength: 128, encryptMetadata: true, U
|
|
49
|
+
});
|
|
50
|
+
if (!r.ok) throw new Error('wrong password');
|
|
51
|
+
const fileKey = r.fileKey;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Decrypt a stream
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
const plain = ext.decryptStream(fileKey, 5, 0, encStreamBytes);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Errors
|
|
61
|
+
|
|
62
|
+
| Code | Class | When |
|
|
63
|
+
|------|-------|------|
|
|
64
|
+
| `pdf/rc4/bad-input` | `EncryptionError` | `rc4` arguments invalid. |
|
|
65
|
+
| `pdf/md5/bad-input` | `EncryptionError` | `md5` input is not a Uint8Array. |
|
|
66
|
+
| `pdf/rc4/bad-password` | `EncryptionError` | Password/pad input invalid. |
|
|
67
|
+
| `pdf/rc4/bad-O` | `EncryptionError` | `/O` invalid (must be a 32-byte Uint8Array). |
|
|
68
|
+
| `pdf/rc4/bad-id` | `EncryptionError` | `/ID` first element missing/invalid. |
|
|
69
|
+
|
|
70
|
+
## See also
|
|
71
|
+
|
|
72
|
+
- [`pdfStandardV5`](../crypto/standardV5.md)
|
|
73
|
+
- [`pdfSecurity`](../crypto/security.md)
|
|
74
|
+
- [Extras index](./README.md)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfLegacyXfaRead
|
|
3
|
+
category: pdf/extra
|
|
4
|
+
dependencies: [pdfErrors]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfLegacyXfaRead
|
|
11
|
+
|
|
12
|
+
> Opaque read-only reader for `/XFA` (XDP packets) — legacy.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfLegacyXfaRead` | **Source** `packages/front/office/pdf/src/extra/legacy-xfa-read.js` | **Deps** `pdfErrors` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
PDF 2.0 forbids writing XFA, but legacy documents must still be parsed. `/XFA` on the AcroForm dict comes in two shapes: (a) a single complete XDP stream, or (b) an array alternating string keys and streams (`['preamble', stream, 'config', stream, …]`). Surfaces the packets as opaque XML bytes on `_legacy.xfa` — no further interpretation.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const ext = runtime.resolve('pdfLegacyXfaRead');
|
|
22
|
+
// Returns: { readXfa, isKnownPacket, KNOWN_PACKETS }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Member | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `readXfa` | `(value) => { _legacy: { xfa: { shape, … } } }` | Stream or array shape. |
|
|
30
|
+
| `isKnownPacket` | `(name) => boolean` | |
|
|
31
|
+
| `KNOWN_PACKETS` | `Set` | `xdp`, `preamble`, `config`, `template`, `localeSet`, `datasets`, `form`, `connectionSet`, `sourceSet`, `stylesheet`, `xmpmeta`, `signature`, `postamble`, `pdf`. |
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
### Read a stream
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
const ext = runtime.resolve('pdfLegacyXfaRead');
|
|
39
|
+
const r = ext.readXfa(xfaStream);
|
|
40
|
+
r._legacy.xfa.shape; // 'stream'
|
|
41
|
+
r._legacy.xfa.xdp; // Uint8Array
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Read an array
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
const r = ext.readXfa(xfaArray);
|
|
48
|
+
r._legacy.xfa.packets.template; // Uint8Array
|
|
49
|
+
r._legacy.xfa.order; // ['preamble','template','datasets']
|
|
50
|
+
r._legacy.xfa.unknownPackets; // []
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Errors
|
|
54
|
+
|
|
55
|
+
| Code | Class | When |
|
|
56
|
+
|------|-------|------|
|
|
57
|
+
| `pdf/xfa/bad-packet` | `ParseError` | Array item is neither a string key nor a stream. |
|
|
58
|
+
| `pdf/xfa/bad-key` | `ParseError` | Array key decoding failed. |
|
|
59
|
+
| `pdf/xfa/odd-array` | `ParseError` | Odd item count (key/stream pairs expected). |
|
|
60
|
+
| `pdf/xfa/bad-shape` | `ParseError` | Neither a stream nor an array. |
|
|
61
|
+
|
|
62
|
+
## See also
|
|
63
|
+
|
|
64
|
+
- [`pdfAcroForm`](../form/acroform.md)
|
|
65
|
+
- [Extras index](./README.md)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfLinearizationWrite
|
|
3
|
+
category: pdf/extra
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfLinearizationWrite
|
|
11
|
+
|
|
12
|
+
> Linearization Parameter Dictionary emitter — Annex F (write-side stub).
|
|
13
|
+
|
|
14
|
+
**Module** `pdfLinearizationWrite` | **Source** `packages/front/office/pdf/src/extra/linearization-write.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Builds a `/Linearized` dict and a placeholder hint-stream for emission as the first indirect object of a linearized PDF (ISO 32000-2 Annex F). The full hint table (page-offset / shared-objects) remains future work — the stub is length-0 to keep the structural shape correct.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const ext = runtime.resolve('pdfLinearizationWrite');
|
|
22
|
+
// Returns: { buildLinearizedDict, buildHintStreamStub,
|
|
23
|
+
// validateLinearizedDict, LINEARIZED_KEYS }
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
| Member | Signature | Returns |
|
|
29
|
+
|--------|-----------|---------|
|
|
30
|
+
| `buildLinearizedDict` | `(params) => dictObj` | Typed `/Linearized` dict. |
|
|
31
|
+
| `buildHintStreamStub` | `() => streamObj` | Length-0 stub. |
|
|
32
|
+
| `validateLinearizedDict` | `(dict) => { pass, errors, warnings }` | Validates the Table F.1 shape. |
|
|
33
|
+
| `LINEARIZED_KEYS` | frozen array | `['Linearized','L','H','O','E','N','T']`. |
|
|
34
|
+
|
|
35
|
+
### Required `params`
|
|
36
|
+
|
|
37
|
+
`version` (defaults to 1.0), `fileLength`, `hintOffset`, `hintLength`, `firstPageObj`, `firstPageEnd`, `pageCount`, `mainXrefOffset`, and optionally `firstPage`.
|
|
38
|
+
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
### Build the dict
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
const ext = runtime.resolve('pdfLinearizationWrite');
|
|
45
|
+
const dict = ext.buildLinearizedDict({
|
|
46
|
+
version: 1.0, fileLength: 12345,
|
|
47
|
+
hintOffset: 678, hintLength: 200,
|
|
48
|
+
firstPageObj: 5, firstPageEnd: 4000,
|
|
49
|
+
pageCount: 10, mainXrefOffset: 12000
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Validate
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
ext.validateLinearizedDict(parsedDict).pass; // true
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Errors
|
|
60
|
+
|
|
61
|
+
| Code | Class | When |
|
|
62
|
+
|------|-------|------|
|
|
63
|
+
| `pdf/extra/linwrite/bad-params` | `RenderError` | `params` is not an object. |
|
|
64
|
+
| `pdf/extra/linwrite/missing-<key>` | `RenderError` | A required numeric parameter is absent (`fileLength`, `firstPageObj`, `firstPageEnd`, `pageCount`, `mainXrefOffset`). |
|
|
65
|
+
| `pdf/extra/linwrite/missing-hint` | `RenderError` | `hintOffset`/`hintLength` absent. |
|
|
66
|
+
| `pdf/extra/linwrite/validate/not-dict` | `RenderError` | `validateLinearizedDict` argument is not a dict. |
|
|
67
|
+
|
|
68
|
+
## See also
|
|
69
|
+
|
|
70
|
+
- [`pdfLinearization`](../linearization/linearization.md)
|
|
71
|
+
- [Extras index](./README.md)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfMisc
|
|
3
|
+
category: pdf/extra
|
|
4
|
+
dependencies: [pdfErrors]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfMisc
|
|
11
|
+
|
|
12
|
+
> Miscellaneous Catalog-level typing (SpiderInfo, Threads, Legal, …).
|
|
13
|
+
|
|
14
|
+
**Module** `pdfMisc` | **Source** `packages/front/office/pdf/src/extra/misc.js` | **Deps** `pdfErrors` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Long tail of Catalog entries that don't warrant their own L1 module:
|
|
17
|
+
- `/SpiderInfo` (§14.10.2) — Web-Capture provenance
|
|
18
|
+
- `/Threads` (§12.4.3) — articles
|
|
19
|
+
- `/Legal` (§12.8.5) — legal attestation
|
|
20
|
+
- `/Requirements` (§12.10)
|
|
21
|
+
- `/Perms` (§12.8.2) — DocMDP, UR3, UR
|
|
22
|
+
- `/NeedsRendering` — XFA indicator
|
|
23
|
+
|
|
24
|
+
## Resolve
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
const ext = runtime.resolve('pdfMisc');
|
|
28
|
+
// Returns: { typeSpiderInfo, typeThreads, typeLegal, typeRequirements,
|
|
29
|
+
// typeDocMdpParams, typePerms, typeNeedsRendering,
|
|
30
|
+
// REQUIREMENT_S_VALUES }
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
| Member | Signature | Returns |
|
|
36
|
+
|--------|-----------|---------|
|
|
37
|
+
| `typeSpiderInfo` | `(dict) => { version?, commands?, raw, _extras }` | §14.10.2. |
|
|
38
|
+
| `typeThreads` | `(array) => Array<dict\|ref>` | §12.4.3, entries left unresolved. |
|
|
39
|
+
| `typeLegal` | `(dict) => { raw, flags, attestation?, _extras }` | §12.8.5. |
|
|
40
|
+
| `typeRequirements` | `(array) => Array<{ raw, s, standard, rh }>` | §12.10. |
|
|
41
|
+
| `typeDocMdpParams` | `(dict) => { permission?, version?, raw, _extras }` | §12.8.2.2. |
|
|
42
|
+
| `typePerms` | `(dict) => { docMDP?, ur3?, ur?, raw, _extras }` | §12.8.2. |
|
|
43
|
+
| `typeNeedsRendering` | `(value) => boolean` | XFA indicator. |
|
|
44
|
+
| `REQUIREMENT_S_VALUES` | `Set` | `EnableJavaScripts`. |
|
|
45
|
+
|
|
46
|
+
## Examples
|
|
47
|
+
|
|
48
|
+
### SpiderInfo
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
const ext = runtime.resolve('pdfMisc');
|
|
52
|
+
const s = ext.typeSpiderInfo(catalog.spiderInfo);
|
|
53
|
+
s.version; // 1.0
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Threads
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
const ts = ext.typeThreads(catalog.threads);
|
|
60
|
+
ts.length;
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### NeedsRendering
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
ext.typeNeedsRendering({ type: 'bool', value: true }); // true
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Errors
|
|
70
|
+
|
|
71
|
+
| Code | Class | When |
|
|
72
|
+
|------|-------|------|
|
|
73
|
+
| `pdf/misc/spider-not-dict` | `ParseError` | SpiderInfo is not a dict. |
|
|
74
|
+
| `pdf/misc/spider-bad-V` | `ParseError` | `/V` is not numeric. |
|
|
75
|
+
| `pdf/misc/spider-bad-C` | `ParseError` | `/C` is not an array. |
|
|
76
|
+
| `pdf/misc/threads-not-array` | `ParseError` | `/Threads` is not an array. |
|
|
77
|
+
| `pdf/misc/thread-bad-entry` | `ParseError` | Entry is neither dict nor ref. |
|
|
78
|
+
| `pdf/misc/legal-not-dict` | `ParseError` | Legal is not a dict. |
|
|
79
|
+
| `pdf/misc/legal-bad-flag` | `ParseError` | A flag is not an int. |
|
|
80
|
+
| `pdf/misc/legal-bad-attestation` | `ParseError` | `/Attestation` is not a string. |
|
|
81
|
+
| `pdf/misc/req-not-array` | `ParseError` | Requirements is not an array. |
|
|
82
|
+
| `pdf/misc/req-bad-entry` | `ParseError` | Entry is not a dict. |
|
|
83
|
+
| `pdf/misc/req-missing-S` | `ParseError` | `/S` absent. |
|
|
84
|
+
| `pdf/misc/docmdp-not-dict` | `ParseError` | DocMDP is not a dict. |
|
|
85
|
+
| `pdf/misc/docmdp-bad-P` | `ParseError` | `/P` is not an int. |
|
|
86
|
+
| `pdf/misc/docmdp-bad-V` | `ParseError` | `/V` is not a name. |
|
|
87
|
+
| `pdf/misc/perms-not-dict` | `ParseError` | Perms is not a dict. |
|
|
88
|
+
| `pdf/misc/needsrendering-bad` | `ParseError` | Not a bool. |
|
|
89
|
+
|
|
90
|
+
## See also
|
|
91
|
+
|
|
92
|
+
- [`pdfCatalog`](../document/catalog.md)
|
|
93
|
+
- [Extras index](./README.md)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfOptionalContentExtended
|
|
3
|
+
category: pdf/extra
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfOptionalContentExtended
|
|
11
|
+
|
|
12
|
+
> Extended OCG/OCMD — VE (Visibility Expression), Order tree, RBGroups, Intent — ISO 32000-2 §8.11.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfOptionalContentExtended` | **Source** `packages/front/office/pdf/src/extra/optional-content-extended.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
§8.11.2.4 defines OCMD `/VE` (Visibility Expression) as a nested array `[op, operand, …]` with ops `And`, `Or`, `Not`. This module evaluates such expressions, types `/Order` (including sub-heading strings), and surfaces RBGroups and `/Intent` (View vs Design).
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const ext = runtime.resolve('pdfOptionalContentExtended');
|
|
22
|
+
// Returns: { evaluateVE, typeOrderTree, typeRBGroups,
|
|
23
|
+
// classifyOcgIntent, VE_OPERATORS }
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
| Member | Signature | Returns |
|
|
29
|
+
|--------|-----------|---------|
|
|
30
|
+
| `evaluateVE` | `(ve, onSet: Set<string>) => boolean` | Recursively evaluates; `onSet` holds `"num gen"` keys of "on" OCGs. |
|
|
31
|
+
| `typeOrderTree` | `(orderArray) => OrderNode[]` | Nodes shaped `{ kind: 'heading', text } \| { kind: 'group', children } \| { kind: 'ocg', ref } \| { kind: 'other', value }`. |
|
|
32
|
+
| `typeRBGroups` | `(arr) => Array<Array<{ num, gen }>>` | Mutually-exclusive radio-button groups. |
|
|
33
|
+
| `classifyOcgIntent` | `(value) => { view: boolean, design: boolean, names: string[] }` | |
|
|
34
|
+
| `VE_OPERATORS` | frozen array | `['And','Or','Not']`. |
|
|
35
|
+
|
|
36
|
+
## Examples
|
|
37
|
+
|
|
38
|
+
### Evaluate VE
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
const ext = runtime.resolve('pdfOptionalContentExtended');
|
|
42
|
+
const visible = ext.evaluateVE(
|
|
43
|
+
{ type: 'array', items: [
|
|
44
|
+
{ type: 'name', value: 'And' }, ocgRefA,
|
|
45
|
+
{ type: 'array', items: [{ type: 'name', value: 'Not' }, ocgRefB] }
|
|
46
|
+
] },
|
|
47
|
+
onSet
|
|
48
|
+
);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Order tree
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const tree = ext.typeOrderTree(orderArr);
|
|
55
|
+
// [ { kind: 'heading', text: 'Layer group' }, { kind: 'group', children: [...] }, … ]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Intent
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
ext.classifyOcgIntent({ type: 'name', value: 'View' });
|
|
62
|
+
// { view: true, design: false, names: ['View'] }
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Errors
|
|
66
|
+
|
|
67
|
+
| Code | Class | When |
|
|
68
|
+
|------|-------|------|
|
|
69
|
+
| `pdf/extra/ocgx/ve/null` | `ParseError` | VE expression is null. |
|
|
70
|
+
| `pdf/extra/ocgx/ve/bad-state` | `ParseError` | `onSet` is not a `Set`. |
|
|
71
|
+
| `pdf/extra/ocgx/ve/bad-shape` | `ParseError` | Neither an array nor a ref. |
|
|
72
|
+
| `pdf/extra/ocgx/ve/bad-op` | `ParseError` | Operator outside `VE_OPERATORS`. |
|
|
73
|
+
| `pdf/extra/ocgx/ve/not-arity` | `ParseError` | Wrong arity (`Not` = 1, `And`/`Or` ≥ 1). |
|
|
74
|
+
| `pdf/extra/ocgx/order/not-array` | `ParseError` | `/Order` is not an array. |
|
|
75
|
+
| `pdf/extra/ocgx/rbg/not-array` | `ParseError` | `/RBGroups` is not an array. |
|
|
76
|
+
| `pdf/extra/ocgx/rbg/bad-group` | `ParseError` | A group entry is not an array. |
|
|
77
|
+
| `pdf/extra/ocgx/intent/bad` | `ParseError` | Intent is neither a name nor an array. |
|
|
78
|
+
|
|
79
|
+
## See also
|
|
80
|
+
|
|
81
|
+
- [`pdfOCG`](../ocg/ocg.md)
|
|
82
|
+
- [`pdfOCConfig`](../ocg/config.md)
|
|
83
|
+
- [Extras index](./README.md)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfAOutputIntent
|
|
3
|
+
category: pdf/extra
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfAOutputIntent
|
|
11
|
+
|
|
12
|
+
> PDF/A detection (`/S /GTS_PDFA1`) and basic validation — ISO 19005-{1..4}.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfAOutputIntent` | **Source** `packages/front/office/pdf/src/extra/pdf-a-output-intent.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Recognizes an `/OutputIntent` whose `/S` is `GTS_PDFA1` (or later ISO 19005-2/3/4 profile names), extracts the conformance-level letter (a/b/u/e/f), and maps `/OutputConditionIdentifier` to a known registry profile.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const ext = runtime.resolve('pdfAOutputIntent');
|
|
22
|
+
// Returns: { detectPdfAProfile, validatePdfABasics, PDFA_PROFILES }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Member | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `detectPdfAProfile` | `(outputIntentDict) => { isPdfA, subtype, identifier, profile, part, level, catalog, raw }` | Detected profile fields (`part`/`level`/`catalog` are `null` when the identifier is unrecognized). |
|
|
30
|
+
| `validatePdfABasics` | `(typedDoc) => { pass, errors, warnings }` | Lints Catalog/Metadata basics. |
|
|
31
|
+
| `PDFA_PROFILES` | frozen catalog | `'1a'`, `'1b'`, `'2a'`, …, `'4f'` → `{ part, level, iso, notes }`. |
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
### Detect the profile
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
const ext = runtime.resolve('pdfAOutputIntent');
|
|
39
|
+
const p = ext.detectPdfAProfile(outputIntent);
|
|
40
|
+
p.part; // 2
|
|
41
|
+
p.level; // 'b'
|
|
42
|
+
p.catalog.iso; // 'ISO 19005-2:2011'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Lint
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
const r = ext.validatePdfABasics(typedDoc);
|
|
49
|
+
r.pass; // false
|
|
50
|
+
r.errors; // [ 'catalog requires /Metadata XMP stream', … ]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Errors
|
|
54
|
+
|
|
55
|
+
| Code | Class | When |
|
|
56
|
+
|------|-------|------|
|
|
57
|
+
| `pdf/extra/pdfa/not-dict` | `ParseError` | outputIntent is not a dict. |
|
|
58
|
+
| `pdf/extra/pdfa/lint/bad-doc` | `ParseError` | typedDoc is not an object. |
|
|
59
|
+
|
|
60
|
+
## See also
|
|
61
|
+
|
|
62
|
+
- [`pdfOutputIntent`](../prepress/outputIntent.md)
|
|
63
|
+
- [`pdfXmp`](../metadata/xmp.md)
|
|
64
|
+
- [`pdfXPrepress`](./pdf-x-prepress.md)
|
|
65
|
+
- [Extras index](./README.md)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfSandbox
|
|
3
|
+
category: pdf/extra
|
|
4
|
+
dependencies: [pdfErrors]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfSandbox
|
|
11
|
+
|
|
12
|
+
> Strict sandbox linter for active-content PDF features.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfSandbox` | **Source** `packages/front/office/pdf/src/extra/pdf-sandbox.js` | **Deps** `pdfErrors` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Flags actions that request active/external behaviour when a document is opened in an untrusted context: `/Launch`, `/JavaScript`, `/ImportData` (errors — execution, scripting, or file-system reads); `/SubmitForm`, `/Rendition` (with a `/JS` payload), `/URI` (warnings — network or navigation side effects). Benign actions (`GoTo`, `Named`, …) are ignored. The linter consumes already-typed action records (e.g. from `pdfFormActionsExtended.typeExtendedAction`), it does not parse raw dicts itself.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const ext = runtime.resolve('pdfSandbox');
|
|
22
|
+
// Returns: { lintAction, lintActions, ACTIVE_KINDS }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Member | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `lintAction` | `(rec: { kind, sandboxed? }) => Issue \| null` | `null` for non-objects, benign kinds, or a `Rendition` record with `sandboxed` falsy. |
|
|
30
|
+
| `lintActions` | `(records: Iterable<Record>) => { sandboxed: true, issues: Issue[], hasActiveContent: boolean, hasErrors: boolean }` | Aggregates `lintAction` over an iterable. |
|
|
31
|
+
| `ACTIVE_KINDS` | frozen catalog | Action kind → `{ severity: 'error' \| 'warning', message }`. |
|
|
32
|
+
|
|
33
|
+
### Shape `Issue`
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
{ kind, code: 'pdf/sandbox/active-' + kind.toLowerCase(),
|
|
37
|
+
severity: 'error' | 'warning', message, context: { sandboxed: boolean } }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
### Lint a single action
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
const ext = runtime.resolve('pdfSandbox');
|
|
46
|
+
const issue = ext.lintAction({ kind: 'Launch', sandboxed: true });
|
|
47
|
+
issue.severity; // 'error'
|
|
48
|
+
issue.code; // 'pdf/sandbox/active-launch'
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Lint a list of typed actions
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const r = ext.lintActions([
|
|
55
|
+
{ kind: 'Launch', sandboxed: true },
|
|
56
|
+
{ kind: 'GoTo' },
|
|
57
|
+
{ kind: 'URI' }
|
|
58
|
+
]);
|
|
59
|
+
r.issues.length; // 2
|
|
60
|
+
r.hasActiveContent; // true
|
|
61
|
+
r.hasErrors; // true (Launch is an error-severity kind)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Errors
|
|
65
|
+
|
|
66
|
+
| Code | Class | When |
|
|
67
|
+
|------|-------|------|
|
|
68
|
+
| `pdf/sandbox/bad-input` | `ContractError` | `lintActions` argument is not iterable. |
|
|
69
|
+
|
|
70
|
+
`lintAction` never throws — it returns `null` for any input it cannot classify.
|
|
71
|
+
|
|
72
|
+
## See also
|
|
73
|
+
|
|
74
|
+
- [`pdfFormActionsExtended`](./form-actions-extended.md)
|
|
75
|
+
- [`pdfAction`](../action/action.md)
|
|
76
|
+
- [Extras index](./README.md)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfUaTagged
|
|
3
|
+
category: pdf/extra
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfUaTagged
|
|
11
|
+
|
|
12
|
+
> PDF/UA-1 linter (ISO 14289-1) and draft PDF/UA-2 (ISO 14289-2).
|
|
13
|
+
|
|
14
|
+
**Module** `pdfUaTagged` | **Source** `packages/front/office/pdf/src/extra/pdf-ua-tagged.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Static linter. Catalog checks: `/StructTreeRoot` required, `/MarkInfo /Marked true`, `/Lang`, `/ViewerPreferences /DisplayDocTitle true`. Structure-element checks: Figures need `/Alt` or `/ActualText`; `/Span` is discouraged as a top-level type; the accessible-permission bit (bit 10) must be set.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const ext = runtime.resolve('pdfUaTagged');
|
|
22
|
+
// Returns: { validatePdfUa, validateUaStructElement, UA_STRUCTURE }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Member | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `validatePdfUa` | `(typedDoc) => { pass, errors, warnings }` | Document-level lint. |
|
|
30
|
+
| `validateUaStructElement` | `(node) => { pass, errors, warnings }` | Lints a single structure node. |
|
|
31
|
+
| `UA_STRUCTURE` | frozen catalog | `{ required, forbidden, figure, headings }` structural rule lists. |
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
### Global lint
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
const ext = runtime.resolve('pdfUaTagged');
|
|
39
|
+
const r = ext.validatePdfUa(typedDoc);
|
|
40
|
+
r.pass; // false
|
|
41
|
+
r.errors; // [ 'catalog requires /Lang string', … ]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Lint a node
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
const r = ext.validateUaStructElement(figureNode);
|
|
48
|
+
r.errors[0]; // 'Figure requires /Alt or /ActualText'
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Errors
|
|
52
|
+
|
|
53
|
+
| Code | Class | When |
|
|
54
|
+
|------|-------|------|
|
|
55
|
+
| `pdf/extra/pdfua/bad-doc` | `ParseError` | typedDoc is not an object. |
|
|
56
|
+
| `pdf/extra/pdfua/struct/bad-node` | `ParseError` | node is not an object. |
|
|
57
|
+
|
|
58
|
+
## See also
|
|
59
|
+
|
|
60
|
+
- [`pdfStructTree`](../tagged/structTree.md)
|
|
61
|
+
- [`pdfWellTagged`](./well-tagged-pdf.md)
|
|
62
|
+
- [`pdfTaggedPdfTyped`](./tagged-pdf-typed.md)
|
|
63
|
+
- [Extras index](./README.md)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfXPrepress
|
|
3
|
+
category: pdf/extra
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfXPrepress
|
|
11
|
+
|
|
12
|
+
> PDF/X conformance (X-1a, X-3, X-4, …, X-6) — ISO 15930.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfXPrepress` | **Source** `packages/front/office/pdf/src/extra/pdf-x-prepress.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
PDF/X profile family (X-1a/X-3/X-4/X-4p/X-5g/X-5n/X-5pg/X-6) with `/OutputIntent /S /GTS_PDFX`. Structural lint: `/TrimBox` (or `/ArtBox`, never both) on every page, plus a `/BleedBox` presence warning.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const ext = runtime.resolve('pdfXPrepress');
|
|
22
|
+
// Returns: { typePdfXOutputIntent, lintPdfXPage, PDFX_PROFILES, COLOR_POLICY }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Member | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `typePdfXOutputIntent` | `(dict) => { isPdfX, subtype, identifier, profile, catalog, raw }` | Typed output intent. |
|
|
30
|
+
| `lintPdfXPage` | `(page) => { pass, errors, warnings }` | Structural per-page lint. |
|
|
31
|
+
| `PDFX_PROFILES` | frozen catalog | Profile name → `{ iso, color, flavor }`. |
|
|
32
|
+
| `COLOR_POLICY` | frozen catalog | `None`/`Convert`/`Tag`/`Embed` → description. |
|
|
33
|
+
|
|
34
|
+
## Examples
|
|
35
|
+
|
|
36
|
+
### Detect the profile
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
const ext = runtime.resolve('pdfXPrepress');
|
|
40
|
+
const oi = ext.typePdfXOutputIntent(outputIntent);
|
|
41
|
+
oi.profile; // 'X-4'
|
|
42
|
+
oi.catalog.iso; // 'ISO 15930-7:2010'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Lint a page
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
const r = ext.lintPdfXPage(page);
|
|
49
|
+
r.pass; // false
|
|
50
|
+
r.errors; // [ 'page requires /TrimBox or /ArtBox' ]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Errors
|
|
54
|
+
|
|
55
|
+
| Code | Class | When |
|
|
56
|
+
|------|-------|------|
|
|
57
|
+
| `pdf/extra/pdfx/not-dict` | `ParseError` | outputIntent is not a dict. |
|
|
58
|
+
| `pdf/extra/pdfx/lint/bad-page` | `ParseError` | page is not a typed page dict. |
|
|
59
|
+
|
|
60
|
+
## See also
|
|
61
|
+
|
|
62
|
+
- [`pdfPageBoundary`](../prepress/pageBoundary.md)
|
|
63
|
+
- [`pdfOutputIntent`](../prepress/outputIntent.md)
|
|
64
|
+
- [`pdfAOutputIntent`](./pdf-a-output-intent.md)
|
|
65
|
+
- [Extras index](./README.md)
|