@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,38 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
| Section | Modules | Description |
|
|
4
|
+
|---------|---------|-------------|
|
|
5
|
+
| [Syntax](./syntax/README.md) | `pdfTokenizer`, `pdfParser`, `pdfXref`, `pdfTrailer` | ISO 32000-2 §7.2–§7.5 — binary layer. |
|
|
6
|
+
| [Document](./document/README.md) | `pdfCatalog`, `pdfPages`, `pdfPage`, `pdfDocument`, `pdfResources`, `pdfWriter`, `pdfBuilder`, `pdfIncrementalWriter`, `pdfEncryptedWriter`, `pdfXrefStreamWriter` | §7.7 / §7.8.3 — typed document layer. |
|
|
7
|
+
| [Content](./content/README.md) | `pdfContentOps`, `pdfContentStream`, `pdfGraphics`, `pdfText`, `pdfColor`, `pdfImages` | §7.8 / §8 / §9.3–§9.4 — content streams. |
|
|
8
|
+
| [Font](./font/README.md) | `pdfFont`, `pdfFontEncoding`, `pdfType3`, `pdfFontEmbed` | §9.6 / §9.7 / §9.9 — fonts. |
|
|
9
|
+
| [Form](./form/README.md) | `pdfAcroForm`, `pdfFieldTree`, `pdfButtonField`, `pdfTextField`, `pdfChoiceField`, `pdfSignatureField`, `pdfAppearance` | §12.7 / §12.5.5 — interactive forms. |
|
|
10
|
+
| [Annot](./annot/README.md) | `pdfAnnot`, `pdfTextAnnot`, `pdfLinkAnnot`, `pdfMarkupAnnot`, `pdfShapeAnnot`, `pdfFreeTextAnnot`, `pdfInkAnnot`, `pdfStampAnnot`, `pdfFileAttachAnnot`, `pdfWidgetAnnot`, `pdfPopupAnnot`, `pdfProjectionAnnot`, `pdfRedactAnnot` | §12.5 — annotations. |
|
|
11
|
+
| [Tagged](./tagged/README.md) | `pdfStructTree`, `pdfStructElement`, `pdfRoleMap`, `pdfParentTree`, `pdfClassMap`, `pdfMarkedContent` | §14.6 / §14.7 / §14.8 — Tagged PDF, PDF/UA-2. |
|
|
12
|
+
| [Crypto](./crypto/README.md) | `pdfSecurity`, `pdfStandardV4`, `pdfStandardV5`, `pdfStandardV6`, `pdfPermissions`, `pdfAesGcm` | §7.6 + ISO TS 32003 — encryption. |
|
|
13
|
+
| [Sig](./sig/README.md) | `pdfSignature`, `pdfSign`, `pdfByteRange`, `pdfTimestamp`, `pdfCertChain`, `pdfDssBuilder`, `pdfSigOids`, `pdfSha1` | §12.8 + ISO TS 32001/32002 — signatures. |
|
|
14
|
+
| [OCG](./ocg/README.md) | `pdfOCG`, `pdfOCConfig` | §8.11 — optional content. |
|
|
15
|
+
| [Outline](./outline/README.md) | `pdfOutline` | §12.3.3 — bookmarks. |
|
|
16
|
+
| [Destination](./destination/README.md) | `pdfDestination` | §12.3.2. |
|
|
17
|
+
| [Action](./action/README.md) | `pdfAction`, `pdfActionGoTo`, `pdfActionUri`, `pdfActionNamed`, `pdfActionLaunch` | §12.6 — actions. |
|
|
18
|
+
| [Embedded](./embedded/README.md) | `pdfFileSpec`, `pdfEmbeddedFile`, `pdfCollection` | §7.11 — attachments. |
|
|
19
|
+
| [Linearization](./linearization/README.md) | `pdfLinearization` | Annex F — Fast Web View. |
|
|
20
|
+
| [Metadata](./metadata/README.md) | `pdfInfo`, `pdfXmp` | §14.3 — metadata. |
|
|
21
|
+
| [Prepress](./prepress/README.md) | `pdfOutputIntent`, `pdfPageBoundary` | §14.11 — prepress. |
|
|
22
|
+
| [Associated Files](./associatedFiles/README.md) | `pdfAssociatedFiles` | PDF 2.0 / PDF20_AN002-AF. |
|
|
23
|
+
| [Extras](./extra/README.md) | 32 opt-in modules (P0/P1/P2/P3/legacy) | L3+ coverage — color fonts, CID, full ExtGState, PAdES, AES-GCM, PDF/A, PDF/X, PDF/UA, WTPDF, 3D, JBIG2, legacy XFA, RC4, LZW… |
|
|
24
|
+
| [Bundles](./bundles/README.md) | `pdf-large`, `pdf-full`, `pdf-legacy` | Pre-wired factories combining core + extras. |
|
|
25
|
+
|
|
26
|
+
## Top-level
|
|
27
|
+
|
|
28
|
+
| Module | Source | Description |
|
|
29
|
+
|--------|--------|-------------|
|
|
30
|
+
| [`pdf`](./pdf.md) | [`src/pdf.js`](../../src/pdf.js) | Public orchestrator, `.use()` hook. |
|
|
31
|
+
| [`pdfErrors`](./errors.md) | [`src/errors.js`](../../src/errors.js) | `PdfError` hierarchy. |
|
|
32
|
+
| [`pdfShared`](./_shared/README.md) | [`src/_shared/index.js`](../../src/_shared/index.js) | Byte-level constants and stateless helpers. |
|
|
33
|
+
| `main` (re-export) | [`src/main.js`](../../src/main.js) | See [`main`](./main.md). |
|
|
34
|
+
|
|
35
|
+
## See also
|
|
36
|
+
|
|
37
|
+
- [Documentation index](../README.md)
|
|
38
|
+
- [Guide getting-started](../guide/getting-started.md)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfShared
|
|
3
|
+
category: _shared
|
|
4
|
+
dependencies: []
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfShared
|
|
11
|
+
|
|
12
|
+
> PDF byte-level constants and stateless helpers, shared across `@awacloud/pdf` factories.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfShared` | **Source** `packages/front/office/pdf/src/_shared/index.js` | **Deps** _(none)_ | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Magic bytes, ASCII byte values, the ISO 32000-2 §7.2 character classes, a hex
|
|
17
|
+
lookup table, text codec instances and a few byte helpers. `pdfTokenizer` and
|
|
18
|
+
the top-level [`pdf`](../pdf.md) declare it as a dependency; other modules
|
|
19
|
+
(the filters, `pdfWriter`, `pdfSerializer`) still carry their own inline
|
|
20
|
+
copies of some of these helpers.
|
|
21
|
+
|
|
22
|
+
## Resolve
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
const shared = runtime.resolve('pdfShared');
|
|
26
|
+
// → { HEADER_PREFIX, EOF_MARKER, BINARY_MARKER,
|
|
27
|
+
// ASCII,
|
|
28
|
+
// isWs, isEol, isDigit, isHex, isDelim, isRegular, hexNibble,
|
|
29
|
+
// HEX_LO,
|
|
30
|
+
// te, tdUtf8, tdUtf8Lenient, tdLatin1,
|
|
31
|
+
// encodeAscii, decodeUtf8, decodeUtf8Lenient, decodeLatin1,
|
|
32
|
+
// pad10, hexLit, bytesEqual, concatBytes }
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`pdfShared` is exported by name from the package root (`import { pdfShared }
|
|
36
|
+
from '@awacloud/pdf'`); it has no sub-path of its own.
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
| Member | Type | Description |
|
|
41
|
+
|--------|------|-------------|
|
|
42
|
+
| `HEADER_PREFIX` | `Uint8Array` | The 5 bytes `%PDF-`. |
|
|
43
|
+
| `EOF_MARKER` | `Uint8Array` | The 5 bytes `%%EOF`. |
|
|
44
|
+
| `BINARY_MARKER` | `Uint8Array` | The binary-marker comment line written after the header (§7.5.2): bytes `0x25 0xE2 0xE3 0xCF 0xD3 0x0A`. |
|
|
45
|
+
| `ASCII` | `object<string, number>` | Frozen byte values: `NUL`, `HT`, `LF`, `FF`, `CR`, `SP`, `HASH`, `PERCENT`, `LPAREN`, `RPAREN`, `PLUS`, `MINUS`, `DOT`, `SLASH`, `ZERO`, `NINE`, `LANGLE`, `RANGLE`, `A_UP`, `F_UP`, `Z_UP`, `LBRACK`, `BACKSLASH`, `RBRACK`, `A_LO`, `F_LO`, `Z_LO`, `LBRACE`, `RBRACE`. |
|
|
46
|
+
| `isWs(b)` | `(number) => boolean` | PDF white-space byte (`NUL`, `HT`, `LF`, `FF`, `CR`, `SP`), §7.2.3. |
|
|
47
|
+
| `isEol(b)` | `(number) => boolean` | `LF` or `CR`. |
|
|
48
|
+
| `isDigit(b)` | `(number) => boolean` | `0`–`9`. |
|
|
49
|
+
| `isHex(b)` | `(number) => boolean` | `0`–`9`, `A`–`F`, `a`–`f`. |
|
|
50
|
+
| `isDelim(b)` | `(number) => boolean` | A delimiter: `( ) < > [ ] { } / %`. |
|
|
51
|
+
| `isRegular(b)` | `(number) => boolean` | Neither white space nor a delimiter. |
|
|
52
|
+
| `hexNibble(b)` | `(number) => number` | The value of one hex digit byte, `-1` when `b` is not one. |
|
|
53
|
+
| `HEX_LO` | `Int8Array` (128 entries) | Lookup table with the same result as `hexNibble`, indexed by ASCII byte. |
|
|
54
|
+
| `te` | `TextEncoder` | One instance per factory call. |
|
|
55
|
+
| `tdUtf8` / `tdUtf8Lenient` | `TextDecoder` | UTF-8 decoders. Both are non-fatal (`fatal: false`, the `TextDecoder` default): a malformed sequence decodes to U+FFFD in either. |
|
|
56
|
+
| `tdLatin1` | `TextDecoder` | `latin1` decoder. |
|
|
57
|
+
| `encodeAscii(s)` | `(string) => Uint8Array` | `te.encode(s)` — UTF-8, so it equals ASCII only for an ASCII string. |
|
|
58
|
+
| `decodeUtf8(bytes)` / `decodeUtf8Lenient(bytes)` | `(Uint8Array) => string` | Wrappers over `tdUtf8` / `tdUtf8Lenient`. |
|
|
59
|
+
| `decodeLatin1(bytes)` | `(Uint8Array) => string` | Wrapper over `tdLatin1`. |
|
|
60
|
+
| `pad10(n)` | `(number) => string` | `n` left-padded with zeros to 10 digits (a cross-reference entry offset). |
|
|
61
|
+
| `hexLit(bytes)` | `(Uint8Array) => string` | The PDF hex-string literal `<…>`, upper-case digits. |
|
|
62
|
+
| `bytesEqual(a, b, n?)` | `(Uint8Array, Uint8Array, number?) => boolean` | Equality of two byte arrays without an early exit. Without `n`, both lengths must match; with `n`, compares the first `n` bytes and requires both arrays to be at least that long. `false` when either array is missing. |
|
|
63
|
+
| `concatBytes(arrays)` | `(Uint8Array[]) => Uint8Array` | One new array holding every input in order. |
|
|
64
|
+
|
|
65
|
+
## Examples
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
const shared = runtime.resolve('pdfShared');
|
|
69
|
+
|
|
70
|
+
shared.decodeLatin1(shared.HEADER_PREFIX); // '%PDF-'
|
|
71
|
+
shared.isWs(shared.ASCII.SP); // true
|
|
72
|
+
shared.hexNibble(0x61); // 10 ('a')
|
|
73
|
+
shared.hexLit(Uint8Array.of(0xde, 0xad)); // '<DEAD>'
|
|
74
|
+
shared.pad10(42); // '0000000042'
|
|
75
|
+
shared.bytesEqual(Uint8Array.of(1, 2, 3), Uint8Array.of(1, 2, 4), 2); // true
|
|
76
|
+
shared.concatBytes([Uint8Array.of(1), Uint8Array.of(2, 3)]); // Uint8Array [1, 2, 3]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Notes
|
|
80
|
+
|
|
81
|
+
- **Worker-safe**: every member is a constant, a pure function, or a codec
|
|
82
|
+
instance created inside the factory body, so `factory.toString()` is a
|
|
83
|
+
self-contained closure.
|
|
84
|
+
- **No mutable module state**: `ASCII` is frozen; each `factory()` call
|
|
85
|
+
creates its own codec instances and tables.
|
|
86
|
+
|
|
87
|
+
## See also
|
|
88
|
+
|
|
89
|
+
- [`pdfErrors`](../errors.md) — the other dependency-free core module.
|
|
90
|
+
- [`pdfTokenizer`](../syntax/tokenizer.md) — a consumer of the character classes.
|
|
91
|
+
- [API index](../README.md)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Actions — ISO 32000-2 §12.6
|
|
2
|
+
|
|
3
|
+
Actions executed from annotations, outlines, form fields.
|
|
4
|
+
|
|
5
|
+
| Module | Returns | Deps | Description |
|
|
6
|
+
|--------|----------|------|-------------|
|
|
7
|
+
| [`pdfAction`](./action.md) | `{ typeAction }` | `pdfErrors`, `pdfParser` | Dispatcher, §12.6. |
|
|
8
|
+
| [`pdfActionGoTo`](./goTo.md) | `{ typeGoTo, typeGoToR, typeGoToE }` | `pdfErrors`, `pdfParser` | §12.6.4.2–4. |
|
|
9
|
+
| [`pdfActionUri`](./uri.md) | `{ typeUri }` | `pdfErrors`, `pdfParser` | §12.6.4.7. |
|
|
10
|
+
| [`pdfActionNamed`](./named.md) | `{ typeNamed }` | `pdfErrors`, `pdfParser` | §12.6.4.11. |
|
|
11
|
+
| [`pdfActionLaunch`](./launch.md) | `{ typeLaunch }` | `pdfErrors`, `pdfParser` | §12.6.4.5. |
|
|
12
|
+
|
|
13
|
+
## Pattern
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
const a = runtime.resolve('pdfAction');
|
|
17
|
+
const typers = {
|
|
18
|
+
GoTo: runtime.resolve('pdfActionGoTo').typeGoTo,
|
|
19
|
+
GoToR: runtime.resolve('pdfActionGoTo').typeGoToR,
|
|
20
|
+
URI: runtime.resolve('pdfActionUri').typeUri,
|
|
21
|
+
Named: runtime.resolve('pdfActionNamed').typeNamed,
|
|
22
|
+
Launch:runtime.resolve('pdfActionLaunch').typeLaunch
|
|
23
|
+
};
|
|
24
|
+
const action = a.typeAction(dict, typers);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## See also
|
|
28
|
+
|
|
29
|
+
- [Destination](../destination/README.md) · [Outline](../outline/README.md) · [Annot — Link / Widget](../annot/README.md)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfAction
|
|
3
|
+
category: pdf/action
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfAction
|
|
11
|
+
|
|
12
|
+
> Action dispatcher — ISO 32000-2 §12.6, walks `/Next` with cycle protection.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfAction` | **Source** `packages/front/office/pdf/src/action/action.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
`typeAction(dict, typers, opts)` dispatches on `/S` to the specialized typer supplied in `typers` (`GoTo`, `GoToR`, `GoToE`, `URI`, `Named`, `Launch`, …). When no matching typer is supplied, falls back to a generic `{ kind, raw, _extras }` record — additionally flagged `vendor: true` when `/S` is outside the set of standard action kinds this module recognizes by name (Thread, Sound, Movie, Hide, SubmitForm, ResetForm, ImportData, SetOCGState, Rendition, Trans, GoTo3DView, GoToDp, JavaScript, RichMediaExecute, plus the ones with dedicated typers). Follows the `/Next` chain (recursive, either a single dict or an array) bounded by depth (`opts.maxDepth`, default **16**) and detecting cycles via a `Set` of already-visited dict objects.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const a = runtime.resolve('pdfAction');
|
|
22
|
+
// Returns: { typeAction }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Method | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `typeAction` | `(dict, typers, opts?: { maxDepth? }) => Action` | Dispatched record + `next` chain. |
|
|
30
|
+
|
|
31
|
+
`typers` is a dict `{ GoTo: fn, GoToR: fn, URI: fn, Named: fn, Launch: fn, … }` — typically composed from the other action modules.
|
|
32
|
+
|
|
33
|
+
### Shape `Action`
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
{ kind, /* fields per typer, or { raw, _extras, vendor? } for unrecognized/generic kinds */, next?: Action[] }
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
### Composing the typers
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
const a = runtime.resolve('pdfAction');
|
|
45
|
+
const goTo = runtime.resolve('pdfActionGoTo');
|
|
46
|
+
const uri = runtime.resolve('pdfActionUri');
|
|
47
|
+
const typers = {
|
|
48
|
+
GoTo: goTo.typeGoTo,
|
|
49
|
+
GoToR: goTo.typeGoToR,
|
|
50
|
+
URI: uri.typeUri,
|
|
51
|
+
Named: runtime.resolve('pdfActionNamed').typeNamed,
|
|
52
|
+
Launch:runtime.resolve('pdfActionLaunch').typeLaunch
|
|
53
|
+
};
|
|
54
|
+
const action = a.typeAction(dict, typers);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Walking the action chain
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
let cur = action;
|
|
61
|
+
while (cur) {
|
|
62
|
+
console.log(cur.kind);
|
|
63
|
+
cur = cur.next ? cur.next[0] : null;
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Errors
|
|
68
|
+
|
|
69
|
+
| Code | Class | When |
|
|
70
|
+
|------|--------|------|
|
|
71
|
+
| `pdf/action/max-depth` | `ParseError` | `/Next` chain exceeds `opts.maxDepth`. |
|
|
72
|
+
| `pdf/action/not-dict` | `ParseError` | Argument is not a dict. |
|
|
73
|
+
| `pdf/action/cycle` | `ParseError` | Action already visited. |
|
|
74
|
+
| `pdf/action/bad-type` | `ParseError` | `/Type` ≠ `/Action`. |
|
|
75
|
+
| `pdf/action/missing-s` | `ParseError` | `/S` absent. |
|
|
76
|
+
| `pdf/action/bad-next` | `ParseError` | `/Next` is neither a dict nor an array. |
|
|
77
|
+
|
|
78
|
+
## See also
|
|
79
|
+
|
|
80
|
+
- [`pdfActionGoTo`](./goTo.md) · [`pdfActionUri`](./uri.md) · [`pdfActionNamed`](./named.md) · [`pdfActionLaunch`](./launch.md)
|
|
81
|
+
- [`pdfLinkAnnot`](../annot/link.md) · [`pdfWidgetAnnot`](../annot/widget.md)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfActionGoTo
|
|
3
|
+
category: pdf/action
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfActionGoTo
|
|
11
|
+
|
|
12
|
+
> GoTo / GoToR / GoToE — ISO 32000-2 §12.6.4.2 / §12.6.4.3 / §12.6.4.4.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfActionGoTo` | **Source** `packages/front/office/pdf/src/action/goTo.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
Three navigation variants:
|
|
17
|
+
- **GoTo** (`/S /GoTo`) — destination inside the current document, `/D` entry.
|
|
18
|
+
- **GoToR** (`/S /GoToR`) — remote file, `/F` (file spec) and `/D` entries, optional `/NewWindow`.
|
|
19
|
+
- **GoToE** (`/S /GoToE`) — embedded file, `/D` entry plus optional `/F` and `/T` (target dict), optional `/NewWindow`.
|
|
20
|
+
|
|
21
|
+
## Resolve
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
const goto = runtime.resolve('pdfActionGoTo');
|
|
25
|
+
// Returns: { typeGoTo, typeGoToR, typeGoToE }
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API
|
|
29
|
+
|
|
30
|
+
| Method | Signature | Returns |
|
|
31
|
+
|--------|-----------|---------|
|
|
32
|
+
| `typeGoTo` | `(dict) => { kind: 'GoTo', dest, raw }` | Internal destination. |
|
|
33
|
+
| `typeGoToR` | `(dict) => { kind: 'GoToR', file, dest, newWindow?, raw }` | Remote file. |
|
|
34
|
+
| `typeGoToE` | `(dict) => { kind: 'GoToE', dest, file?, target?, newWindow?, raw }` | Embedded file. |
|
|
35
|
+
|
|
36
|
+
## Examples
|
|
37
|
+
|
|
38
|
+
### Internal link via outline
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
const a = runtime.resolve('pdfActionGoTo').typeGoTo(actionDict);
|
|
42
|
+
const d = runtime.resolve('pdfDestination').typeDestination(a.dest, names, resolveRef);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Remote link
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
const a = runtime.resolve('pdfActionGoTo').typeGoToR(actionDict);
|
|
49
|
+
a.file; // file spec (/F)
|
|
50
|
+
a.dest; // destination inside the remote document (/D)
|
|
51
|
+
a.newWindow; // boolean, when /NewWindow is present
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Errors
|
|
55
|
+
|
|
56
|
+
| Code | Class | When |
|
|
57
|
+
|------|--------|------|
|
|
58
|
+
| `pdf/action/goto/missing-d` | `ParseError` | `/D` absent. |
|
|
59
|
+
| `pdf/action/gotor/missing-f` | `ParseError` | `/F` absent. |
|
|
60
|
+
| `pdf/action/gotor/missing-d` | `ParseError` | `/D` absent. |
|
|
61
|
+
| `pdf/action/gotoe/missing-d` | `ParseError` | `/D` absent. |
|
|
62
|
+
| `pdf/action/goto/not-dict` · `gotor/not-dict` · `gotoe/not-dict` | `ParseError` | Argument is not a dict. |
|
|
63
|
+
|
|
64
|
+
## See also
|
|
65
|
+
|
|
66
|
+
- [`pdfAction`](./action.md) · [`pdfDestination`](../destination/destination.md) · [`pdfFileSpec`](../embedded/fileSpec.md)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfActionLaunch
|
|
3
|
+
category: pdf/action
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfActionLaunch
|
|
11
|
+
|
|
12
|
+
> Launch action — ISO 32000-2 §12.6.4.5.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfActionLaunch` | **Source** `packages/front/office/pdf/src/action/launch.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
`/S /Launch` action — requests launching an external application. `/F` (file spec) or the platform-specific `/Win`/`/Mac`/`/Unix` entries. Optional `/NewWindow` boolean. **Major attack surface** — this module **never executes anything**; it always returns `sandboxed: true` and a `securityWarning` string alongside the typed entries, so the host application decides what to do (typically: ignore, or prompt the user).
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const launch = runtime.resolve('pdfActionLaunch');
|
|
22
|
+
// Returns: { typeLaunch }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Method | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `typeLaunch` | `(dict) => { kind: 'Launch', sandboxed: true, securityWarning: string, file?, win?, mac?, unix?, newWindow?, raw }` | Typing only — no execution. |
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
### Inspection without execution
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
const a = runtime.resolve('pdfActionLaunch').typeLaunch(actionDict);
|
|
37
|
+
console.warn('Launch action present', a.file); // refused by default
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Filtering in a viewer
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
function safeDispatch(action) {
|
|
44
|
+
if (action.kind === 'Launch') return false;
|
|
45
|
+
// …
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Errors
|
|
50
|
+
|
|
51
|
+
| Code | Class | When |
|
|
52
|
+
|------|--------|------|
|
|
53
|
+
| `pdf/action/launch/not-dict` | `ParseError` | Argument is not a dict. |
|
|
54
|
+
| `pdf/action/launch/empty` | `ParseError` | No target at all (`/F`, `/Win`, `/Mac`, `/Unix` all absent). |
|
|
55
|
+
|
|
56
|
+
## See also
|
|
57
|
+
|
|
58
|
+
- [`pdfAction`](./action.md) · [`pdfFileSpec`](../embedded/fileSpec.md)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfActionNamed
|
|
3
|
+
category: pdf/action
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfActionNamed
|
|
11
|
+
|
|
12
|
+
> Named action — ISO 32000-2 §12.6.4.11.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfActionNamed` | **Source** `packages/front/office/pdf/src/action/named.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
`/S /Named` action — invokes a predefined viewer command. Requires `/N`. Standard names per §12.6.4.11: `NextPage`, `PrevPage`, `FirstPage`, `LastPage`; vendor-defined names are accepted but flagged via `standard: false`. PDF readers often extend the set with `GoBack`, `GoForward`, `GoToPage`, `Find`, `Print`, `SaveAs`.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const named = runtime.resolve('pdfActionNamed');
|
|
22
|
+
// Returns: { typeNamed }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Method | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `typeNamed` | `(dict) => { kind: 'Named', name: string, standard: boolean, raw }` | Typing. |
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
const a = runtime.resolve('pdfActionNamed').typeNamed(actionDict);
|
|
35
|
+
switch (a.name) {
|
|
36
|
+
case 'NextPage': viewer.next(); break;
|
|
37
|
+
case 'PrevPage': viewer.prev(); break;
|
|
38
|
+
case 'FirstPage': viewer.first(); break;
|
|
39
|
+
case 'LastPage': viewer.last(); break;
|
|
40
|
+
default:
|
|
41
|
+
if (!a.standard) console.warn('vendor-defined named action', a.name);
|
|
42
|
+
viewer.invokeNamed(a.name);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Errors
|
|
47
|
+
|
|
48
|
+
| Code | Class | When |
|
|
49
|
+
|------|--------|------|
|
|
50
|
+
| `pdf/action/named/not-dict` | `ParseError` | Argument is not a dict. |
|
|
51
|
+
| `pdf/action/named/missing-n` | `ParseError` | `/N` absent or not a name. |
|
|
52
|
+
|
|
53
|
+
## See also
|
|
54
|
+
|
|
55
|
+
- [`pdfAction`](./action.md)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfActionUri
|
|
3
|
+
category: pdf/action
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfActionUri
|
|
11
|
+
|
|
12
|
+
> URI action — ISO 32000-2 §12.6.4.7.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfActionUri` | **Source** `packages/front/office/pdf/src/action/uri.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
`/S /URI` action — opens an external resource (HTTP, mailto, …). Requires `/URI` (ASCII string), optional `/IsMap` boolean (for server-side image maps). Note: the factory only actually uses its `errors` parameter (a self-contained `isType` helper is inlined so the module tolerates a stub `parser`), even though `pdfParser` is declared as a dependency.
|
|
17
|
+
|
|
18
|
+
## Resolve
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
const uri = runtime.resolve('pdfActionUri');
|
|
22
|
+
// Returns: { typeUri }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
| Method | Signature | Returns |
|
|
28
|
+
|--------|-----------|---------|
|
|
29
|
+
| `typeUri` | `(dict) => { kind: 'URI', uri: string, isMap?: boolean, raw }` | Typing. |
|
|
30
|
+
|
|
31
|
+
## Examples
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
const a = runtime.resolve('pdfActionUri').typeUri(actionDict);
|
|
35
|
+
a.uri; // 'https://example.com'
|
|
36
|
+
window.open(a.uri, a.isMap ? '_blank' : '_self');
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Sanitization
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
if (a.uri.startsWith('javascript:')) reject();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Errors
|
|
46
|
+
|
|
47
|
+
| Code | Class | When |
|
|
48
|
+
|------|--------|------|
|
|
49
|
+
| `pdf/action/uri/not-dict` | `ParseError` | Argument is not a dict. |
|
|
50
|
+
| `pdf/action/uri/missing` | `ParseError` | `/URI` absent or not a string. |
|
|
51
|
+
|
|
52
|
+
## See also
|
|
53
|
+
|
|
54
|
+
- [`pdfAction`](./action.md) · [`pdfLinkAnnot`](../annot/link.md)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Annotations — ISO 32000-2 §12.5
|
|
2
|
+
|
|
3
|
+
Interactive annotation layer: a generic dispatcher plus one typer per
|
|
4
|
+
subtype.
|
|
5
|
+
|
|
6
|
+
| Module | Returns | Deps | Description |
|
|
7
|
+
|--------|---------|------|-------------|
|
|
8
|
+
| [`pdfAnnot`](./annot.md) | `{ BASE_KEYS, typeBaseAnnot, captureExtras, typeAnnot }` | `pdfErrors`, `pdfParser` | Dispatcher §12.5.2. |
|
|
9
|
+
| [`pdfTextAnnot`](./text.md) | `{ typeTextAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | Sticky note §12.5.6.4. |
|
|
10
|
+
| [`pdfLinkAnnot`](./link.md) | `{ typeLinkAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | Hyperlink §12.5.6.5. |
|
|
11
|
+
| [`pdfMarkupAnnot`](./markup.md) | `{ typeMarkupAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | Highlight/Underline/… §12.5.6.10. |
|
|
12
|
+
| [`pdfShapeAnnot`](./square.md) | `{ typeShapeAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | Line/Square/Circle/Polygon §12.5.6.7–9. |
|
|
13
|
+
| [`pdfFreeTextAnnot`](./freeText.md) | `{ typeFreeTextAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | Free text §12.5.6.6. |
|
|
14
|
+
| [`pdfInkAnnot`](./ink.md) | `{ typeInkAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | Freehand ink §12.5.6.13. |
|
|
15
|
+
| [`pdfStampAnnot`](./stamp.md) | `{ typeStampAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | Rubber stamp §12.5.6.12. |
|
|
16
|
+
| [`pdfFileAttachAnnot`](./fileAttach.md) | `{ typeFileAttachAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | File attachment §12.5.6.15. |
|
|
17
|
+
| [`pdfWidgetAnnot`](./widget.md) | `{ typeWidgetAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | Form widget §12.5.6.19. |
|
|
18
|
+
| [`pdfPopupAnnot`](./popup.md) | `{ typePopupAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | Pop-up §12.5.6.14. |
|
|
19
|
+
| [`pdfProjectionAnnot`](./projection.md) | `{ typeProjectionAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | 3D measurement §12.5.6.23. |
|
|
20
|
+
| [`pdfRedactAnnot`](./redact.md) | `{ typeRedactAnnot }` | `pdfErrors`, `pdfParser`, `pdfAnnot` | Redaction (ISO TS 32005). |
|
|
21
|
+
|
|
22
|
+
## Common pattern
|
|
23
|
+
|
|
24
|
+
`typeAnnot` takes a second argument — a **typers map** wiring each subtype
|
|
25
|
+
family to its specialised typer. Omit it and every subtype falls back to
|
|
26
|
+
base typing (`typeBaseAnnot` plus a full `_extras` capture).
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
const annot = runtime.resolve('pdfAnnot');
|
|
30
|
+
const typers = {
|
|
31
|
+
Text: runtime.resolve('pdfTextAnnot').typeTextAnnot,
|
|
32
|
+
Link: runtime.resolve('pdfLinkAnnot').typeLinkAnnot,
|
|
33
|
+
Markup: runtime.resolve('pdfMarkupAnnot').typeMarkupAnnot,
|
|
34
|
+
Shape: runtime.resolve('pdfShapeAnnot').typeShapeAnnot,
|
|
35
|
+
FreeText: runtime.resolve('pdfFreeTextAnnot').typeFreeTextAnnot,
|
|
36
|
+
Ink: runtime.resolve('pdfInkAnnot').typeInkAnnot,
|
|
37
|
+
Stamp: runtime.resolve('pdfStampAnnot').typeStampAnnot,
|
|
38
|
+
Popup: runtime.resolve('pdfPopupAnnot').typePopupAnnot,
|
|
39
|
+
FileAttachment: runtime.resolve('pdfFileAttachAnnot').typeFileAttachAnnot,
|
|
40
|
+
Widget: runtime.resolve('pdfWidgetAnnot').typeWidgetAnnot,
|
|
41
|
+
Redact: runtime.resolve('pdfRedactAnnot').typeRedactAnnot,
|
|
42
|
+
Projection: runtime.resolve('pdfProjectionAnnot').typeProjectionAnnot
|
|
43
|
+
};
|
|
44
|
+
for (const ref of page.annots) {
|
|
45
|
+
const a = annot.typeAnnot(doc._raw.resolve(ref), typers);
|
|
46
|
+
switch (a.kind) { /* … */ }
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## See also
|
|
51
|
+
|
|
52
|
+
- [Document layer](../document/README.md) — `pdfPage.annots`.
|
|
53
|
+
- [Form](../form/README.md) — `/Widget` is a special case.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
module: pdfAnnot
|
|
3
|
+
category: pdf/annot
|
|
4
|
+
dependencies: [pdfErrors, pdfParser]
|
|
5
|
+
returns: object
|
|
6
|
+
worker-safe: true
|
|
7
|
+
status: complete
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# pdfAnnot
|
|
11
|
+
|
|
12
|
+
> Annotation orchestrator — ISO 32000-2 §12.5, dispatch on `/Subtype`.
|
|
13
|
+
|
|
14
|
+
**Module** `pdfAnnot` | **Source** `packages/front/office/pdf/src/annot/annot.js` | **Deps** `pdfErrors`, `pdfParser` | **Worker-safe** yes
|
|
15
|
+
|
|
16
|
+
`typeAnnot` reads a `/Type /Annot` dictionary (§12.5.2 Table 166) and delegates
|
|
17
|
+
to a specialised typer selected by `/Subtype`: `Text`, `Link`, `FreeText`,
|
|
18
|
+
`Line`/`Square`/`Circle`/`Polygon`/`PolyLine`,
|
|
19
|
+
`Highlight`/`Underline`/`Squiggly`/`StrikeOut`/`Caret`, `Stamp`, `Ink`, `Popup`,
|
|
20
|
+
`FileAttachment`, `Widget`, `Redact`, `Projection`. Those delegates are supplied
|
|
21
|
+
by the caller through the second `typers` argument — when it is missing, or when
|
|
22
|
+
the relevant slot is not a function, the subtype falls back to base typing plus a
|
|
23
|
+
full `_extras` capture. The known-but-unhandled subtypes (`Sound`, `Movie`,
|
|
24
|
+
`Screen`, `PrinterMark`, `TrapNet`, `Watermark`, `3D`, `RichMedia`) always take
|
|
25
|
+
that fallback; any other name returns `{ kind, raw, _extras }` with every
|
|
26
|
+
dictionary entry copied into `_extras`.
|
|
27
|
+
|
|
28
|
+
`typeBaseAnnot` factors out the entries common to every annotation (`/Rect`,
|
|
29
|
+
`/Contents`, `/P`, `/NM`, `/M`, `/F`, `/AP`, `/AS`, `/Border`, `/C`,
|
|
30
|
+
`/StructParent`, `/OC`, `/AF`, `/CA`, `/BS`, `/BE`) — exactly the names held by
|
|
31
|
+
the exported `BASE_KEYS` set, plus `/Type` and `/Subtype`.
|
|
32
|
+
|
|
33
|
+
## Resolve
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
const annot = runtime.resolve('pdfAnnot');
|
|
37
|
+
// Returns: { BASE_KEYS, typeBaseAnnot, captureExtras, typeAnnot }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
| Member | Signature | Returns |
|
|
43
|
+
|--------|-----------|---------|
|
|
44
|
+
| `BASE_KEYS` | `Set<string>` | The 18 base `/Type /Annot` keys consumed by `typeBaseAnnot`. |
|
|
45
|
+
| `typeBaseAnnot` | `(dict) => BaseAnnot` | §12.5.2 entries only. |
|
|
46
|
+
| `captureExtras` | `(target, dict, known) => void` | Copies every entry outside `BASE_KEYS` and outside the optional `known` set into `target._extras`. Used by every subtype typer. |
|
|
47
|
+
| `typeAnnot` | `(dict, typers?) => Annotation` | Typed record carrying `kind`, derived from `/Subtype`. |
|
|
48
|
+
|
|
49
|
+
### The `typers` map
|
|
50
|
+
|
|
51
|
+
Keys are typer *families*, not subtype names — `Shape` covers
|
|
52
|
+
`Line`/`Square`/`Circle`/`Polygon`/`PolyLine`, `Markup` covers
|
|
53
|
+
`Highlight`/`Underline`/`Squiggly`/`StrikeOut`/`Caret`, and both receive the
|
|
54
|
+
expected subtype as a second argument:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
{ Text, Link, FreeText, Shape, Markup, Stamp, Ink, Popup,
|
|
58
|
+
FileAttachment, Widget, Redact, Projection }
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### `BaseAnnot` shape
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
{
|
|
65
|
+
subtype, rect: [llx,lly,urx,ury]|null, contents, p: {num,gen}|null,
|
|
66
|
+
nm, m, f: number, // /F flags (bit 1 Invisible, 2 Hidden, …)
|
|
67
|
+
ap, as, border, c, // /AP /AS /Border /C
|
|
68
|
+
structParent, oc, af, ca,
|
|
69
|
+
bs, be, raw, _extras
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Examples
|
|
74
|
+
|
|
75
|
+
### Dispatch an annotation
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
const annot = runtime.resolve('pdfAnnot');
|
|
79
|
+
const typers = { Text: runtime.resolve('pdfTextAnnot').typeTextAnnot };
|
|
80
|
+
for (const ref of page.annots) {
|
|
81
|
+
const a = annot.typeAnnot(doc._raw.resolve(ref), typers);
|
|
82
|
+
a.kind; // 'Text' | 'Link' | 'Highlight' | …
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Base typing only
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
const base = annot.typeBaseAnnot(dict);
|
|
90
|
+
base.rect; // [llx, lly, urx, ury]
|
|
91
|
+
base.f & 0x02; // Hidden flag
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Unknown subtype
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
const a = annot.typeAnnot(weirdDict);
|
|
98
|
+
a.kind === 'CustomVendor'; // preserved; _extras holds every entry
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Errors
|
|
102
|
+
|
|
103
|
+
| Code | Class | When |
|
|
104
|
+
|------|-------|------|
|
|
105
|
+
| `pdf/annot/not-dict` | `ParseError` | Argument is not a dictionary. |
|
|
106
|
+
| `pdf/annot/bad-type` | `ParseError` | `/Type` present but not `/Annot`. |
|
|
107
|
+
| `pdf/annot/missing-subtype` | `ParseError` | `/Subtype` missing or not a name (`typeAnnot` only). |
|
|
108
|
+
|
|
109
|
+
## See also
|
|
110
|
+
|
|
111
|
+
- [`pdfTextAnnot`](./text.md) · [`pdfLinkAnnot`](./link.md) · [`pdfMarkupAnnot`](./markup.md) · [`pdfShapeAnnot`](./square.md)
|
|
112
|
+
- [`pdfFreeTextAnnot`](./freeText.md) · [`pdfInkAnnot`](./ink.md) · [`pdfStampAnnot`](./stamp.md) · [`pdfFileAttachAnnot`](./fileAttach.md)
|
|
113
|
+
- [`pdfWidgetAnnot`](./widget.md) · [`pdfPopupAnnot`](./popup.md) · [`pdfProjectionAnnot`](./projection.md) · [`pdfRedactAnnot`](./redact.md)
|
|
114
|
+
- [`pdfPage`](../document/page.md)
|