@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,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfButtonField
|
|
3
|
+
category: pdf/form
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfButtonField
|
|
11
|
+
|
|
12
|
+
> Typing of an `/FT /Btn` field — ISO 32000-2 §12.7.5.2.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfButtonField` | **Source** `packages/front/office/pdf/src/form/button.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
A button field covers three subtypes selected by the `/Ff` flag word:
|
|
17
|
+
|
|
18
|
+
- **Pushbutton** (bit 17) — momentary, no retained state.
|
|
19
|
+
- **Radio** (bit 16) — exclusive.
|
|
20
|
+
- **Checkbox** — default when neither Pushbutton nor Radio.
|
|
21
|
+
|
|
22
|
+
Additional sub-flags: **NoToggleToOff** (bit 15, radio only) and **RadiosInUnison** (bit 26). `/V` is a `name` (`/Yes`, `/Off`, ...); `/Opt` is an array of strings/names for the export values. Any non-canonical entry falls into `_extras`.
|
|
23
|
+
|
|
24
|
+
## Resolve
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
const bf = runtime.resolve('pdfButtonField');
|
|
28
|
+
// Returns: { typeButtonField }
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## API
|
|
32
|
+
|
|
33
|
+
| Method | Signature | Returns |
|
|
34
|
+
|--------|-----------|---------|
|
|
35
|
+
| `typeButtonField` | `(dict) => ButtonField` | Typing. |
|
|
36
|
+
|
|
37
|
+
### Shape `ButtonField`
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
{
|
|
41
|
+
ft: 'Btn',
|
|
42
|
+
flags: number,
|
|
43
|
+
kind: 'pushbutton' | 'radio' | 'checkbox',
|
|
44
|
+
noToggleToOff: boolean,
|
|
45
|
+
radiosInUnison: boolean,
|
|
46
|
+
v: string | null, // name value
|
|
47
|
+
dv: string | null,
|
|
48
|
+
opt: Array<string|Uint8Array>,
|
|
49
|
+
t: Uint8Array | null, // /T partial name
|
|
50
|
+
raw: object,
|
|
51
|
+
_extras: { [key]: PdfObject }
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
57
|
+
### Typing
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
const bf = runtime.resolve('pdfButtonField');
|
|
61
|
+
const btn = bf.typeButtonField(record.node);
|
|
62
|
+
btn.kind; // 'checkbox'
|
|
63
|
+
btn.v; // 'Yes' | 'Off'
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Radio detection
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
if (btn.kind === 'radio') {
|
|
70
|
+
btn.opt; // ['First option', 'Second option', ...]
|
|
71
|
+
btn.noToggleToOff; // bit 15
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Pushbutton (no retained state)
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
if (btn.kind === 'pushbutton') {
|
|
79
|
+
// No /V to change; behavior is driven by /AA (actions).
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Errors
|
|
84
|
+
|
|
85
|
+
| Code | Class | When |
|
|
86
|
+
|------|--------|------|
|
|
87
|
+
| `pdf/form/btn/not-dict` | `ParseError` | Argument is not a typed dict. |
|
|
88
|
+
| `pdf/form/btn/bad-ft` | `ParseError` | `/FT` present but ≠ `/Btn`. |
|
|
89
|
+
| `pdf/form/btn/bad-opt` | `ParseError` | `/Opt` is not an array. |
|
|
90
|
+
| `pdf/form/btn/bad-opt-entry` | `ParseError` | `/Opt` entry is not a string/name. |
|
|
91
|
+
|
|
92
|
+
## See also
|
|
93
|
+
|
|
94
|
+
- [`pdfAcroForm`](./acroform.md) — roots.
|
|
95
|
+
- [`pdfFieldTree`](./fieldTree.md) — field discovery.
|
|
96
|
+
- [`pdfAppearance`](./appearance.md) — `/AP` with `states` for checkbox/radio.
|
|
97
|
+
- [`pdfTextField`](./text.md), [`pdfChoiceField`](./choice.md), [`pdfSignatureField`](./signature.md).
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfChoiceField
|
|
3
|
+
category: pdf/form
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfChoiceField
|
|
11
|
+
|
|
12
|
+
> Typing of a choice field `/FT /Ch` (list box or combo box) — ISO 32000-2 §12.7.5.4.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfChoiceField` | **Source** `packages/front/office/pdf/src/form/choice.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
A choice field is either a **list box** (default) or a **combo** (bit 18). Sub-flags: **Edit** (bit 19, combo + free text entry), **Sort** (bit 20), **MultiSelect** (bit 22, list only), **DoNotSpellCheck** (bit 23, Edit-combo only), **CommitOnSelChange** (bit 27). `/Opt` accepts two shapes: `string|name` (display = export) or a 2-element `[export, display]` array. `/V` is a `string` or `array<string>`. `/I` is a parallel array of indices.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const cf = runtime.resolve('pdfChoiceField');
|
|
22
|
+
// Returns: { typeChoiceField }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Method | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `typeChoiceField` | `(dict) => ChoiceField` | Typing. |
|
|
30
|
+
|
|
31
|
+
### Shape `ChoiceField`
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
{
|
|
35
|
+
ft: 'Ch',
|
|
36
|
+
flags: number,
|
|
37
|
+
kind: 'list' | 'combo',
|
|
38
|
+
editable, sort, multiSelect, doNotSpellCheck, commitOnSelChange, // booleans
|
|
39
|
+
opt: Array<{ export: string|Uint8Array, display: string|Uint8Array }>,
|
|
40
|
+
v: Array<string|Uint8Array> | null,
|
|
41
|
+
dv: Array<string|Uint8Array> | null,
|
|
42
|
+
i: number[], // indices
|
|
43
|
+
ti: number, // top index
|
|
44
|
+
da: Uint8Array | null,
|
|
45
|
+
q: number,
|
|
46
|
+
t: Uint8Array | null,
|
|
47
|
+
raw, _extras
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`editable` is computed as `combo && Edit`. `multiSelect` is computed as `!combo && MultiSelect` (combos cannot be multi-select).
|
|
52
|
+
|
|
53
|
+
## Examples
|
|
54
|
+
|
|
55
|
+
### Typical list box
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
const cf = runtime.resolve('pdfChoiceField');
|
|
59
|
+
const ch = cf.typeChoiceField(record.node);
|
|
60
|
+
ch.kind; // 'list'
|
|
61
|
+
ch.opt; // [{export:'A',display:'Alpha'}, ...]
|
|
62
|
+
ch.v; // ['A']
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Editable combo
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
if (ch.kind === 'combo' && ch.editable) {
|
|
69
|
+
// The user can enter a value outside /Opt
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Multi-select
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
if (ch.multiSelect) {
|
|
77
|
+
ch.v; // ['A','C']
|
|
78
|
+
ch.i; // [0, 2]
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Errors
|
|
83
|
+
|
|
84
|
+
| Code | Class | When |
|
|
85
|
+
|------|--------|------|
|
|
86
|
+
| `pdf/form/ch/not-dict` | `ParseError` | Argument is not a typed dict. |
|
|
87
|
+
| `pdf/form/ch/bad-ft` | `ParseError` | `/FT` present but ≠ `/Ch`. |
|
|
88
|
+
| `pdf/form/ch/bad-opt` | `ParseError` | `/Opt` is not an array. |
|
|
89
|
+
| `pdf/form/ch/bad-opt-entry` | `ParseError` | Invalid entry (shape, length, or types). |
|
|
90
|
+
| `pdf/form/ch/bad-v` | `ParseError` | `/V` array contains a non-string. |
|
|
91
|
+
|
|
92
|
+
## See also
|
|
93
|
+
|
|
94
|
+
- [`pdfFieldTree`](./fieldTree.md) — discovery.
|
|
95
|
+
- [`pdfButtonField`](./button.md), [`pdfTextField`](./text.md), [`pdfSignatureField`](./signature.md).
|
|
96
|
+
- [`pdfAppearance`](./appearance.md) — re-rendering when `NeedAppearances`.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfFieldTree
|
|
3
|
+
category: pdf/form
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfFieldTree
|
|
11
|
+
|
|
12
|
+
> Form-field tree walker — ISO 32000-2 §12.7.4.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfFieldTree` | **Source** `packages/front/office/pdf/src/form/fieldTree.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Form fields form a tree rooted at `AcroForm./Fields`. Each node may carry `/Kids` (refs to child fields or widget annotations) and **inherits** `/FT`, `/Ff`, `/V`, `/DV`, `/DA`, `/Q`, `/MaxLen` from its ancestors (§12.7.4.2). A **terminal** field is one whose kids are widgets (no `/T`) or has none. Guardrails: max depth 32, max total 100,000 fields, cycle detection via a `Set<num:gen>`.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const ft = runtime.resolve('pdfFieldTree');
|
|
22
|
+
// Returns: { walkFieldTree, getInherited }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Method | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `walkFieldTree` | `(rootRefs, resolveRef, opts?) => FieldRecord[]` | Pre-order walk. |
|
|
30
|
+
| `getInherited` | `(node, ancestors, key) => PdfObject \| undefined` | Inherited lookup. |
|
|
31
|
+
|
|
32
|
+
### Options
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
{ maxDepth?: number = 32, maxFields?: number = 100000 }
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Shape `FieldRecord`
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
{
|
|
42
|
+
ref: { num: number, gen: number },
|
|
43
|
+
node: object, // typed dict
|
|
44
|
+
ancestors: object[], // root → parent (typed dicts)
|
|
45
|
+
terminal: boolean
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`getInherited` only accepts inheritable keys: `FT`, `Ff`, `V`, `DV`, `DA`, `Q`, `MaxLen`. Otherwise returns `undefined`.
|
|
50
|
+
|
|
51
|
+
## Examples
|
|
52
|
+
|
|
53
|
+
### Walk from AcroForm
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const ft = runtime.resolve('pdfFieldTree');
|
|
57
|
+
const records = ft.walkFieldTree(form.fields, doc._raw.resolve);
|
|
58
|
+
records.filter(r => r.terminal).length;
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Inherited FT
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
for (const r of records) {
|
|
65
|
+
if (!r.terminal) continue;
|
|
66
|
+
const val = ft.getInherited(r.node, r.ancestors, 'FT');
|
|
67
|
+
if (val && val.value === 'Tx') console.log('text field', r.ref);
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Custom limits
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
const records = ft.walkFieldTree(roots, resolveRef, { maxDepth: 8, maxFields: 500 });
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Errors
|
|
78
|
+
|
|
79
|
+
| Code | Class | When |
|
|
80
|
+
|------|--------|------|
|
|
81
|
+
| `pdf/form/tree/bad-roots` | `ParseError` | `rootRefs` is not an array. |
|
|
82
|
+
| `pdf/form/tree/max-depth` | `ParseError` | Depth > `maxDepth`. |
|
|
83
|
+
| `pdf/form/tree/bad-ref` | `ParseError` | Malformed reference (no numeric `num`). |
|
|
84
|
+
| `pdf/form/tree/cycle` | `ParseError` | Cycle detected (same `num:gen` seen again). |
|
|
85
|
+
| `pdf/form/tree/not-dict` | `ParseError` | Resolved node is not a dict. |
|
|
86
|
+
| `pdf/form/tree/too-many` | `ParseError` | Total > `maxFields`. |
|
|
87
|
+
| `pdf/form/tree/non-ref-kid` | `ParseError` | `/Kids` entry is not a ref. |
|
|
88
|
+
|
|
89
|
+
## See also
|
|
90
|
+
|
|
91
|
+
- [`pdfAcroForm`](./acroform.md) — supplies the root refs.
|
|
92
|
+
- [`pdfButtonField`](./button.md), [`pdfTextField`](./text.md), [`pdfChoiceField`](./choice.md), [`pdfSignatureField`](./signature.md) — typing by `/FT`.
|
|
93
|
+
- [`pdfAppearance`](./appearance.md) — `/AP` on terminal widgets.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfSignatureField
|
|
3
|
+
category: pdf/form
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfSignatureField
|
|
11
|
+
|
|
12
|
+
> Typing of a signature field `/FT /Sig` — ISO 32000-2 §12.7.5.5.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfSignatureField` | **Source** `packages/front/office/pdf/src/form/signature.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
A signature field carries an opaque signature dict in `/V` (PKCS#7 / CMS, ByteRange, MDP). The **signature payload** itself is typed at L3 in `src/sig/` — here `/V` is kept as a raw typed object (ref or inline dict) so the caller decides whether to descend into it. `/Lock` (post-signature lock) and `/SV` (seed value) are also preserved. `signed` is `true` iff `/V` is present and well-formed.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const sf = runtime.resolve('pdfSignatureField');
|
|
22
|
+
// Returns: { typeSignatureField }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Method | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `typeSignatureField` | `(dict) => SignatureField` | Typing. |
|
|
30
|
+
|
|
31
|
+
### Shape `SignatureField`
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
{
|
|
35
|
+
ft: 'Sig',
|
|
36
|
+
flags: number,
|
|
37
|
+
v: object | null, // signature dict ref|dict (opaque at this level)
|
|
38
|
+
lock: object | null, // ref|dict
|
|
39
|
+
sv: object | null, // ref|dict — seed value
|
|
40
|
+
t: Uint8Array | null,
|
|
41
|
+
signed: boolean,
|
|
42
|
+
raw: object,
|
|
43
|
+
_extras:{ [key]: PdfObject }
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Examples
|
|
48
|
+
|
|
49
|
+
### Detecting a present signature
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
const sf = runtime.resolve('pdfSignatureField');
|
|
53
|
+
const sig = sf.typeSignatureField(record.node);
|
|
54
|
+
if (sig.signed) {
|
|
55
|
+
const sigDict = sig.v.type === 'ref' ? doc._raw.resolve(sig.v) : sig.v;
|
|
56
|
+
// → hand off to the L3 src/sig/ API
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Lock / seed value
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
sig.lock; // /Lock — post-signature restrictions
|
|
64
|
+
sig.sv; // /SV — constraints for the signer
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Combining with AcroForm.sigFlags
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
const af = runtime.resolve('pdfAcroForm').typeAcroForm(...);
|
|
71
|
+
const signaturesExist = (af.sigFlags & 1) !== 0;
|
|
72
|
+
const appendOnly = (af.sigFlags & 2) !== 0;
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Errors
|
|
76
|
+
|
|
77
|
+
| Code | Class | When |
|
|
78
|
+
|------|--------|------|
|
|
79
|
+
| `pdf/form/sig/not-dict` | `ParseError` | Argument is not a typed dict. |
|
|
80
|
+
| `pdf/form/sig/bad-ft` | `ParseError` | `/FT` present but ≠ `/Sig`. |
|
|
81
|
+
| `pdf/form/sig/bad-v` | `ParseError` | `/V` is neither a dict nor a ref. |
|
|
82
|
+
| `pdf/form/sig/bad-lock` | `ParseError` | `/Lock` is neither a dict nor a ref. |
|
|
83
|
+
| `pdf/form/sig/bad-sv` | `ParseError` | `/SV` is neither a dict nor a ref. |
|
|
84
|
+
|
|
85
|
+
## See also
|
|
86
|
+
|
|
87
|
+
- [`pdfAcroForm`](./acroform.md) — `/SigFlags`.
|
|
88
|
+
- [`pdfFieldTree`](./fieldTree.md) — discovery.
|
|
89
|
+
- [`pdfAppearance`](./appearance.md) — visual representation.
|
|
90
|
+
- [`pdfButtonField`](./button.md), [`pdfTextField`](./text.md), [`pdfChoiceField`](./choice.md).
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfTextField
|
|
3
|
+
category: pdf/form
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfTextField
|
|
11
|
+
|
|
12
|
+
> Typing of a text field `/FT /Tx` — ISO 32000-2 §12.7.5.3.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfTextField` | **Source** `packages/front/office/pdf/src/form/text.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Text field — free-form input. `/V` is a string (or a stream for very long content — retrieved as `Uint8Array` via `stream.raw`). The `/Ff` word carries the sub-flags: **Multiline** (bit 13), **Password** (bit 14), **FileSelect** (bit 21), **DoNotSpellCheck** (bit 23), **DoNotScroll** (bit 24), **Comb** (bit 25, requires `/MaxLen`), **RichText** (bit 26). The module enforces the `Comb` ⇒ `/MaxLen` present constraint.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const tf = runtime.resolve('pdfTextField');
|
|
22
|
+
// Returns: { typeTextField }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Method | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `typeTextField` | `(dict) => TextField` | Typing. |
|
|
30
|
+
|
|
31
|
+
### Shape `TextField`
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
{
|
|
35
|
+
ft: 'Tx',
|
|
36
|
+
flags: number,
|
|
37
|
+
multiline, password, fileSelect,
|
|
38
|
+
doNotSpellCheck, doNotScroll, comb, richText, // booleans
|
|
39
|
+
v: Uint8Array | null,
|
|
40
|
+
dv: Uint8Array | null,
|
|
41
|
+
maxLen: number | null,
|
|
42
|
+
da: Uint8Array | null,
|
|
43
|
+
q: number, // 0=left, 1=center, 2=right
|
|
44
|
+
t: Uint8Array | null,
|
|
45
|
+
raw: object,
|
|
46
|
+
_extras:{ [key]: PdfObject }
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
### Simple typing
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
const tf = runtime.resolve('pdfTextField');
|
|
56
|
+
const tx = tf.typeTextField(record.node);
|
|
57
|
+
new TextDecoder('utf-8').decode(tx.v); // current value
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Comb with MaxLen
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
if (tx.comb) {
|
|
64
|
+
tx.maxLen; // guaranteed defined, otherwise a ParseError would have been thrown
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Password detection
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
if (tx.password) {
|
|
72
|
+
// Don't render tx.v in clear text in the UI.
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Errors
|
|
77
|
+
|
|
78
|
+
| Code | Class | When |
|
|
79
|
+
|------|--------|------|
|
|
80
|
+
| `pdf/form/tx/not-dict` | `ParseError` | Argument is not a typed dict. |
|
|
81
|
+
| `pdf/form/tx/bad-ft` | `ParseError` | `/FT` present but ≠ `/Tx`. |
|
|
82
|
+
| `pdf/form/tx/comb-without-maxlen` | `ParseError` | `Comb` flag set but `/MaxLen` absent. |
|
|
83
|
+
|
|
84
|
+
## See also
|
|
85
|
+
|
|
86
|
+
- [`pdfFieldTree`](./fieldTree.md) — discovery.
|
|
87
|
+
- [`pdfAppearance`](./appearance.md) — `/AP /N` regenerated when `NeedAppearances`.
|
|
88
|
+
- [`pdfButtonField`](./button.md), [`pdfChoiceField`](./choice.md), [`pdfSignatureField`](./signature.md).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Linearization — ISO 32000-2 Annex F
|
|
2
|
+
|
|
3
|
+
Fast Web View — progressive prefetch over an HTTP byte-range transport.
|
|
4
|
+
|
|
5
|
+
| Module | Returns | Deps | Description |
|
|
6
|
+
|--------|----------|------|-------------|
|
|
7
|
+
| [`pdfLinearization`](./linearization.md) | `{ typeLinearizationDict }` | `pdfErrors`, `pdfParser` | Annex F parameter dict, read-only. |
|
|
8
|
+
|
|
9
|
+
## See also
|
|
10
|
+
|
|
11
|
+
- [Document](../document/README.md)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfLinearization
|
|
3
|
+
category: pdf/linearization
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfLinearization
|
|
11
|
+
|
|
12
|
+
> Linearization parameter dict — ISO 32000-2 Annex F.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfLinearization` | **Source** `packages/front/office/pdf/src/linearization/linearization.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
The "Linearized" parameter dict is the very first object of a file optimized for progressive (Fast Web View) download. Fields: `/Linearized` (version, usually 1.0), `/L` (file length), `/H` (hint-stream offsets/lengths — array of at least 2 numbers), `/O` (first-page object number), `/E` (end-of-first-page offset), `/N` (page count), `/T` (offset of the first entry in the main xref table), `/P` (optional, first page number).
|
|
17
|
+
|
|
18
|
+
Read-only: `pdf.write` does not linearize (no writer module references this module), and `extra/linearization-write` only builds the `/Linearized` dictionary and a zero-length hint-stream placeholder.
|
|
19
|
+
|
|
20
|
+
## Resolve
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
const lin = runtime.resolve('pdfLinearization');
|
|
24
|
+
// Returns: { typeLinearizationDict }
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
| Method | Signature | Returns |
|
|
30
|
+
|---------|-----------|----------|
|
|
31
|
+
| `typeLinearizationDict` | `(dict) => Linearization` | Strict typing; throws if invalid. |
|
|
32
|
+
|
|
33
|
+
### Shape
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
{
|
|
37
|
+
version: number, // /Linearized
|
|
38
|
+
length: number, // /L — total file length
|
|
39
|
+
hintOffsets: number[], // /H — at least 2 numbers
|
|
40
|
+
firstPageObject: number, // /O
|
|
41
|
+
endOfFirstPage: number, // /E
|
|
42
|
+
numberOfPages: number, // /N
|
|
43
|
+
mainXrefOffset: number, // /T
|
|
44
|
+
firstPageNumber?: number, // /P, when present
|
|
45
|
+
raw, _extras
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Examples
|
|
50
|
+
|
|
51
|
+
### Fast Web View detection
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const lin = runtime.resolve('pdfLinearization');
|
|
55
|
+
try {
|
|
56
|
+
const l = lin.typeLinearizationDict(firstObject.value);
|
|
57
|
+
console.log('linearized,', l.numberOfPages, 'pages, hint at', l.hintOffsets[0]);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
console.log('not linearized');
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Reading just the first page
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
const firstPageBytes = bytes.subarray(0, l.endOfFirstPage);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Errors
|
|
70
|
+
|
|
71
|
+
| Code | Class | When |
|
|
72
|
+
|------|--------|------|
|
|
73
|
+
| `pdf/linearization/not-dict` | `ParseError` | Argument is not a dict. |
|
|
74
|
+
| `pdf/linearization/not-linearized` | `ParseError` | `/Linearized` absent. |
|
|
75
|
+
| `pdf/linearization/missing-h` | `ParseError` | `/H` absent or not an array. |
|
|
76
|
+
| `pdf/linearization/bad-h` | `ParseError` | `/H` has fewer than 2 numeric elements. |
|
|
77
|
+
| `pdf/linearization/missing-l`, `-o`, `-e`, `-n`, `-t` | `ParseError` | The corresponding required key is absent or non-numeric. |
|
|
78
|
+
|
|
79
|
+
## See also
|
|
80
|
+
|
|
81
|
+
- [`pdfDocument`](../document/document.md) · [`pdfXref`](../syntax/xref.md)
|
package/docs/api/main.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
---
|
|
2
|
+
category: pdf
|
|
3
|
+
status: complete
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# main
|
|
7
|
+
|
|
8
|
+
> Entry point of `@awacloud/pdf` — re-exports every factory and the ordered `modules` list for `ModuleRuntime`.
|
|
9
|
+
|
|
10
|
+
**Source** `packages/front/office/pdf/src/main.js` | **Sub-path** `@awacloud/pdf` (the `.` export) — not a module descriptor
|
|
11
|
+
|
|
12
|
+
No factory of its own — this file is a declarative manifest: it imports every `pdf*` module descriptor and aggregates them into five arrays (`fw_require`, `pkg_require`, `modules`, `extras`, `bundle`), plus one additive re-export block, to provide a single import point (`@awacloud/pdf`). The `modules` array is topologically sorted: `register(m)` in order guarantees each dependency precedes its dependents.
|
|
13
|
+
|
|
14
|
+
## Resolve
|
|
15
|
+
|
|
16
|
+
`main` is not a DI module; it is used via direct import:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { pdf, pdfErrors, modules } from '@awacloud/pdf';
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The error classes (`PdfError`, `ParseError`, `RenderError`, `ContractError`, `EncryptionError`) are not exported at the top level — they are resolved via `pdfErrors.factory()` (see [`pdfErrors`](./errors.md)).
|
|
23
|
+
|
|
24
|
+
## API (exports)
|
|
25
|
+
|
|
26
|
+
| Export | Type | Description |
|
|
27
|
+
|--------|------|-------------|
|
|
28
|
+
| `pdf` | factory | Orchestrator — see [`pdf`](./pdf.md). |
|
|
29
|
+
| `pdfErrors` | factory | See [`pdfErrors`](./errors.md) — resolves the 5 error classes. |
|
|
30
|
+
| `pdfTokenizer` | factory | See [`pdfTokenizer`](./syntax/tokenizer.md). |
|
|
31
|
+
| `pdfParser` | factory | See [`pdfParser`](./syntax/parser.md). |
|
|
32
|
+
| `pdfXref` | factory | See [`pdfXref`](./syntax/xref.md). |
|
|
33
|
+
| `pdfTrailer` | factory | See [`pdfTrailer`](./syntax/trailer.md). |
|
|
34
|
+
| `pdfCatalog` | factory | See [`pdfCatalog`](./document/catalog.md). |
|
|
35
|
+
| `pdfPages` | factory | See [`pdfPages`](./document/pages.md). |
|
|
36
|
+
| `pdfPage` | factory | See [`pdfPage`](./document/page.md). |
|
|
37
|
+
| `pdfDocument` | factory | See [`pdfDocument`](./document/document.md). |
|
|
38
|
+
| `fw_require` | `factory[]` | The `@awacloud/fw` module descriptors required by fw-bound modules, their own transitive dependencies included (zlib, aes, asn1, rsa, ecc, ed25519, …). |
|
|
39
|
+
| `pkg_require` | `factory[]` | Cross-package descriptors: the whole `@awacloud/fonts` manifest (`fw_require` + `modules`) plus 4 internal `embed-pdf/subsetForPdf` helper descriptors (`embedClosure`, `embedCmapBuilder`, `embedGlyphRewriter`, `embedHash`) not re-exported by `@awacloud/fonts` itself — needed to resolve `pdfFontEmbed`'s full transitive graph. |
|
|
40
|
+
| `modules` | `factory[]` | PDF core — topologically ordered for `ModuleRuntime.register`. |
|
|
41
|
+
| `extras` | `factory[]` | The opt-in extras (P0/P1/P2/P3 + legacy + sandbox). |
|
|
42
|
+
| `bundle` | `factory[]` | Three descriptors: `pdfLargeBundle` / `pdfFullBundle` / `pdfLegacyBundle`. They are reachable through this array or their own sub-paths (`@awacloud/pdf/pdf-large`, …), not as named exports of the root — see [Bundles](./bundles/README.md). |
|
|
43
|
+
|
|
44
|
+
Beyond these arrays, **every module descriptor listed in `modules`** — from `pdfErrors`/`pdfShared` through the final `pdf` orchestrator, covering syntax, document, content, font, form, annotations, tagged PDF, encryption, signatures, OCG, outlines/destinations/actions, embedded files, linearization, metadata, prepress and associated files — **is additionally re-exported by its own binding name** (e.g. `import { pdfSignature, pdfCertChain } from '@awacloud/pdf'`), together with the 4 `pkg_require` fonts helper bindings. This is purely additive: the five arrays above stay byte-unchanged. The `extras` and `bundle` descriptors are **not** re-exported by name.
|
|
45
|
+
|
|
46
|
+
### Named descriptor exports
|
|
47
|
+
|
|
48
|
+
Derived from the `export { … }` block of `src/main.js` (its group comments
|
|
49
|
+
included):
|
|
50
|
+
|
|
51
|
+
| Group | Named exports |
|
|
52
|
+
|-------|---------------|
|
|
53
|
+
| Errors / shared | `pdfErrors`, `pdfShared` |
|
|
54
|
+
| Syntax | `pdfTokenizer`, `pdfParserObj`, `pdfParser`, `pdfXref`, `pdfTrailer`, `pdfSerializer`, `pdfFlate`, `pdfAsciiHex`, `pdfAscii85`, `pdfRunLength`, `pdfFilterDispatch`, `pdfObjStream`, `pdfCrossRefStream` |
|
|
55
|
+
| Document | `pdfCatalog`, `pdfPages`, `pdfPage`, `pdfDocument`, `pdfWriter`, `pdfBuilder`, `pdfEncryptedWriter`, `pdfIncrementalWriter`, `pdfXrefStreamWriter`, `pdfResources` |
|
|
56
|
+
| Content | `pdfContentOps`, `pdfContentStream`, `pdfGraphics`, `pdfText`, `pdfColor`, `pdfImages` |
|
|
57
|
+
| Font | `pdfFont`, `pdfFontEncoding`, `pdfType3`, `pdfFontEmbed` |
|
|
58
|
+
| Form | `pdfAcroForm`, `pdfFieldTree`, `pdfButtonField`, `pdfTextField`, `pdfChoiceField`, `pdfSignatureField`, `pdfAppearance` |
|
|
59
|
+
| Annotations | `pdfAnnot`, `pdfTextAnnot`, `pdfLinkAnnot`, `pdfMarkupAnnot`, `pdfShapeAnnot`, `pdfFreeTextAnnot`, `pdfInkAnnot`, `pdfStampAnnot`, `pdfFileAttachAnnot`, `pdfWidgetAnnot`, `pdfPopupAnnot`, `pdfProjectionAnnot`, `pdfRedactAnnot` |
|
|
60
|
+
| Tagged | `pdfStructTree`, `pdfStructElement`, `pdfRoleMap`, `pdfParentTree`, `pdfClassMap`, `pdfMarkedContent` |
|
|
61
|
+
| Encryption | `pdfSecurity`, `pdfStandardV4`, `pdfStandardV5`, `pdfStandardV6`, `pdfPermissions`, `pdfAesGcm` |
|
|
62
|
+
| Signatures | `pdfSigOids`, `pdfSha1`, `pdfSignature`, `pdfByteRange`, `pdfTimestamp`, `pdfCertChain`, `pdfDssBuilder`, `pdfSign` |
|
|
63
|
+
| Optional Content | `pdfOCG`, `pdfOCConfig` |
|
|
64
|
+
| Outlines / Destinations / Actions | `pdfOutline`, `pdfDestination`, `pdfAction`, `pdfActionGoTo`, `pdfActionUri`, `pdfActionNamed`, `pdfActionLaunch` |
|
|
65
|
+
| Embedded files | `pdfFileSpec`, `pdfEmbeddedFile`, `pdfCollection` |
|
|
66
|
+
| Linearization / Metadata / Prepress / Associated | `pdfLinearization`, `pdfInfo`, `pdfXmp`, `pdfOutputIntent`, `pdfPageBoundary`, `pdfAssociatedFiles` |
|
|
67
|
+
| Top-level | `pdf` |
|
|
68
|
+
| `pkg_require` — `@awacloud/fonts` subset helper bindings | `embedClosure`, `embedCmapBuilder`, `embedGlyphRewriter`, `embedHash` | See each module's own category page (e.g. [`pdfSignature`](./sig/signature.md), [`pdfAcroForm`](./form/acroform.md)) for its individual API.
|
|
69
|
+
|
|
70
|
+
## Examples
|
|
71
|
+
|
|
72
|
+
### Wire via the fw runtime
|
|
73
|
+
|
|
74
|
+
`fw_require` is needed as soon as a resolved module reaches an `@awacloud/fw`
|
|
75
|
+
factory — `pdf` does, through the Flate filter — so register it first:
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
import { ModuleRuntime } from '@awacloud/fw/core/runtime.js';
|
|
79
|
+
import { fw_require, modules } from '@awacloud/pdf';
|
|
80
|
+
|
|
81
|
+
const rt = new ModuleRuntime();
|
|
82
|
+
for (const m of fw_require) rt.register(m);
|
|
83
|
+
for (const m of modules) rt.register(m);
|
|
84
|
+
|
|
85
|
+
const api = rt.resolve('pdf');
|
|
86
|
+
const doc = api.read(bytes);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Stand-alone, without a runtime
|
|
90
|
+
|
|
91
|
+
`pdf.factory()` takes its dependencies as positional arguments; the
|
|
92
|
+
zero-argument entry is the committed framework-free build:
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
import { pdfBundled } from '@awacloud/pdf/standalone/pdf.js';
|
|
96
|
+
pdfBundled.factory().read(bytes);
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Typed catch subscription
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import { pdfErrors } from '@awacloud/pdf';
|
|
103
|
+
const { PdfError } = pdfErrors.factory();
|
|
104
|
+
|
|
105
|
+
try { /* … */ }
|
|
106
|
+
catch (e) { if (e instanceof PdfError) console.log(e.code); else throw e; }
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Errors
|
|
110
|
+
|
|
111
|
+
This module throws no errors of its own — it only re-exports.
|
|
112
|
+
|
|
113
|
+
## See also
|
|
114
|
+
|
|
115
|
+
- [`pdf`](./pdf.md) — main orchestrator.
|
|
116
|
+
- [Getting started](../guide/getting-started.md)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Metadata — ISO 32000-2 §14.3
|
|
2
|
+
|
|
3
|
+
| Module | Returns | Deps | Description |
|
|
4
|
+
|--------|----------|------|-------------|
|
|
5
|
+
| [`pdfInfo`](./info.md) | `{ typeInfo }` | `pdfErrors`, `pdfParser` | Info dict §14.3.3. |
|
|
6
|
+
| [`pdfXmp`](./xmp.md) | `{ typeXmpStream }` | `pdfErrors`, `pdfParser` | XMP §14.3.2 / ISO 16684-1. |
|
|
7
|
+
|
|
8
|
+
## See also
|
|
9
|
+
|
|
10
|
+
- [Document](../document/README.md) · [Prepress](../prepress/README.md)
|