@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,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfStandardV4
|
|
3
|
+
category: pdf/crypto
|
|
4
|
+
dependencies: [pdfErrors, aes, cbc, bitArray]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfStandardV4
|
|
11
|
+
|
|
12
|
+
> Standard Security Handler V=4, R=4 — PDF 1.6 legacy (RC4-128 / AES-128-CBC).
|
|
13
|
+
|
|
14
|
+
**Module** `pdfStandardV4` | **Source** `packages/front/office/pdf/src/crypto/standardV4.js` | **Deps** `pdfErrors`, `aes`, `cbc`, `bitArray` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Implements ISO 32000-1 §7.6.3 Algorithm 2 (128-bit file-key derivation, 50
|
|
17
|
+
rounds of MD5), Algorithm 3 (`/O`), Algorithm 5 (`/U`), and per-object key
|
|
18
|
+
derivation for the two V=4 crypt filter methods selectable via `/CF /StdCF`:
|
|
19
|
+
|
|
20
|
+
- **AESV2** — AES-128-CBC; per-object key = `MD5(fileKey ‖ objId(3 LE) ‖ gen(2 LE) ‖ "sAlT")`
|
|
21
|
+
truncated to `min(fileKey.len + 5, 16)`; ciphertext is IV-prefixed, PKCS#7 padded.
|
|
22
|
+
- **V2** — RC4-128; per-object key = `MD5(fileKey ‖ objId(3 LE) ‖ gen(2 LE))` truncated the same way.
|
|
23
|
+
|
|
24
|
+
MD5 and RC4 are implemented locally (this handler predates fw's hash/cipher
|
|
25
|
+
family and both primitives are legacy-only) — `aes`/`cbc` are the only fw
|
|
26
|
+
crypto deps, for the AESV2 path.
|
|
27
|
+
|
|
28
|
+
## Resolve
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
const v4 = runtime.resolve('pdfStandardV4');
|
|
32
|
+
// Returns: { tryPassword, decryptString, decryptStream,
|
|
33
|
+
// decryptEmbeddedFile, encryptEmbeddedFile,
|
|
34
|
+
// encryptString, encryptStream,
|
|
35
|
+
// buildOU, buildPerms,
|
|
36
|
+
// computeFileKey, computeU, computeO,
|
|
37
|
+
// objectKey, rc4, md5, padPassword, PASSWORD_PADDING }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
| Method | Signature | Returns |
|
|
43
|
+
|--------|-----------|---------|
|
|
44
|
+
| `tryPassword` | `(typedEncrypt: { O, U, P, idFirst, EncryptMetadata? }, password, isOwner: boolean) => { fileEncryptionKey: Uint8Array \| null }` | `null` FEK on rejection; recovers the user password from `/O` first when `isOwner`. |
|
|
45
|
+
| `decryptString` | `(typedEncrypt: { method }, fek, objNum, gen, ciphertext) => Uint8Array` | Dispatches on `typedEncrypt.method` (`'AESV2'` or `'V2'`/`'RC4'`). |
|
|
46
|
+
| `decryptStream` | same signature as `decryptString` | Alias — identical implementation. |
|
|
47
|
+
| `decryptEmbeddedFile` | same signature as `decryptString` | Alias for the `/EFF`-resolved method (ISO 32000-1 §7.6.5). |
|
|
48
|
+
| `encryptString` | `(typedEncrypt: { method }, fek, objNum, gen, plaintext, iv?) => Uint8Array` | `iv` (16 bytes) required for `'AESV2'`; ignored for RC4. |
|
|
49
|
+
| `encryptStream` | same signature as `encryptString` | Alias — identical implementation. |
|
|
50
|
+
| `encryptEmbeddedFile` | same signature as `encryptString` | Alias for the `/EFF` write path. |
|
|
51
|
+
| `buildOU` | `(ownerPassword, userPassword, P, idFirst: Uint8Array, encryptMetadata) => { O, U, fek }` | Builds a fresh `/O` + `/U` pair and the derived 16-byte file key. |
|
|
52
|
+
| `buildPerms` | `() => null` | No-op — `/Perms` (Algorithm 8) is V≥5 only; kept for handler-dispatch symmetry with V5/V6. |
|
|
53
|
+
| `computeFileKey` / `computeU` / `computeO` | internal Algorithm 2/5/3 primitives | Exposed for testing/interop. |
|
|
54
|
+
| `objectKey` | `(fileKey, objNum, gen, isAes: boolean) => Uint8Array` | Per-object key derivation. |
|
|
55
|
+
| `rc4` / `md5` | stream-cipher / hash primitives | Exposed for testing. |
|
|
56
|
+
| `padPassword` | `(password: string \| Uint8Array) => Uint8Array` | The 32-byte padded password of Algorithm 2 step (a). Exposed for testing/interop. |
|
|
57
|
+
| `PASSWORD_PADDING` | `Uint8Array` (32 bytes) | The Algorithm 2 padding string. |
|
|
58
|
+
|
|
59
|
+
## Examples
|
|
60
|
+
|
|
61
|
+
### Password check then decrypt (read side)
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const v4 = runtime.resolve('pdfStandardV4');
|
|
65
|
+
const r = v4.tryPassword(
|
|
66
|
+
{ O, U, P, idFirst, EncryptMetadata: true }, 'user', false);
|
|
67
|
+
if (!r.fileEncryptionKey) throw new Error('bad password');
|
|
68
|
+
const plain = v4.decryptStream(
|
|
69
|
+
{ method: 'AESV2' }, r.fileEncryptionKey, objNum, gen, encryptedBytes);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Building `/O` + `/U` for a fresh document (write side)
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
const v4 = runtime.resolve('pdfStandardV4');
|
|
76
|
+
const { O, U, fek } = v4.buildOU('owner', 'user', -4, idFirst, true);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This is the handler `pdfEncryptedWriter` selects internally for `version: 4, revision: 4`.
|
|
80
|
+
|
|
81
|
+
## Errors
|
|
82
|
+
|
|
83
|
+
All thrown as `EncryptionError`.
|
|
84
|
+
|
|
85
|
+
| Code | When |
|
|
86
|
+
|------|------|
|
|
87
|
+
| `pdf/crypto/v4/missing-fw` | `aes`/`cbc`/`bitArray` fw modules unavailable (thrown at module construction). |
|
|
88
|
+
| `pdf/crypto/v4/bad-password` | Password argument is neither `string` nor `Uint8Array`. |
|
|
89
|
+
| `pdf/crypto/v4/bad-O` | `/O` is not a 32-byte `Uint8Array` (`computeFileKey`). |
|
|
90
|
+
| `pdf/crypto/v4/bad-id` | First `/ID` element missing/invalid (`computeFileKey`, `buildOU`). |
|
|
91
|
+
| `pdf/crypto/v4/bad-O-U` | `/O` or `/U` not exactly 32 bytes (`tryPassword`). |
|
|
92
|
+
| `pdf/crypto/v4/bad-string` | AESV2 ciphertext shorter than 16 bytes (missing IV). |
|
|
93
|
+
| `pdf/crypto/v4/bad-method` | `method` neither `'AESV2'` nor `'V2'`/`'RC4'` (decrypt or encrypt side). |
|
|
94
|
+
| `pdf/crypto/v4/encrypt-bad-input` | `encryptString` plaintext is not a `Uint8Array`. |
|
|
95
|
+
| `pdf/crypto/v4/encrypt-bad-iv` | AESV2 encrypt `iv` is not exactly 16 bytes. |
|
|
96
|
+
| `pdf/crypto/v4/bad-ciphertext-len` / `bad-pt-len` | AES-CBC input length not a multiple of 16. |
|
|
97
|
+
| `pdf/crypto/v4/aes-schedule-failed` / `aes-encrypt-schedule` | fw AES-128 key schedule failed. |
|
|
98
|
+
| `pdf/crypto/v4/cbc-decrypt-failed` / `cbc-encrypt-failed` | fw CBC operation failed. |
|
|
99
|
+
|
|
100
|
+
## See also
|
|
101
|
+
|
|
102
|
+
- [`pdfEncryptedWriter`](../document/encryptedWriter.md) — selects this handler for `version: 4`.
|
|
103
|
+
- [`pdfStandardV5`](./standardV5.md) · [`pdfStandardV6`](./standardV6.md) — modern (V=5) handlers.
|
|
104
|
+
- [`pdfSecurity`](./security.md) — read-side dispatch.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfStandardV5
|
|
3
|
+
category: pdf/crypto
|
|
4
|
+
dependencies: [pdfErrors, aes, cbc, sha256, bitArray, pdfAesGcm]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfStandardV5
|
|
11
|
+
|
|
12
|
+
> Standard Security Handler R=5 (historical AES-256, PDF 1.7 Adobe Extension Level 3).
|
|
13
|
+
|
|
14
|
+
**Module** `pdfStandardV5` | **Source** `packages/front/office/pdf/src/crypto/standardV5.js` | **Deps** `pdfErrors`, `aes`, `cbc`, `sha256`, `bitArray`, `pdfAesGcm` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Implements the R=5 derivation: SHA-256 of password + validation salt → file encryption key via AES-CBC over `/OE`/`/UE`. This algorithm was deprecated by ISO 32000-2 in favor of R=6 hardening, but remains needed to read PDFs produced between 2009 and 2018. `pdfAesGcm` is an optional dependency, only required when a `/CF` crypt filter resolves to `AESV4` (ISO/TS 32003).
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const v5 = runtime.resolve('pdfStandardV5');
|
|
22
|
+
// Returns: { tryPassword, decryptString, decryptStream,
|
|
23
|
+
// encryptString, encryptStream,
|
|
24
|
+
// buildUUE, buildOOE, buildPerms }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
| Method | Signature | Returns |
|
|
30
|
+
|--------|-----------|---------|
|
|
31
|
+
| `tryPassword` | `(typedEncrypt: { O, U, OE, UE }, password: string \| Uint8Array, isOwner: boolean) => { fileEncryptionKey: Uint8Array \| null }` | `null` on rejection. |
|
|
32
|
+
| `decryptString` | `(typedEncrypt: { method? }, fek, objNum, gen, ciphertext) => Uint8Array` | AES-256-CBC (or AES-GCM when `typedEncrypt.method === 'AESV4'`), §7.6.4. `objNum`/`gen` are accepted but unused (V5 keys are not per-object). |
|
|
33
|
+
| `decryptStream` | same signature as `decryptString` | Alias — identical implementation. |
|
|
34
|
+
| `encryptString` | `(typedEncrypt: { method? }, fek, objNum, gen, plaintext, iv) => Uint8Array` | Encrypts (write side). `iv` must be 16 bytes for AES-CBC or 12 bytes for AESV4. |
|
|
35
|
+
| `encryptStream` | same signature as `encryptString` | Alias — identical implementation. |
|
|
36
|
+
| `buildUUE` | `(password, fek, valSalt: Uint8Array, keySalt: Uint8Array) => { U: Uint8Array(48), UE: Uint8Array(32) }` | Builds `/U` + `/UE` per Algorithm 2.A. |
|
|
37
|
+
| `buildOOE` | `(password, fek, U48: Uint8Array, valSalt, keySalt) => { O: Uint8Array(48), OE: Uint8Array(32) }` | Builds `/O` + `/OE`. |
|
|
38
|
+
| `buildPerms` | `(p: number, fek, encryptMetadata: boolean, randomBytes: (n) => Uint8Array) => Uint8Array(16)` | Algorithm 10 — encrypted `/Perms` block. |
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
### Owner then user password attempt
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
const v5 = runtime.resolve('pdfStandardV5');
|
|
46
|
+
let r = v5.tryPassword(enc, ownerPwd, true);
|
|
47
|
+
if (!r.fileEncryptionKey) r = v5.tryPassword(enc, userPwd, false);
|
|
48
|
+
if (!r.fileEncryptionKey) throw new Error('bad password');
|
|
49
|
+
const plain = v5.decryptStream(enc, r.fileEncryptionKey, num, gen, encStream);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Building a fresh `/O`, `/U`, `/OE`, `/UE` set (write side)
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
const v5 = runtime.resolve('pdfStandardV5');
|
|
56
|
+
const { U, UE } = v5.buildUUE(userPwd, fek, valSalt, keySalt);
|
|
57
|
+
const { O, OE } = v5.buildOOE(ownerPwd, fek, U, valSalt2, keySalt2);
|
|
58
|
+
const permsBlock = v5.buildPerms(pBitmask, fek, true, cryptoRandomBytes);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Errors
|
|
62
|
+
|
|
63
|
+
| Code | Class | When |
|
|
64
|
+
|------|--------|------|
|
|
65
|
+
| `pdf/crypto/v5/missing-fw` | `EncryptionError` | fw bundle incomplete (thrown at module construction). |
|
|
66
|
+
| `pdf/crypto/v5/bad-password` | `EncryptionError` | Invalid password argument. |
|
|
67
|
+
| `pdf/crypto/v5/bad-ciphertext-len` | `EncryptionError` | Length not a multiple of 16. |
|
|
68
|
+
| `pdf/crypto/v5/aes-schedule-failed` | `EncryptionError` | fw key schedule failed. |
|
|
69
|
+
| `pdf/crypto/v5/cbc-decrypt-failed` | `EncryptionError` | fw CBC decrypt failed. |
|
|
70
|
+
| `pdf/crypto/v5/bad-O-U` | `EncryptionError` | `/O` or `/U` not at least 48 bytes. |
|
|
71
|
+
| `pdf/crypto/v5/bad-OE-UE` | `EncryptionError` | `/OE` or `/UE` not exactly 32 bytes. |
|
|
72
|
+
| `pdf/crypto/v5/bad-string` | `EncryptionError` | Encrypted string shorter than 32 bytes (IV + 1 block). |
|
|
73
|
+
| `pdf/crypto/v5/missing-gcm` | `EncryptionError` | `method === 'AESV4'` requested but `pdfAesGcm` was not supplied. |
|
|
74
|
+
| `pdf/crypto/v5/bad-pt-len` | `EncryptionError` | Plaintext length not a multiple of 16 (`encryptString`/CBC path). |
|
|
75
|
+
| `pdf/crypto/v5/aes-encrypt-schedule` | `EncryptionError` | fw key schedule failed on the encrypt side. |
|
|
76
|
+
| `pdf/crypto/v5/cbc-encrypt-failed` | `EncryptionError` | fw CBC encrypt failed. |
|
|
77
|
+
| `pdf/crypto/v5/encrypt-bad-input` | `EncryptionError` | `encryptString` plaintext is not a Uint8Array. |
|
|
78
|
+
| `pdf/crypto/v5/encrypt-bad-iv` | `EncryptionError` | `iv` has the wrong length for the resolved method. |
|
|
79
|
+
| `pdf/crypto/v5/perms-schedule` | `EncryptionError` | AES-256-ECB schedule failed while building `/Perms`. |
|
|
80
|
+
|
|
81
|
+
## See also
|
|
82
|
+
|
|
83
|
+
- [`pdfStandardV6`](./standardV6.md) — recommended algorithm.
|
|
84
|
+
- [`pdfSecurity`](./security.md) · [`pdfPermissions`](./permissions.md) · [`pdfAesGcm`](./aesGcm.md)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfStandardV6
|
|
3
|
+
category: pdf/crypto
|
|
4
|
+
dependencies: [pdfErrors, aes, cbc, sha256, sha384, sha512, bitArray, pdfAesGcm]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfStandardV6
|
|
11
|
+
|
|
12
|
+
> Standard Security Handler R=6 — AES-256 + hardening — ISO 32000-2 §7.6.4.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfStandardV6` | **Source** `packages/front/office/pdf/src/crypto/standardV6.js` | **Deps** `pdfErrors`, `aes`, `cbc`, `sha256`, `sha384`, `sha512`, `bitArray`, `pdfAesGcm` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Implements Algorithm 2.B (Annex A): 64+ rounds of SHA-{256/384/512} over password + salt (+ extra), resistant to brute-force/rainbow-table attacks. Which hash function runs at each round depends on the remainder mod 3 of the last byte of the round's AES-CBC output (`hardening-runaway` bounds the loop at 1024 rounds). String/stream decryption shape is identical to V5 (IV-prefixed AES-256-CBC, no per-object rekeying); `pdfAesGcm` is optional, only required for `AESV4` (ISO/TS 32003).
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const v6 = runtime.resolve('pdfStandardV6');
|
|
22
|
+
// Returns: { tryPassword, decryptString, decryptStream,
|
|
23
|
+
// encryptString, encryptStream,
|
|
24
|
+
// buildUUE, buildOOE, buildPerms }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
| Method | Signature | Returns |
|
|
30
|
+
|--------|-----------|---------|
|
|
31
|
+
| `tryPassword` | `(typedEncrypt: { O, U, OE, UE }, password, isOwner: boolean) => { fileEncryptionKey: Uint8Array \| null }` | `null` = rejected (try the next password). |
|
|
32
|
+
| `decryptString` | `(typedEncrypt: { method? }, fek, objNum, gen, ciphertext) => Uint8Array` | AES-256-CBC (or AES-GCM for `method === 'AESV4'`). |
|
|
33
|
+
| `decryptStream` | same signature as `decryptString` | Alias — identical implementation. |
|
|
34
|
+
| `encryptString` | `(typedEncrypt: { method? }, fek, objNum, gen, plaintext, iv) => Uint8Array` | Encrypts (write side). `iv`: 16 bytes CBC / 12 bytes AESV4. |
|
|
35
|
+
| `encryptStream` | same signature as `encryptString` | Alias — identical implementation. |
|
|
36
|
+
| `buildUUE` | `(password, fek, valSalt, keySalt) => { U: Uint8Array(48), UE: Uint8Array(32) }` | Algorithm 8 / 2.B with hardening. |
|
|
37
|
+
| `buildOOE` | `(password, fek, U48, valSalt, keySalt) => { O: Uint8Array(48), OE: Uint8Array(32) }` | Same, owner side. |
|
|
38
|
+
| `buildPerms` | `(p: number, fek, encryptMetadata: boolean, randomBytes: (n) => Uint8Array) => Uint8Array(16)` | Algorithm 10 — encrypted `/Perms` block. |
|
|
39
|
+
|
|
40
|
+
## Examples
|
|
41
|
+
|
|
42
|
+
### Full decryption
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
const v6 = runtime.resolve('pdfStandardV6');
|
|
46
|
+
const r = v6.tryPassword(enc, userPwd, false);
|
|
47
|
+
if (!r.fileEncryptionKey) throw new Error('rejected');
|
|
48
|
+
for (const obj of doc._raw.encryptedStreams) {
|
|
49
|
+
obj.plain = v6.decryptStream(enc, r.fileEncryptionKey, obj.num, obj.gen, obj.raw);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Permission validation
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const perms = runtime.resolve('pdfPermissions');
|
|
57
|
+
const ok = perms.verifyPermsField(enc, r.fileEncryptionKey);
|
|
58
|
+
ok.encryptMetadata === enc.EncryptMetadata;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Building a fresh handler set (write side)
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const v6 = runtime.resolve('pdfStandardV6');
|
|
65
|
+
const { U, UE } = v6.buildUUE(userPwd, fek, valSalt, keySalt);
|
|
66
|
+
const { O, OE } = v6.buildOOE(ownerPwd, fek, U, valSalt2, keySalt2);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Errors
|
|
70
|
+
|
|
71
|
+
| Code | Class | When |
|
|
72
|
+
|------|--------|------|
|
|
73
|
+
| `pdf/crypto/v6/missing-fw` | `EncryptionError` | fw bundle incomplete (thrown at module construction). |
|
|
74
|
+
| `pdf/crypto/v6/bad-password` | `EncryptionError` | Invalid password argument. |
|
|
75
|
+
| `pdf/crypto/v6/bad-pt-len` | `EncryptionError` | Plaintext length not a multiple of 16. |
|
|
76
|
+
| `pdf/crypto/v6/aes-schedule-failed` | `EncryptionError` | Key schedule failed (hardening round). |
|
|
77
|
+
| `pdf/crypto/v6/bad-ct-len` | `EncryptionError` | Ciphertext length not a multiple of 16. |
|
|
78
|
+
| `pdf/crypto/v6/aes-decrypt-schedule` | `EncryptionError` | Key schedule failed on decrypt. |
|
|
79
|
+
| `pdf/crypto/v6/cbc-decrypt-failed` | `EncryptionError` | CBC decrypt failed. |
|
|
80
|
+
| `pdf/crypto/v6/hardening-runaway` | `EncryptionError` | Hardening loop exceeded 1024 rounds. |
|
|
81
|
+
| `pdf/crypto/v6/bad-O-U` | `EncryptionError` | `/O`/`/U` not at least 48 bytes. |
|
|
82
|
+
| `pdf/crypto/v6/bad-OE-UE` | `EncryptionError` | `/OE`/`/UE` not exactly 32 bytes. |
|
|
83
|
+
| `pdf/crypto/v6/bad-string` | `EncryptionError` | Encrypted string shorter than 32 bytes. |
|
|
84
|
+
| `pdf/crypto/v6/missing-gcm` | `EncryptionError` | `method === 'AESV4'` requested but `pdfAesGcm` was not supplied. |
|
|
85
|
+
| `pdf/crypto/v6/encrypt-bad-input` | `EncryptionError` | `encryptString` plaintext is not a Uint8Array. |
|
|
86
|
+
| `pdf/crypto/v6/encrypt-bad-iv` | `EncryptionError` | `iv` has the wrong length for the resolved method. |
|
|
87
|
+
| `pdf/crypto/v6/perms-schedule` | `EncryptionError` | AES-256-ECB schedule failed while building `/Perms`. |
|
|
88
|
+
|
|
89
|
+
## See also
|
|
90
|
+
|
|
91
|
+
- [`pdfStandardV5`](./standardV5.md) — legacy.
|
|
92
|
+
- [`pdfAesGcm`](./aesGcm.md) — ISO/TS 32003 (AES-GCM).
|
|
93
|
+
- [`pdfSecurity`](./security.md)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Destination — ISO 32000-2 §12.3.2
|
|
2
|
+
|
|
3
|
+
| Module | Returns | Deps | Description |
|
|
4
|
+
|--------|----------|------|-------------|
|
|
5
|
+
| [`pdfDestination`](./destination.md) | `{ typeDestination }` | `pdfErrors`, `pdfParser` | Explicit + named destinations. |
|
|
6
|
+
|
|
7
|
+
## See also
|
|
8
|
+
|
|
9
|
+
- [Action](../action/README.md) · [Outline](../outline/README.md) · [Annot](../annot/link.md)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfDestination
|
|
3
|
+
category: pdf/destination
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfDestination
|
|
11
|
+
|
|
12
|
+
> Explicit and named destinations — ISO 32000-2 §12.3.2.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfDestination` | **Source** `packages/front/office/pdf/src/destination/destination.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
A destination describes a view within a document: `[page, fit, …args]`. `fit` is one of `XYZ`, `Fit`, `FitH`, `FitV`, `FitR`, `FitB`, `FitBH`, `FitBV`. `typeDestination` accepts an explicit array, a name/string (looked up through the supplied names dict — either `/Names /Dests` (PDF 1.2+ name tree) or the legacy PDF 1.1 `/Dests` dict), or a dict carrying `/D`.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const dest = runtime.resolve('pdfDestination');
|
|
22
|
+
// Returns: { typeDestination }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Method | Signature | Returns |
|
|
28
|
+
|---------|-----------|----------|
|
|
29
|
+
| `typeDestination` | `(value, namesDict?, resolveRef?) => Destination` | Typed form. |
|
|
30
|
+
|
|
31
|
+
### Shape `Destination`
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
{
|
|
35
|
+
page: { num, gen } | { pageNum: number }, // explicit ref, or remote page index
|
|
36
|
+
fit: 'XYZ' | 'Fit' | 'FitH' | 'FitV' | 'FitR' | 'FitB' | 'FitBH' | 'FitBV',
|
|
37
|
+
args: (number | null)[] // per `fit`'s expected arity
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Examples
|
|
42
|
+
|
|
43
|
+
### Explicit destination
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const dest = runtime.resolve('pdfDestination');
|
|
47
|
+
const d = dest.typeDestination(dictItemD, null, resolveRef);
|
|
48
|
+
d.fit === 'XYZ';
|
|
49
|
+
d.args; // [left, top, zoom]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Named destination
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
const d = dest.typeDestination(
|
|
56
|
+
{ type: 'name', value: 'chap1' },
|
|
57
|
+
catalog.names?.entries?.Dests,
|
|
58
|
+
resolveRef
|
|
59
|
+
);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Errors
|
|
63
|
+
|
|
64
|
+
| Code | Class | When |
|
|
65
|
+
|------|--------|------|
|
|
66
|
+
| `pdf/dest/bad-input` | `ParseError` | `value` is null or not a typed PDF object. |
|
|
67
|
+
| `pdf/dest/bad-type` | `ParseError` | Value is neither array, name nor string. |
|
|
68
|
+
| `pdf/dest/empty` | `ParseError` | Destination array is empty. |
|
|
69
|
+
| `pdf/dest/bad-page` | `ParseError` | First element is neither a ref nor an int. |
|
|
70
|
+
| `pdf/dest/missing-fit` | `ParseError` | Second element missing or not a name. |
|
|
71
|
+
| `pdf/dest/unknown-fit` | `ParseError` | `fit` outside the known set. |
|
|
72
|
+
| `pdf/dest/bad-arg` | `ParseError` | A fit argument is neither a number nor null. |
|
|
73
|
+
| `pdf/dest/no-names` | `ParseError` | Named destination with no `namesDict` supplied. |
|
|
74
|
+
| `pdf/dest/unknown-name` | `ParseError` | Name not found in `/Dests`. |
|
|
75
|
+
|
|
76
|
+
## See also
|
|
77
|
+
|
|
78
|
+
- [`pdfOutline`](../outline/outline.md) · [`pdfAction`](../action/action.md)
|
|
79
|
+
- [`pdfLinkAnnot`](../annot/link.md)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Document — ISO 32000-2 §7.7
|
|
2
|
+
|
|
3
|
+
Typed document layer — Catalog, page tree, Page, read orchestrator, writers.
|
|
4
|
+
|
|
5
|
+
| Module | Returns | Deps | Description |
|
|
6
|
+
|--------|---------|------|-------------|
|
|
7
|
+
| [`pdfCatalog`](./catalog.md) | `{ typeCatalog }` | `pdfErrors`, `pdfParser` | §7.7.2 — Catalog. |
|
|
8
|
+
| [`pdfPages`](./pages.md) | `{ walkPageTree, readPageCount }` | `pdfErrors`, `pdfParser` | §7.7.3 — page-tree walker. |
|
|
9
|
+
| [`pdfPage`](./page.md) | `{ typePage }` | `pdfErrors`, `pdfParser` | §7.7.3.3 — typed Page. |
|
|
10
|
+
| [`pdfDocument`](./document.md) | `{ readDocument, readHeader }` | `pdfErrors`, `pdfTokenizer`, `pdfParser`, `pdfXref`, `pdfTrailer`, `pdfCatalog`, `pdfPage`, `pdfPages`, `pdfCrossRefStream`, `pdfObjStream`, `pdfFilterDispatch` | Top-level read orchestrator (classic tables, cross-reference streams, object streams, hybrid files). |
|
|
11
|
+
| [`pdfResources`](./resources.md) | `{ typeResources, resolvePageResources, lookupResource }` | `pdfErrors`, `pdfParser` | §7.8.3 — inheritable `/Resources`. |
|
|
12
|
+
| [`pdfWriter`](./writer.md) | `{ writeDocument, assembleIndirects }` | `pdfErrors`, `pdfSerializer` | Model → bytes §7.5.2–7.5.5. |
|
|
13
|
+
| [`pdfBuilder`](./builder.md) | `{ builder }` | `pdfErrors`, `pdfParserObj`, `pdfWriter` | Chainable constructive DSL over `pdfWriter`. |
|
|
14
|
+
| [`pdfIncrementalWriter`](./incrementalWriter.md) | `{ appendIncremental, appendIncrementalWithOffsets, readBaseTrailer }` | `pdfErrors`, `pdfSerializer`, `pdfTokenizer`, `pdfParser`, `pdfXref`, `pdfTrailer` | §7.5.6 — append-only incremental update. |
|
|
15
|
+
| [`pdfEncryptedWriter`](./encryptedWriter.md) | `{ writeEncryptedDocument }` | `pdfErrors`, `pdfWriter`, `pdfStandardV5`, `pdfStandardV6`, `pdfStandardV4`, `pdfAesGcm` | Wraps `pdfWriter` with the Standard Security Handlers. |
|
|
16
|
+
| [`pdfXrefStreamWriter`](./xrefStreamWriter.md) | `{ writeXrefStreamDocument }` | `pdfErrors`, `pdfSerializer`, `pdfFlate` | §7.5.8 — xref-stream + ObjStm alternative emitter. |
|
|
17
|
+
|
|
18
|
+
## Common pattern
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const doc = runtime.resolve('pdfDocument').readDocument(bytes);
|
|
22
|
+
doc.pages.forEach(p => console.log(p.mediaBox));
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## See also
|
|
26
|
+
|
|
27
|
+
- [Syntax layer](../syntax/README.md)
|
|
28
|
+
- [Top-level `pdf`](../pdf.md)
|
|
29
|
+
- [Read pipeline](../../guide/read-pdf.md)
|