@laminapdf/sdk 0.2.0-alpha.2 → 0.2.0-alpha.4
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/README.md +63 -8
- package/dist/api.d.ts +8 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +4 -2
- package/dist/api.js.map +1 -1
- package/dist/builder.d.ts +43 -22
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +122 -83
- package/dist/builder.js.map +1 -1
- package/dist/document.d.ts +89 -22
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +177 -67
- package/dist/document.js.map +1 -1
- package/dist/errors.d.ts +5 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -16
- package/dist/errors.js.map +1 -1
- package/dist/extract-job.d.ts +100 -0
- package/dist/extract-job.d.ts.map +1 -0
- package/dist/extract-job.js +177 -0
- package/dist/extract-job.js.map +1 -0
- package/dist/extract.d.ts +57 -0
- package/dist/extract.d.ts.map +1 -0
- package/dist/extract.js +5 -0
- package/dist/extract.js.map +1 -0
- package/dist/font.d.ts +13 -6
- package/dist/font.d.ts.map +1 -1
- package/dist/font.js +50 -20
- package/dist/font.js.map +1 -1
- package/dist/generated/builder-enums.d.ts +3 -3
- package/dist/generated/builder-enums.d.ts.map +1 -1
- package/dist/generated/builder-enums.js +10 -0
- package/dist/generated/builder-enums.js.map +1 -1
- package/dist/generated/codes.d.ts +18 -6
- package/dist/generated/codes.d.ts.map +1 -1
- package/dist/generated/codes.js +114 -5
- package/dist/generated/codes.js.map +1 -1
- package/dist/generated/explain.d.ts.map +1 -1
- package/dist/generated/explain.js +45 -11
- package/dist/generated/explain.js.map +1 -1
- package/dist/generated/extract.d.ts +282 -0
- package/dist/generated/extract.d.ts.map +1 -0
- package/dist/generated/extract.js +4 -0
- package/dist/generated/extract.js.map +1 -0
- package/dist/init.d.ts +13 -5
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +23 -11
- package/dist/init.js.map +1 -1
- package/dist/internal/handle.d.ts +58 -0
- package/dist/internal/handle.d.ts.map +1 -0
- package/dist/internal/handle.js +113 -0
- package/dist/internal/handle.js.map +1 -0
- package/dist/internal/instance.d.ts +56 -0
- package/dist/internal/instance.d.ts.map +1 -0
- package/dist/internal/instance.js +125 -0
- package/dist/internal/instance.js.map +1 -0
- package/dist/source/http.d.ts +1 -1
- package/dist/source/http.js +2 -2
- package/dist/source/http.js.map +1 -1
- package/dist/source/range.d.ts +6 -1
- package/dist/source/range.d.ts.map +1 -1
- package/dist/source/range.js +10 -6
- package/dist/source/range.js.map +1 -1
- package/dist/text.d.ts +3 -3
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +3 -3
- package/dist/text.js.map +1 -1
- package/dist/types.d.ts +19 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -2
- package/dist/version.js.map +1 -1
- package/dist/worker/client.d.ts +3 -2
- package/dist/worker/client.d.ts.map +1 -1
- package/dist/worker/client.js +6 -4
- package/dist/worker/client.js.map +1 -1
- package/dist/worker/entry.js +1 -1
- package/dist/worker/entry.js.map +1 -1
- package/dist/worker/server.d.ts.map +1 -1
- package/dist/worker/server.js +42 -9
- package/dist/worker/server.js.map +1 -1
- package/dist/worker/support.d.ts +13 -3
- package/dist/worker/support.d.ts.map +1 -1
- package/dist/worker/support.js +5 -0
- package/dist/worker/support.js.map +1 -1
- package/dist/worker/types.d.ts +8 -1
- package/dist/worker/types.d.ts.map +1 -1
- package/docs/AGENTS.md +14 -0
- package/docs/api/README.md +166 -0
- package/docs/api/classes/Builder.md +467 -0
- package/docs/api/classes/Document.md +854 -0
- package/docs/api/classes/ExtractJob.md +236 -0
- package/docs/api/classes/Font.md +74 -0
- package/docs/api/classes/Image.md +140 -0
- package/docs/api/classes/LaminaPdfError.md +189 -0
- package/docs/api/classes/Page.md +178 -0
- package/docs/api/classes/PageRef.md +253 -0
- package/docs/api/classes/PageText.md +129 -0
- package/docs/api/classes/PageTextRun.md +167 -0
- package/docs/api/classes/PendingPath.md +97 -0
- package/docs/api/classes/SaveJob.md +205 -0
- package/docs/api/classes/Surface.md +331 -0
- package/docs/api/classes/Transaction.md +111 -0
- package/docs/api/functions/callbackSource.md +33 -0
- package/docs/api/functions/extractWithModels.md +70 -0
- package/docs/api/functions/httpRangeSource.md +48 -0
- package/docs/api/functions/init.md +36 -0
- package/docs/api/functions/isExtractLoaded.md +21 -0
- package/docs/api/functions/isInitialized.md +19 -0
- package/docs/api/functions/isLaminaPdfError.md +41 -0
- package/docs/api/functions/isTextLoaded.md +19 -0
- package/docs/api/functions/loadExtract.md +28 -0
- package/docs/api/functions/loadText.md +28 -0
- package/docs/api/functions/onLeak.md +29 -0
- package/docs/api/functions/reset.md +22 -0
- package/docs/api/functions/wasmMemory.md +22 -0
- package/docs/api/interfaces/BuilderOptions.md +108 -0
- package/docs/api/interfaces/ByteRange.md +29 -0
- package/docs/api/interfaces/ChunkOptions.md +37 -0
- package/docs/api/interfaces/Diagnostic.md +67 -0
- package/docs/api/interfaces/ExtractOptions.md +92 -0
- package/docs/api/interfaces/ExtractResult.md +37 -0
- package/docs/api/interfaces/FontInfo.md +37 -0
- package/docs/api/interfaces/HostModels.md +57 -0
- package/docs/api/interfaces/HttpRangeOptions.md +78 -0
- package/docs/api/interfaces/InitOptions.md +40 -0
- package/docs/api/interfaces/LayoutRegion.md +38 -0
- package/docs/api/interfaces/Leak.md +21 -0
- package/docs/api/interfaces/Location.md +53 -0
- package/docs/api/interfaces/ModelInfo.md +45 -0
- package/docs/api/interfaces/ModelRequest.md +45 -0
- package/docs/api/interfaces/Models.md +45 -0
- package/docs/api/interfaces/OcrWord.md +37 -0
- package/docs/api/interfaces/OpLog.md +25 -0
- package/docs/api/interfaces/OpenOptions.md +37 -0
- package/docs/api/interfaces/PageTextOptions.md +21 -0
- package/docs/api/interfaces/PathBuilder.md +195 -0
- package/docs/api/interfaces/QuadPoint.md +25 -0
- package/docs/api/interfaces/RangeOptions.md +54 -0
- package/docs/api/interfaces/RangeSource.md +59 -0
- package/docs/api/interfaces/StrokeStyle.md +61 -0
- package/docs/api/interfaces/TagSpec.md +69 -0
- package/docs/api/interfaces/TextBoxOptions.md +93 -0
- package/docs/api/interfaces/TextGlyph.md +29 -0
- package/docs/api/interfaces/TextOptions.md +101 -0
- package/docs/api/interfaces/WasmMemory.md +37 -0
- package/docs/api/type-aliases/AfRelationship.md +15 -0
- package/docs/api/type-aliases/Align.md +15 -0
- package/docs/api/type-aliases/ArtifactKind.md +15 -0
- package/docs/api/type-aliases/AttachmentOptions.md +15 -0
- package/docs/api/type-aliases/BlendMode.md +15 -0
- package/docs/api/type-aliases/BoxRect.md +15 -0
- package/docs/api/type-aliases/BuildOptions.md +15 -0
- package/docs/api/type-aliases/Cell.md +71 -0
- package/docs/api/type-aliases/Chunk.md +79 -0
- package/docs/api/type-aliases/Color.md +16 -0
- package/docs/api/type-aliases/Coordinates.md +55 -0
- package/docs/api/type-aliases/Direction.md +15 -0
- package/docs/api/type-aliases/DocumentInfo.md +15 -0
- package/docs/api/type-aliases/DropReason.md +15 -0
- package/docs/api/type-aliases/Dropped.md +59 -0
- package/docs/api/type-aliases/Edited.md +15 -0
- package/docs/api/type-aliases/ErrorCode.md +15 -0
- package/docs/api/type-aliases/ErrorKind.md +15 -0
- package/docs/api/type-aliases/ExtractFormat.md +15 -0
- package/docs/api/type-aliases/ExtractJobOptions.md +31 -0
- package/docs/api/type-aliases/ExtractStep.md +61 -0
- package/docs/api/type-aliases/ExtractedBlock.md +94 -0
- package/docs/api/type-aliases/ExtractedPage.md +73 -0
- package/docs/api/type-aliases/ExtractedSource.md +48 -0
- package/docs/api/type-aliases/Extraction.md +22 -0
- package/docs/api/type-aliases/FillRule.md +15 -0
- package/docs/api/type-aliases/Fit.md +15 -0
- package/docs/api/type-aliases/Flags.md +15 -0
- package/docs/api/type-aliases/Generator.md +43 -0
- package/docs/api/type-aliases/GlyphQuad.md +15 -0
- package/docs/api/type-aliases/InfoPatch.md +15 -0
- package/docs/api/type-aliases/LaminaPdfWarning.md +16 -0
- package/docs/api/type-aliases/LimitName.md +15 -0
- package/docs/api/type-aliases/Limits.md +15 -0
- package/docs/api/type-aliases/LineBox.md +15 -0
- package/docs/api/type-aliases/LineCap.md +15 -0
- package/docs/api/type-aliases/LineJoin.md +15 -0
- package/docs/api/type-aliases/LinkTarget.md +15 -0
- package/docs/api/type-aliases/Metadata.md +15 -0
- package/docs/api/type-aliases/ModelResult.md +15 -0
- package/docs/api/type-aliases/Op.md +15 -0
- package/docs/api/type-aliases/OutlineEntry.md +15 -0
- package/docs/api/type-aliases/OutlineNode.md +15 -0
- package/docs/api/type-aliases/Overflow.md +15 -0
- package/docs/api/type-aliases/PageInfo.md +15 -0
- package/docs/api/type-aliases/PageLabel.md +15 -0
- package/docs/api/type-aliases/PageSizeName.md +15 -0
- package/docs/api/type-aliases/Point.md +15 -0
- package/docs/api/type-aliases/Profile.md +15 -0
- package/docs/api/type-aliases/Progress.md +15 -0
- package/docs/api/type-aliases/ReadingOrder.md +15 -0
- package/docs/api/type-aliases/Rect.md +15 -0
- package/docs/api/type-aliases/Region.md +31 -0
- package/docs/api/type-aliases/RegionLabel.md +15 -0
- package/docs/api/type-aliases/RenderMode.md +15 -0
- package/docs/api/type-aliases/Rotation.md +15 -0
- package/docs/api/type-aliases/SaveOptions.md +15 -0
- package/docs/api/type-aliases/SaveReport.md +15 -0
- package/docs/api/type-aliases/Span.md +74 -0
- package/docs/api/type-aliases/SplitOn.md +15 -0
- package/docs/api/type-aliases/Standard14.md +15 -0
- package/docs/api/type-aliases/StructRef.md +41 -0
- package/docs/api/type-aliases/StructSource.md +17 -0
- package/docs/api/type-aliases/StructureKid.md +15 -0
- package/docs/api/type-aliases/StructureNode.md +16 -0
- package/docs/api/type-aliases/TableDetector.md +15 -0
- package/docs/api/type-aliases/TableMode.md +15 -0
- package/docs/api/type-aliases/TableScope.md +15 -0
- package/docs/api/type-aliases/Tag.md +15 -0
- package/docs/api/type-aliases/TagName.md +15 -0
- package/docs/api/type-aliases/Target.md +15 -0
- package/docs/api/type-aliases/TargetView.md +18 -0
- package/docs/api/type-aliases/TextLayer.md +72 -0
- package/docs/api/type-aliases/TextLayerStatus.md +15 -0
- package/docs/api/type-aliases/TextLayout.md +15 -0
- package/docs/api/type-aliases/TextRange.md +33 -0
- package/docs/api/type-aliases/TextRunInfo.md +15 -0
- package/docs/api/type-aliases/Transform.md +15 -0
- package/docs/api/type-aliases/UndoOutcome.md +15 -0
- package/docs/api/type-aliases/ViewerPreferences.md +15 -0
- package/docs/api/type-aliases/WarningCode.md +15 -0
- package/docs/api/type-aliases/WasmSource.md +16 -0
- package/docs/api/variables/Matrix.md +99 -0
- package/docs/api/variables/PAGE_SIZES.md +15 -0
- package/docs/api/variables/TAG_NAMES.md +15 -0
- package/docs/errors/README.md +173 -0
- package/docs/errors/aes-padding-invalid.md +34 -0
- package/docs/errors/already-initialized.md +34 -0
- package/docs/errors/binary-output-to-terminal.md +35 -0
- package/docs/errors/builder-finished.md +35 -0
- package/docs/errors/cancelled.md +35 -0
- package/docs/errors/cmap-invalid.md +42 -0
- package/docs/errors/collection-index.md +33 -0
- package/docs/errors/color-components.md +33 -0
- package/docs/errors/content-bad-operands.md +36 -0
- package/docs/errors/content-path-unpainted.md +36 -0
- package/docs/errors/content-resource-missing.md +37 -0
- package/docs/errors/content-syntax.md +36 -0
- package/docs/errors/content-unbalanced-bt.md +36 -0
- package/docs/errors/content-unbalanced-marked.md +36 -0
- package/docs/errors/content-unbalanced-q.md +36 -0
- package/docs/errors/content-unknown-operator.md +37 -0
- package/docs/errors/covered-text.md +33 -0
- package/docs/errors/data-pending.md +34 -0
- package/docs/errors/decompress.md +34 -0
- package/docs/errors/device-color-without-output-intent.md +33 -0
- package/docs/errors/direct-page.md +34 -0
- package/docs/errors/disposed.md +34 -0
- package/docs/errors/document-changed.md +34 -0
- package/docs/errors/embedded-file-forbidden.md +35 -0
- package/docs/errors/embedded-file-without-mime-type.md +36 -0
- package/docs/errors/encoding-full.md +34 -0
- package/docs/errors/encrypted-base.md +33 -0
- package/docs/errors/extract-column-order-uncertain.md +38 -0
- package/docs/errors/extract-limit-blocks.md +35 -0
- package/docs/errors/extract-module-not-loaded.md +37 -0
- package/docs/errors/extract-needs-ocr.md +37 -0
- package/docs/errors/extract-reading-order-ambiguous.md +32 -0
- package/docs/errors/extract-struct-tree-ignored.md +32 -0
- package/docs/errors/extract-table-ambiguous.md +32 -0
- package/docs/errors/extract-table-limit.md +35 -0
- package/docs/errors/extract-untagged-content.md +32 -0
- package/docs/errors/fetch-failed.md +34 -0
- package/docs/errors/flate-truncated.md +34 -0
- package/docs/errors/flow-content-too-large.md +34 -0
- package/docs/errors/flow-keep-broken.md +34 -0
- package/docs/errors/flow-layout-unstable.md +38 -0
- package/docs/errors/font-invalid.md +36 -0
- package/docs/errors/font-mismatch.md +34 -0
- package/docs/errors/font-not-embeddable.md +34 -0
- package/docs/errors/font-not-embedded.md +35 -0
- package/docs/errors/font-not-shapable.md +33 -0
- package/docs/errors/glyph-out-of-range.md +34 -0
- package/docs/errors/glyph-without-unicode.md +37 -0
- package/docs/errors/heading-level-skipped.md +36 -0
- package/docs/errors/image-data-length.md +33 -0
- package/docs/errors/image-too-large.md +32 -0
- package/docs/errors/inline-image-unterminated.md +36 -0
- package/docs/errors/input-unreadable.md +37 -0
- package/docs/errors/instance-reset.md +34 -0
- package/docs/errors/invalid-argument.md +33 -0
- package/docs/errors/invalid-axis-value.md +32 -0
- package/docs/errors/invalid-box.md +34 -0
- package/docs/errors/invalid-color.md +32 -0
- package/docs/errors/invalid-command-line.md +44 -0
- package/docs/errors/invalid-date.md +34 -0
- package/docs/errors/invalid-entry.md +34 -0
- package/docs/errors/invalid-feature.md +32 -0
- package/docs/errors/invalid-font.md +32 -0
- package/docs/errors/invalid-geometry.md +32 -0
- package/docs/errors/invalid-icc-profile.md +32 -0
- package/docs/errors/invalid-image.md +33 -0
- package/docs/errors/invalid-op-log.md +33 -0
- package/docs/errors/invalid-page-label.md +34 -0
- package/docs/errors/invalid-page-labels.md +32 -0
- package/docs/errors/invalid-page-range.md +37 -0
- package/docs/errors/invalid-rotate.md +34 -0
- package/docs/errors/invalid-spans.md +39 -0
- package/docs/errors/invalid-structure-nesting.md +38 -0
- package/docs/errors/invalid-structure.md +34 -0
- package/docs/errors/invalid-text-range.md +33 -0
- package/docs/errors/job-finished.md +34 -0
- package/docs/errors/limit-exceeded.md +38 -0
- package/docs/errors/link-without-contents.md +33 -0
- package/docs/errors/link-without-structure.md +37 -0
- package/docs/errors/markdown-html-ignored.md +33 -0
- package/docs/errors/markdown-image-missing.md +34 -0
- package/docs/errors/missing-alt-text.md +33 -0
- package/docs/errors/missing-glyph.md +33 -0
- package/docs/errors/missing-header.md +37 -0
- package/docs/errors/missing-lang.md +32 -0
- package/docs/errors/missing-root.md +34 -0
- package/docs/errors/missing-title.md +32 -0
- package/docs/errors/model-failed.md +33 -0
- package/docs/errors/model-needs-host.md +40 -0
- package/docs/errors/model-result-unexpected.md +36 -0
- package/docs/errors/name-tree-node-skipped.md +34 -0
- package/docs/errors/nested-transaction.md +34 -0
- package/docs/errors/no-pending-save.md +32 -0
- package/docs/errors/no-transaction.md +33 -0
- package/docs/errors/not-initialized.md +35 -0
- package/docs/errors/not-pdf.md +33 -0
- package/docs/errors/not-rebased.md +35 -0
- package/docs/errors/object-number-out-of-range.md +38 -0
- package/docs/errors/objstm-index-mismatch.md +36 -0
- package/docs/errors/out-of-memory.md +38 -0
- package/docs/errors/outline-cycle.md +34 -0
- package/docs/errors/outline-item-skipped.md +34 -0
- package/docs/errors/output-unwritable.md +37 -0
- package/docs/errors/overwrite-refused.md +36 -0
- package/docs/errors/page-count-mismatch.md +34 -0
- package/docs/errors/page-index-out-of-range.md +34 -0
- package/docs/errors/page-tree-node-skipped.md +35 -0
- package/docs/errors/password-required.md +36 -0
- package/docs/errors/path-outside-roots.md +32 -0
- package/docs/errors/perms-mismatch.md +34 -0
- package/docs/errors/profile-version-conflict.md +35 -0
- package/docs/errors/redaction-not-applied.md +32 -0
- package/docs/errors/reference-cycle.md +35 -0
- package/docs/errors/render-backend-unavailable.md +32 -0
- package/docs/errors/render-failed.md +33 -0
- package/docs/errors/render-too-large.md +36 -0
- package/docs/errors/repaired-base.md +34 -0
- package/docs/errors/requires-rewrite.md +38 -0
- package/docs/errors/revision-index-out-of-range.md +34 -0
- package/docs/errors/saved-not-rebased.md +34 -0
- package/docs/errors/sink-not-empty.md +33 -0
- package/docs/errors/sink.md +31 -0
- package/docs/errors/source-budget-exceeded.md +34 -0
- package/docs/errors/source-changed.md +33 -0
- package/docs/errors/source.md +30 -0
- package/docs/errors/stale-generation.md +34 -0
- package/docs/errors/stream-length-recovered.md +37 -0
- package/docs/errors/strict.md +34 -0
- package/docs/errors/subset-failed.md +31 -0
- package/docs/errors/syntax.md +34 -0
- package/docs/errors/tag-element-not-open.md +41 -0
- package/docs/errors/tag-element-unclosed.md +34 -0
- package/docs/errors/text-in-earlier-revision.md +36 -0
- package/docs/errors/text-module-not-loaded.md +36 -0
- package/docs/errors/text-overflow.md +34 -0
- package/docs/errors/tounicode-conflict.md +32 -0
- package/docs/errors/type.md +34 -0
- package/docs/errors/unexpected-eof.md +34 -0
- package/docs/errors/unknown-axis.md +33 -0
- package/docs/errors/unknown-code.md +36 -0
- package/docs/errors/unknown-destination.md +33 -0
- package/docs/errors/unknown-font.md +33 -0
- package/docs/errors/unknown-option.md +33 -0
- package/docs/errors/unknown-page.md +34 -0
- package/docs/errors/unmapped-glyph.md +36 -0
- package/docs/errors/unnumbered-heading-misused.md +34 -0
- package/docs/errors/unset-object.md +30 -0
- package/docs/errors/unsupported-filter.md +34 -0
- package/docs/errors/unsupported-image.md +33 -0
- package/docs/errors/unsupported-layout-option.md +33 -0
- package/docs/errors/unsupported-security-handler.md +34 -0
- package/docs/errors/unsupported-version.md +32 -0
- package/docs/errors/untagged-content.md +35 -0
- package/docs/errors/warnings-truncated.md +35 -0
- package/docs/errors/wasm-trap.md +37 -0
- package/docs/errors/whole-font-rebuilt.md +30 -0
- package/docs/errors/worker-crashed.md +33 -0
- package/docs/errors/worker-failed.md +32 -0
- package/docs/errors/worker-version-mismatch.md +34 -0
- package/docs/errors/would-invalidate-signatures.md +38 -0
- package/docs/errors/wrong-document.md +33 -0
- package/docs/errors/wrong-password.md +34 -0
- package/docs/errors/xobject-cycle.md +36 -0
- package/docs/errors/xref-repaired.md +36 -0
- package/docs/errors/xrefstm-ignored.md +34 -0
- package/docs/llms.txt +94 -0
- package/docs/pages/concepts/dependencies.md +44 -0
- package/docs/pages/concepts/drawing-pages.md +76 -0
- package/docs/pages/concepts/errors-and-warnings.md +68 -0
- package/docs/pages/concepts/how-lamina-thinks.md +98 -0
- package/docs/pages/concepts/pages-and-coordinates.md +75 -0
- package/docs/pages/guides/accessible-pdfs.md +262 -0
- package/docs/pages/guides/archival-pdfs.md +433 -0
- package/docs/pages/guides/edit-a-pdf.md +143 -0
- package/docs/pages/guides/flowing-pages.md +379 -0
- package/docs/pages/guides/fonts-and-text.md +204 -0
- package/docs/pages/guides/images-and-vectors.md +221 -0
- package/docs/pages/guides/keep-the-page-responsive.md +85 -0
- package/docs/pages/guides/links-outlines-and-metadata.md +224 -0
- package/docs/pages/guides/open-large-files.md +69 -0
- package/docs/pages/guides/password-protected-files.md +70 -0
- package/docs/pages/guides/save-a-pdf.md +154 -0
- package/docs/pages/guides/test-generated-pdfs.md +324 -0
- package/docs/pages/guides/untrusted-files.md +82 -0
- package/docs/pages/index.md +33 -0
- package/docs/pages/install.md +79 -0
- package/docs/pages/quick-start/browser.md +71 -0
- package/docs/pages/quick-start/bun.md +64 -0
- package/docs/pages/quick-start/deno.md +62 -0
- package/docs/pages/quick-start/node.md +65 -0
- package/docs/pages/quick-start/rust.md +62 -0
- package/docs/pages/quick-start/workers.md +139 -0
- package/docs/pages/recipes/cloudflare-worker.md +115 -0
- package/docs/pages/recipes/element-flow.md +248 -0
- package/docs/pages/recipes/extract-markdown.md +152 -0
- package/docs/pages/recipes/generate-then-edit.md +142 -0
- package/docs/pages/recipes/hello.md +101 -0
- package/docs/pages/recipes/images-and-vectors.md +216 -0
- package/docs/pages/recipes/invoice.md +233 -0
- package/docs/pages/recipes/links-and-outlines.md +222 -0
- package/docs/pages/recipes/multilingual.md +196 -0
- package/docs/pages/recipes/open-untrusted.md +65 -0
- package/docs/pages/recipes/pdf-a-archive.md +212 -0
- package/docs/pages/recipes/pdf-a3-invoice-with-xml.md +229 -0
- package/docs/pages/recipes/pdf-ua-report.md +244 -0
- package/docs/pages/recipes/report.md +125 -0
- package/docs/pages/recipes/web-worker-client.md +64 -0
- package/docs/pages/recipes.md +48 -0
- package/docs/pages/reference/benchmarks.md +93 -0
- package/docs/pages/reference/changelog.md +134 -0
- package/docs/pages/reference/codes.md +14 -0
- package/docs/pages/reference/glossary.md +108 -0
- package/docs/pages/reference/rust.md +36 -0
- package/docs/pages/reference/stability.md +59 -0
- package/docs/pages/start/coding-agents.md +45 -0
- package/docs/pages/start/first-pdf.md +81 -0
- package/docs/pages/troubleshooting.md +74 -0
- package/docs/renames.json +86 -0
- package/docs/schemas/error.schema.json +322 -0
- package/docs/schemas/renames.schema.json +29 -0
- package/package.json +7 -3
- package/schemas/error.schema.json +37 -3
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
---
|
|
2
|
+
version: "0.2.0-alpha.4"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
[**@laminapdf/sdk**](../README.md)
|
|
6
|
+
|
|
7
|
+
***
|
|
8
|
+
|
|
9
|
+
[@laminapdf/sdk](../README.md) / Document
|
|
10
|
+
|
|
11
|
+
# Class: Document
|
|
12
|
+
|
|
13
|
+
An open PDF: read it, edit it with ops (atomic transactions with undo), save it. It holds
|
|
14
|
+
WebAssembly memory: free it with `using` or [Document.free](#free) (an alias).
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
await init();
|
|
20
|
+
using doc = Document.open(bytes);
|
|
21
|
+
doc.transact((tx) => tx.setInfo({ title: "Final" }));
|
|
22
|
+
const updated = doc.save({ mode: "incremental" });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Extends
|
|
26
|
+
|
|
27
|
+
- `Handle`\<`BaseGlue`\>
|
|
28
|
+
|
|
29
|
+
## Accessors
|
|
30
|
+
|
|
31
|
+
### canExtractText
|
|
32
|
+
|
|
33
|
+
#### Get Signature
|
|
34
|
+
|
|
35
|
+
> **get** **canExtractText**(): `boolean`
|
|
36
|
+
|
|
37
|
+
Whether `page(i).text()` works on this document: it was opened or built while the extract or
|
|
38
|
+
the text module was loaded. A document opened before the module loaded stays in the base
|
|
39
|
+
module; save and reopen it to move it.
|
|
40
|
+
|
|
41
|
+
##### Returns
|
|
42
|
+
|
|
43
|
+
`boolean`
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
### hasUnsavedChanges
|
|
48
|
+
|
|
49
|
+
#### Get Signature
|
|
50
|
+
|
|
51
|
+
> **get** **hasUnsavedChanges**(): `boolean`
|
|
52
|
+
|
|
53
|
+
Whether there are changes no save has written yet.
|
|
54
|
+
|
|
55
|
+
##### Returns
|
|
56
|
+
|
|
57
|
+
`boolean`
|
|
58
|
+
|
|
59
|
+
***
|
|
60
|
+
|
|
61
|
+
### info
|
|
62
|
+
|
|
63
|
+
#### Get Signature
|
|
64
|
+
|
|
65
|
+
> **get** **info**(): `DocumentInfoJs`
|
|
66
|
+
|
|
67
|
+
The Info dictionary's text entries (document text).
|
|
68
|
+
|
|
69
|
+
##### Throws
|
|
70
|
+
|
|
71
|
+
[LaminaPdfError](LaminaPdfError.md) reading errors.
|
|
72
|
+
|
|
73
|
+
##### Returns
|
|
74
|
+
|
|
75
|
+
`DocumentInfoJs`
|
|
76
|
+
|
|
77
|
+
***
|
|
78
|
+
|
|
79
|
+
### instance
|
|
80
|
+
|
|
81
|
+
#### Get Signature
|
|
82
|
+
|
|
83
|
+
> **get** `protected` **instance**(): `Instance`\<`G`\>
|
|
84
|
+
|
|
85
|
+
The instance this handle lives in (for the handles it makes).
|
|
86
|
+
|
|
87
|
+
##### Returns
|
|
88
|
+
|
|
89
|
+
`Instance`\<`G`\>
|
|
90
|
+
|
|
91
|
+
#### Inherited from
|
|
92
|
+
|
|
93
|
+
`Handle.instance`
|
|
94
|
+
|
|
95
|
+
***
|
|
96
|
+
|
|
97
|
+
### isFreed
|
|
98
|
+
|
|
99
|
+
#### Get Signature
|
|
100
|
+
|
|
101
|
+
> **get** `protected` **isFreed**(): `boolean`
|
|
102
|
+
|
|
103
|
+
Whether `free()` ran on this handle or its parent.
|
|
104
|
+
|
|
105
|
+
##### Returns
|
|
106
|
+
|
|
107
|
+
`boolean`
|
|
108
|
+
|
|
109
|
+
#### Inherited from
|
|
110
|
+
|
|
111
|
+
`Handle.isFreed`
|
|
112
|
+
|
|
113
|
+
***
|
|
114
|
+
|
|
115
|
+
### isTagged
|
|
116
|
+
|
|
117
|
+
#### Get Signature
|
|
118
|
+
|
|
119
|
+
> **get** **isTagged**(): `boolean`
|
|
120
|
+
|
|
121
|
+
Whether the document says it is tagged (`/MarkInfo /Marked true`); it doesn't check the tree.
|
|
122
|
+
Needs a document opened while the extract or text module was loaded, as `page.text()` does.
|
|
123
|
+
|
|
124
|
+
##### Throws
|
|
125
|
+
|
|
126
|
+
[LaminaPdfError](LaminaPdfError.md) `extract-module-not-loaded`; reading errors.
|
|
127
|
+
|
|
128
|
+
##### Returns
|
|
129
|
+
|
|
130
|
+
`boolean`
|
|
131
|
+
|
|
132
|
+
***
|
|
133
|
+
|
|
134
|
+
### owned
|
|
135
|
+
|
|
136
|
+
#### Get Signature
|
|
137
|
+
|
|
138
|
+
> **get** `protected` **owned**(): `boolean`
|
|
139
|
+
|
|
140
|
+
Whether the handle's raw objects can be freed: its instance is current and hasn't trapped.
|
|
141
|
+
|
|
142
|
+
##### Returns
|
|
143
|
+
|
|
144
|
+
`boolean`
|
|
145
|
+
|
|
146
|
+
#### Inherited from
|
|
147
|
+
|
|
148
|
+
`Handle.owned`
|
|
149
|
+
|
|
150
|
+
***
|
|
151
|
+
|
|
152
|
+
### pageCount
|
|
153
|
+
|
|
154
|
+
#### Get Signature
|
|
155
|
+
|
|
156
|
+
> **get** **pageCount**(): `number`
|
|
157
|
+
|
|
158
|
+
The number of pages.
|
|
159
|
+
|
|
160
|
+
##### Throws
|
|
161
|
+
|
|
162
|
+
[LaminaPdfError](LaminaPdfError.md) reading errors.
|
|
163
|
+
|
|
164
|
+
##### Returns
|
|
165
|
+
|
|
166
|
+
`number`
|
|
167
|
+
|
|
168
|
+
***
|
|
169
|
+
|
|
170
|
+
### pages
|
|
171
|
+
|
|
172
|
+
#### Get Signature
|
|
173
|
+
|
|
174
|
+
> **get** **pages**(): readonly `PageInfoJs`[]
|
|
175
|
+
|
|
176
|
+
Every page's facts, in order (one page-tree walk).
|
|
177
|
+
|
|
178
|
+
##### Throws
|
|
179
|
+
|
|
180
|
+
[LaminaPdfError](LaminaPdfError.md) reading errors.
|
|
181
|
+
|
|
182
|
+
##### Returns
|
|
183
|
+
|
|
184
|
+
readonly `PageInfoJs`[]
|
|
185
|
+
|
|
186
|
+
***
|
|
187
|
+
|
|
188
|
+
### warnings
|
|
189
|
+
|
|
190
|
+
#### Get Signature
|
|
191
|
+
|
|
192
|
+
> **get** **warnings**(): readonly [`LaminaPdfWarning`](../type-aliases/LaminaPdfWarning.md)[]
|
|
193
|
+
|
|
194
|
+
Every warning so far (build warnings first), each the ADR 0026 §1 object.
|
|
195
|
+
|
|
196
|
+
##### Returns
|
|
197
|
+
|
|
198
|
+
readonly [`LaminaPdfWarning`](../type-aliases/LaminaPdfWarning.md)[]
|
|
199
|
+
|
|
200
|
+
## Methods
|
|
201
|
+
|
|
202
|
+
### \[dispose\]()
|
|
203
|
+
|
|
204
|
+
> **\[dispose\]**(): `void`
|
|
205
|
+
|
|
206
|
+
Frees the handle at the end of a `using` block (an alias of `free()`).
|
|
207
|
+
|
|
208
|
+
#### Returns
|
|
209
|
+
|
|
210
|
+
`void`
|
|
211
|
+
|
|
212
|
+
#### Inherited from
|
|
213
|
+
|
|
214
|
+
`Handle.[dispose]`
|
|
215
|
+
|
|
216
|
+
***
|
|
217
|
+
|
|
218
|
+
### apply()
|
|
219
|
+
|
|
220
|
+
> **apply**(`ops`): `EditedJs`
|
|
221
|
+
|
|
222
|
+
Applies `ops` in order as one transaction: all of them, or none.
|
|
223
|
+
|
|
224
|
+
#### Parameters
|
|
225
|
+
|
|
226
|
+
##### ops
|
|
227
|
+
|
|
228
|
+
readonly `Op`[]
|
|
229
|
+
|
|
230
|
+
#### Returns
|
|
231
|
+
|
|
232
|
+
`EditedJs`
|
|
233
|
+
|
|
234
|
+
the pages the edit touched.
|
|
235
|
+
|
|
236
|
+
#### Throws
|
|
237
|
+
|
|
238
|
+
[LaminaPdfError](LaminaPdfError.md) `unknown-option` / `invalid-argument` for a value that isn't an op;
|
|
239
|
+
the first failing op's error (`unknown-page`, …), with nothing applied.
|
|
240
|
+
|
|
241
|
+
***
|
|
242
|
+
|
|
243
|
+
### applyLog()
|
|
244
|
+
|
|
245
|
+
> **applyLog**(`log`): `EditedJs`
|
|
246
|
+
|
|
247
|
+
Applies an op log (`{ v: 1, ops }`, as JSON text or an object) as one transaction.
|
|
248
|
+
|
|
249
|
+
#### Parameters
|
|
250
|
+
|
|
251
|
+
##### log
|
|
252
|
+
|
|
253
|
+
`string` \| [`OpLog`](../interfaces/OpLog.md)
|
|
254
|
+
|
|
255
|
+
#### Returns
|
|
256
|
+
|
|
257
|
+
`EditedJs`
|
|
258
|
+
|
|
259
|
+
#### Throws
|
|
260
|
+
|
|
261
|
+
[LaminaPdfError](LaminaPdfError.md) `invalid-op-log`, `unsupported-version`; as [Document.apply](#apply).
|
|
262
|
+
|
|
263
|
+
***
|
|
264
|
+
|
|
265
|
+
### assertLive()
|
|
266
|
+
|
|
267
|
+
> `protected` **assertLive**(): `void`
|
|
268
|
+
|
|
269
|
+
#### Returns
|
|
270
|
+
|
|
271
|
+
`void`
|
|
272
|
+
|
|
273
|
+
#### Throws
|
|
274
|
+
|
|
275
|
+
[LaminaPdfError](LaminaPdfError.md) `disposed` after `free()` (here or on the parent);
|
|
276
|
+
`instance-reset` when the instance was replaced (a trapped one is replaced first).
|
|
277
|
+
|
|
278
|
+
#### Inherited from
|
|
279
|
+
|
|
280
|
+
`Handle.assertLive`
|
|
281
|
+
|
|
282
|
+
***
|
|
283
|
+
|
|
284
|
+
### call()
|
|
285
|
+
|
|
286
|
+
> `protected` **call**\<`T`\>(`f`): `T`
|
|
287
|
+
|
|
288
|
+
Runs `f` (calls into the glue) on this live handle; see Instance.call.
|
|
289
|
+
|
|
290
|
+
#### Type Parameters
|
|
291
|
+
|
|
292
|
+
##### T
|
|
293
|
+
|
|
294
|
+
`T`
|
|
295
|
+
|
|
296
|
+
#### Parameters
|
|
297
|
+
|
|
298
|
+
##### f
|
|
299
|
+
|
|
300
|
+
(`glue`) => `T`
|
|
301
|
+
|
|
302
|
+
#### Returns
|
|
303
|
+
|
|
304
|
+
`T`
|
|
305
|
+
|
|
306
|
+
#### Inherited from
|
|
307
|
+
|
|
308
|
+
`Handle.call`
|
|
309
|
+
|
|
310
|
+
***
|
|
311
|
+
|
|
312
|
+
### ensure()
|
|
313
|
+
|
|
314
|
+
> **ensure**\<`T`\>(`f`, `options?`): `Promise`\<`T`\>
|
|
315
|
+
|
|
316
|
+
Runs a synchronous call on this document, fetching what it needs first: for a document
|
|
317
|
+
from [Document.openRange](#openrange), a `data-pending` makes it fetch the ranges asked for and
|
|
318
|
+
call `f` again. For other documents it just returns `f()`.
|
|
319
|
+
|
|
320
|
+
#### Type Parameters
|
|
321
|
+
|
|
322
|
+
##### T
|
|
323
|
+
|
|
324
|
+
`T`
|
|
325
|
+
|
|
326
|
+
#### Parameters
|
|
327
|
+
|
|
328
|
+
##### f
|
|
329
|
+
|
|
330
|
+
() => `T` \| `Promise`\<`T`\>
|
|
331
|
+
|
|
332
|
+
the call (it may run several times; keep it free of side effects). An async
|
|
333
|
+
function works too: its `data-pending` rejections are caught the same way.
|
|
334
|
+
|
|
335
|
+
##### options?
|
|
336
|
+
|
|
337
|
+
`signal` aborts this call's fetches (the open's signal applies to the open
|
|
338
|
+
only).
|
|
339
|
+
|
|
340
|
+
###### signal?
|
|
341
|
+
|
|
342
|
+
`AbortSignal`
|
|
343
|
+
|
|
344
|
+
#### Returns
|
|
345
|
+
|
|
346
|
+
`Promise`\<`T`\>
|
|
347
|
+
|
|
348
|
+
what `f` returns.
|
|
349
|
+
|
|
350
|
+
#### Example
|
|
351
|
+
|
|
352
|
+
```ts
|
|
353
|
+
const doc = await Document.openRange(httpRangeSource(url));
|
|
354
|
+
const pages = await doc.ensure(() => doc.pages);
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
#### Throws
|
|
358
|
+
|
|
359
|
+
what `f` throws, and as [Document.openRange](#openrange).
|
|
360
|
+
|
|
361
|
+
***
|
|
362
|
+
|
|
363
|
+
### extract()
|
|
364
|
+
|
|
365
|
+
> **extract**\<`F`\>(`options`): [`ExtractResult`](../interfaces/ExtractResult.md)\[`F`\]
|
|
366
|
+
|
|
367
|
+
The document's text for retrieval and LLMs: Markdown or plain text in reading order, the
|
|
368
|
+
`laminapdf.extract/1` JSON with a box for every block, or chunks sized for retrieval. Tables
|
|
369
|
+
drawn with lines come out as tables, and text a reader can't see is left out. Needs a
|
|
370
|
+
document opened while the extract or text module was loaded.
|
|
371
|
+
|
|
372
|
+
#### Type Parameters
|
|
373
|
+
|
|
374
|
+
##### F
|
|
375
|
+
|
|
376
|
+
`F` *extends* [`ExtractFormat`](../type-aliases/ExtractFormat.md)
|
|
377
|
+
|
|
378
|
+
#### Parameters
|
|
379
|
+
|
|
380
|
+
##### options
|
|
381
|
+
|
|
382
|
+
[`ExtractOptions`](../interfaces/ExtractOptions.md)\<`F`\>
|
|
383
|
+
|
|
384
|
+
#### Returns
|
|
385
|
+
|
|
386
|
+
[`ExtractResult`](../interfaces/ExtractResult.md)\[`F`\]
|
|
387
|
+
|
|
388
|
+
a string for `"markdown"` and `"text"`, an [Extraction](../type-aliases/Extraction.md) for `"json"`,
|
|
389
|
+
[Chunk](../type-aliases/Chunk.md)s for `"chunks"`.
|
|
390
|
+
|
|
391
|
+
#### Example
|
|
392
|
+
|
|
393
|
+
```ts
|
|
394
|
+
await init({ extract: true });
|
|
395
|
+
const doc = Document.open(bytes);
|
|
396
|
+
const markdown = doc.extract({ format: "markdown" });
|
|
397
|
+
const chunks = doc.extract({ format: "chunks", chunk: { maxTokens: 400 } });
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
#### Throws
|
|
401
|
+
|
|
402
|
+
[LaminaPdfError](LaminaPdfError.md) `extract-module-not-loaded` for a document opened in the base
|
|
403
|
+
module; `page-index-out-of-range`; `unknown-option` (with `didYouMean`) / `invalid-argument`
|
|
404
|
+
for bad options; reading errors (`data-pending` for a range document: use `ensure`).
|
|
405
|
+
|
|
406
|
+
***
|
|
407
|
+
|
|
408
|
+
### extractJob()
|
|
409
|
+
|
|
410
|
+
> **extractJob**\<`F`\>(`options`): [`ExtractJob`](ExtractJob.md)\<`F`\>
|
|
411
|
+
|
|
412
|
+
An extraction stepped a page at a time, for models the host runs: each step that needs a
|
|
413
|
+
model's result stops with a `request` (the page and resolution to render), answered with
|
|
414
|
+
[ExtractJob.provide](ExtractJob.md#provide). [extractWithModels](../functions/extractWithModels.md) loops one for async models. Needs a
|
|
415
|
+
document opened while the extract or text module was loaded.
|
|
416
|
+
|
|
417
|
+
#### Type Parameters
|
|
418
|
+
|
|
419
|
+
##### F
|
|
420
|
+
|
|
421
|
+
`F` *extends* [`ExtractFormat`](../type-aliases/ExtractFormat.md)
|
|
422
|
+
|
|
423
|
+
#### Parameters
|
|
424
|
+
|
|
425
|
+
##### options
|
|
426
|
+
|
|
427
|
+
[`ExtractJobOptions`](../type-aliases/ExtractJobOptions.md)\<`F`\>
|
|
428
|
+
|
|
429
|
+
#### Returns
|
|
430
|
+
|
|
431
|
+
[`ExtractJob`](ExtractJob.md)\<`F`\>
|
|
432
|
+
|
|
433
|
+
#### Throws
|
|
434
|
+
|
|
435
|
+
[LaminaPdfError](LaminaPdfError.md) as [Document.extract](#extract).
|
|
436
|
+
|
|
437
|
+
***
|
|
438
|
+
|
|
439
|
+
### free()
|
|
440
|
+
|
|
441
|
+
> **free**(): `void`
|
|
442
|
+
|
|
443
|
+
Frees the handle's memory now; without it, the garbage collector frees it later. A second
|
|
444
|
+
call does nothing, and any other call afterwards throws `disposed`. Prefer `using`, which
|
|
445
|
+
calls this at the end of the block.
|
|
446
|
+
|
|
447
|
+
#### Returns
|
|
448
|
+
|
|
449
|
+
`void`
|
|
450
|
+
|
|
451
|
+
#### Inherited from
|
|
452
|
+
|
|
453
|
+
`Handle.free`
|
|
454
|
+
|
|
455
|
+
***
|
|
456
|
+
|
|
457
|
+
### namedDestination()
|
|
458
|
+
|
|
459
|
+
> **namedDestination**(`name`): `TargetJs` \| `undefined`
|
|
460
|
+
|
|
461
|
+
Where the named destination `name` goes (the names a link or a `#nameddest=` address uses),
|
|
462
|
+
or `undefined` when the document has none by that name. Needs a document opened while the
|
|
463
|
+
extract or text module was loaded.
|
|
464
|
+
|
|
465
|
+
#### Parameters
|
|
466
|
+
|
|
467
|
+
##### name
|
|
468
|
+
|
|
469
|
+
`string`
|
|
470
|
+
|
|
471
|
+
#### Returns
|
|
472
|
+
|
|
473
|
+
`TargetJs` \| `undefined`
|
|
474
|
+
|
|
475
|
+
#### Throws
|
|
476
|
+
|
|
477
|
+
[LaminaPdfError](LaminaPdfError.md) as [Document.outline](#outline).
|
|
478
|
+
|
|
479
|
+
***
|
|
480
|
+
|
|
481
|
+
### outline()
|
|
482
|
+
|
|
483
|
+
> **outline**(): `OutlineNodeJs`[]
|
|
484
|
+
|
|
485
|
+
The outline (bookmarks): its top-level items in order, each with its children, and where
|
|
486
|
+
each goes as a page and a view in page space; empty without one. Needs a document opened
|
|
487
|
+
while the extract or text module was loaded.
|
|
488
|
+
|
|
489
|
+
#### Returns
|
|
490
|
+
|
|
491
|
+
`OutlineNodeJs`[]
|
|
492
|
+
|
|
493
|
+
#### Throws
|
|
494
|
+
|
|
495
|
+
[LaminaPdfError](LaminaPdfError.md) `extract-module-not-loaded` for a document opened in the base
|
|
496
|
+
module; reading errors (`data-pending` for a range document: use `ensure`).
|
|
497
|
+
|
|
498
|
+
***
|
|
499
|
+
|
|
500
|
+
### page()
|
|
501
|
+
|
|
502
|
+
> **page**(`index`): [`PageRef`](PageRef.md)
|
|
503
|
+
|
|
504
|
+
A handle on page `index` that follows the page by its ID.
|
|
505
|
+
|
|
506
|
+
#### Parameters
|
|
507
|
+
|
|
508
|
+
##### index
|
|
509
|
+
|
|
510
|
+
`number`
|
|
511
|
+
|
|
512
|
+
#### Returns
|
|
513
|
+
|
|
514
|
+
[`PageRef`](PageRef.md)
|
|
515
|
+
|
|
516
|
+
#### Throws
|
|
517
|
+
|
|
518
|
+
[LaminaPdfError](LaminaPdfError.md) `page-index-out-of-range`.
|
|
519
|
+
|
|
520
|
+
***
|
|
521
|
+
|
|
522
|
+
### pageById()
|
|
523
|
+
|
|
524
|
+
> **pageById**(`id`): [`PageRef`](PageRef.md)
|
|
525
|
+
|
|
526
|
+
A handle on the page with `id` (`p12.0`).
|
|
527
|
+
|
|
528
|
+
#### Parameters
|
|
529
|
+
|
|
530
|
+
##### id
|
|
531
|
+
|
|
532
|
+
`string`
|
|
533
|
+
|
|
534
|
+
#### Returns
|
|
535
|
+
|
|
536
|
+
[`PageRef`](PageRef.md)
|
|
537
|
+
|
|
538
|
+
#### Throws
|
|
539
|
+
|
|
540
|
+
[LaminaPdfError](LaminaPdfError.md) `invalid-argument`, `unknown-page`.
|
|
541
|
+
|
|
542
|
+
***
|
|
543
|
+
|
|
544
|
+
### pageInfo()
|
|
545
|
+
|
|
546
|
+
> **pageInfo**(`index`): `PageInfoJs`
|
|
547
|
+
|
|
548
|
+
Page `index`'s facts.
|
|
549
|
+
|
|
550
|
+
#### Parameters
|
|
551
|
+
|
|
552
|
+
##### index
|
|
553
|
+
|
|
554
|
+
`number`
|
|
555
|
+
|
|
556
|
+
#### Returns
|
|
557
|
+
|
|
558
|
+
`PageInfoJs`
|
|
559
|
+
|
|
560
|
+
#### Throws
|
|
561
|
+
|
|
562
|
+
[LaminaPdfError](LaminaPdfError.md) `page-index-out-of-range`.
|
|
563
|
+
|
|
564
|
+
***
|
|
565
|
+
|
|
566
|
+
### rebase()
|
|
567
|
+
|
|
568
|
+
> **rebase**(`bytes`): `void`
|
|
569
|
+
|
|
570
|
+
Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
571
|
+
|
|
572
|
+
#### Parameters
|
|
573
|
+
|
|
574
|
+
##### bytes
|
|
575
|
+
|
|
576
|
+
`Uint8Array`
|
|
577
|
+
|
|
578
|
+
#### Returns
|
|
579
|
+
|
|
580
|
+
`void`
|
|
581
|
+
|
|
582
|
+
#### Throws
|
|
583
|
+
|
|
584
|
+
[LaminaPdfError](LaminaPdfError.md) `no-pending-save`; reading errors in `bytes`.
|
|
585
|
+
|
|
586
|
+
***
|
|
587
|
+
|
|
588
|
+
### redo()
|
|
589
|
+
|
|
590
|
+
> **redo**(): `UndoOutcomeJs` \| `undefined`
|
|
591
|
+
|
|
592
|
+
Redoes the newest undone transaction.
|
|
593
|
+
|
|
594
|
+
#### Returns
|
|
595
|
+
|
|
596
|
+
`UndoOutcomeJs` \| `undefined`
|
|
597
|
+
|
|
598
|
+
how it went, or `undefined` when there is nothing to redo.
|
|
599
|
+
|
|
600
|
+
#### Throws
|
|
601
|
+
|
|
602
|
+
[LaminaPdfError](LaminaPdfError.md) as [Document.undo](#undo).
|
|
603
|
+
|
|
604
|
+
***
|
|
605
|
+
|
|
606
|
+
### release()
|
|
607
|
+
|
|
608
|
+
> `protected` **release**(): `void`
|
|
609
|
+
|
|
610
|
+
Frees the WebAssembly side; called at most once, and only while [owned](#owned).
|
|
611
|
+
|
|
612
|
+
#### Returns
|
|
613
|
+
|
|
614
|
+
`void`
|
|
615
|
+
|
|
616
|
+
#### Overrides
|
|
617
|
+
|
|
618
|
+
`Handle.release`
|
|
619
|
+
|
|
620
|
+
***
|
|
621
|
+
|
|
622
|
+
### save()
|
|
623
|
+
|
|
624
|
+
> **save**(`options?`): `Uint8Array`\<`ArrayBuffer`\>
|
|
625
|
+
|
|
626
|
+
Saves and rebases onto the output (later edits and saves build on it).
|
|
627
|
+
|
|
628
|
+
#### Parameters
|
|
629
|
+
|
|
630
|
+
##### options?
|
|
631
|
+
|
|
632
|
+
`SaveOptionsInit`
|
|
633
|
+
|
|
634
|
+
`mode` (`auto`, `incremental`, `fullRewrite`), overrides, output form.
|
|
635
|
+
|
|
636
|
+
#### Returns
|
|
637
|
+
|
|
638
|
+
`Uint8Array`\<`ArrayBuffer`\>
|
|
639
|
+
|
|
640
|
+
the file's bytes.
|
|
641
|
+
|
|
642
|
+
#### Throws
|
|
643
|
+
|
|
644
|
+
[LaminaPdfError](LaminaPdfError.md) `would-invalidate-signatures`, `requires-rewrite`, `encrypted-base`, …
|
|
645
|
+
|
|
646
|
+
***
|
|
647
|
+
|
|
648
|
+
### saveJob()
|
|
649
|
+
|
|
650
|
+
> **saveJob**(`options?`): [`SaveJob`](SaveJob.md)
|
|
651
|
+
|
|
652
|
+
A save as a job stepped by the caller (to keep a UI responsive).
|
|
653
|
+
|
|
654
|
+
#### Parameters
|
|
655
|
+
|
|
656
|
+
##### options?
|
|
657
|
+
|
|
658
|
+
`SaveOptionsInit`
|
|
659
|
+
|
|
660
|
+
#### Returns
|
|
661
|
+
|
|
662
|
+
[`SaveJob`](SaveJob.md)
|
|
663
|
+
|
|
664
|
+
#### Throws
|
|
665
|
+
|
|
666
|
+
[LaminaPdfError](LaminaPdfError.md) `unknown-option` / `invalid-argument` for bad options.
|
|
667
|
+
|
|
668
|
+
***
|
|
669
|
+
|
|
670
|
+
### saveWithReport()
|
|
671
|
+
|
|
672
|
+
> **saveWithReport**(`options?`): `object`
|
|
673
|
+
|
|
674
|
+
As [Document.save](#save), with the save's report (mode used, bytes written, renumbering, …).
|
|
675
|
+
|
|
676
|
+
#### Parameters
|
|
677
|
+
|
|
678
|
+
##### options?
|
|
679
|
+
|
|
680
|
+
`SaveOptionsInit`
|
|
681
|
+
|
|
682
|
+
#### Returns
|
|
683
|
+
|
|
684
|
+
`object`
|
|
685
|
+
|
|
686
|
+
##### bytes
|
|
687
|
+
|
|
688
|
+
> `readonly` **bytes**: `Uint8Array`\<`ArrayBuffer`\>
|
|
689
|
+
|
|
690
|
+
##### report
|
|
691
|
+
|
|
692
|
+
> `readonly` **report**: `SaveReportJs`
|
|
693
|
+
|
|
694
|
+
#### Throws
|
|
695
|
+
|
|
696
|
+
[LaminaPdfError](LaminaPdfError.md) as [Document.save](#save).
|
|
697
|
+
|
|
698
|
+
***
|
|
699
|
+
|
|
700
|
+
### structureTree()
|
|
701
|
+
|
|
702
|
+
> **structureTree**(): `StructureNodeJs`[] \| `undefined`
|
|
703
|
+
|
|
704
|
+
The structure tree's top-level elements in reading order, or `undefined` for a document
|
|
705
|
+
without one. A text run's `mcid` (on [PageTextRun](PageTextRun.md)) links it to the element whose
|
|
706
|
+
`{ type: "content", page, mcid }` kid names it. Needs the extract or text module, as
|
|
707
|
+
`page.text()` does.
|
|
708
|
+
|
|
709
|
+
#### Returns
|
|
710
|
+
|
|
711
|
+
`StructureNodeJs`[] \| `undefined`
|
|
712
|
+
|
|
713
|
+
#### Throws
|
|
714
|
+
|
|
715
|
+
[LaminaPdfError](LaminaPdfError.md) `extract-module-not-loaded`; reading errors.
|
|
716
|
+
|
|
717
|
+
***
|
|
718
|
+
|
|
719
|
+
### transact()
|
|
720
|
+
|
|
721
|
+
> **transact**\<`T`\>(`edit`): `T`
|
|
722
|
+
|
|
723
|
+
Runs `edit` with a transaction handle and applies what it collected as one transaction
|
|
724
|
+
(ADR 0006 §2). When `edit` throws, nothing is applied and the error propagates. The ops are
|
|
725
|
+
applied when `edit` returns: reads inside `edit` see the document before the transaction.
|
|
726
|
+
|
|
727
|
+
#### Type Parameters
|
|
728
|
+
|
|
729
|
+
##### T
|
|
730
|
+
|
|
731
|
+
`T`
|
|
732
|
+
|
|
733
|
+
#### Parameters
|
|
734
|
+
|
|
735
|
+
##### edit
|
|
736
|
+
|
|
737
|
+
(`tx`) => `T`
|
|
738
|
+
|
|
739
|
+
collects ops on `tx`; synchronous only (a callback returning a promise is
|
|
740
|
+
refused with `invalid-argument` and nothing is applied).
|
|
741
|
+
|
|
742
|
+
#### Returns
|
|
743
|
+
|
|
744
|
+
`T`
|
|
745
|
+
|
|
746
|
+
what `edit` returned.
|
|
747
|
+
|
|
748
|
+
#### Throws
|
|
749
|
+
|
|
750
|
+
[LaminaPdfError](LaminaPdfError.md) `nested-transaction` when called (or when `apply`, `undo`, `redo`,
|
|
751
|
+
`save`… are called) inside a `transact` of the same document; `invalid-argument` for an
|
|
752
|
+
async callback; as [Document.apply](#apply).
|
|
753
|
+
|
|
754
|
+
#### Example
|
|
755
|
+
|
|
756
|
+
```ts
|
|
757
|
+
doc.transact((tx) => {
|
|
758
|
+
tx.setInfo({ title: "Report" });
|
|
759
|
+
tx.rotatePage(doc.page(0).id, 90);
|
|
760
|
+
});
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
***
|
|
764
|
+
|
|
765
|
+
### undo()
|
|
766
|
+
|
|
767
|
+
> **undo**(): `UndoOutcomeJs` \| `undefined`
|
|
768
|
+
|
|
769
|
+
Undoes the newest transaction.
|
|
770
|
+
|
|
771
|
+
#### Returns
|
|
772
|
+
|
|
773
|
+
`UndoOutcomeJs` \| `undefined`
|
|
774
|
+
|
|
775
|
+
how it went, or `undefined` when there is nothing to undo.
|
|
776
|
+
|
|
777
|
+
#### Throws
|
|
778
|
+
|
|
779
|
+
[LaminaPdfError](LaminaPdfError.md) `saved-not-rebased`; reading errors.
|
|
780
|
+
|
|
781
|
+
***
|
|
782
|
+
|
|
783
|
+
### open()
|
|
784
|
+
|
|
785
|
+
> `static` **open**(`bytes`, `options?`): `Document`
|
|
786
|
+
|
|
787
|
+
Opens a document from its bytes (the bytes are copied into the WASM memory).
|
|
788
|
+
|
|
789
|
+
The password is tried as given. When that fails with `wrong-password` and its NFKC form
|
|
790
|
+
differs, the NFKC form is tried too: R5/R6 passwords are prepared with SASLprep, whose
|
|
791
|
+
normalisation the WASM modules leave out (ADR 0016 §7), while R2–R4 passwords must reach
|
|
792
|
+
the core unchanged.
|
|
793
|
+
|
|
794
|
+
#### Parameters
|
|
795
|
+
|
|
796
|
+
##### bytes
|
|
797
|
+
|
|
798
|
+
`ArrayBuffer` \| `Uint8Array`\<`ArrayBufferLike`\>
|
|
799
|
+
|
|
800
|
+
the PDF file.
|
|
801
|
+
|
|
802
|
+
##### options?
|
|
803
|
+
|
|
804
|
+
[`OpenOptions`](../interfaces/OpenOptions.md)
|
|
805
|
+
|
|
806
|
+
password, strict mode, limits.
|
|
807
|
+
|
|
808
|
+
#### Returns
|
|
809
|
+
|
|
810
|
+
`Document`
|
|
811
|
+
|
|
812
|
+
the document.
|
|
813
|
+
|
|
814
|
+
#### Throws
|
|
815
|
+
|
|
816
|
+
[LaminaPdfError](LaminaPdfError.md) `not-pdf`, `password-required`, `wrong-password`, `limit-exceeded`,
|
|
817
|
+
`strict`, …; `unknown-option` / `invalid-argument` for bad options; `not-initialized`.
|
|
818
|
+
|
|
819
|
+
***
|
|
820
|
+
|
|
821
|
+
### openRange()
|
|
822
|
+
|
|
823
|
+
> `static` **openRange**(`source`, `options?`): `Promise`\<`Document`\>
|
|
824
|
+
|
|
825
|
+
Opens a document whose bytes are fetched range by range ([httpRangeSource](../functions/httpRangeSource.md),
|
|
826
|
+
[callbackSource](../functions/callbackSource.md)): only what the open needs is fetched (the end of the file, the xref,
|
|
827
|
+
the catalog). Calls on the document stay synchronous; one that needs bytes not fetched yet
|
|
828
|
+
throws `data-pending` with `ranges`, so wrap later reads in [Document.ensure](#ensure).
|
|
829
|
+
|
|
830
|
+
#### Parameters
|
|
831
|
+
|
|
832
|
+
##### source
|
|
833
|
+
|
|
834
|
+
[`RangeSource`](../interfaces/RangeSource.md) \| `Promise`\<[`RangeSource`](../interfaces/RangeSource.md)\>
|
|
835
|
+
|
|
836
|
+
the file (or a promise of it, as `httpRangeSource` returns).
|
|
837
|
+
|
|
838
|
+
##### options?
|
|
839
|
+
|
|
840
|
+
[`OpenOptions`](../interfaces/OpenOptions.md) & [`RangeOptions`](../interfaces/RangeOptions.md) = `{}`
|
|
841
|
+
|
|
842
|
+
open options (password, strict, limits) and fetch options.
|
|
843
|
+
|
|
844
|
+
#### Returns
|
|
845
|
+
|
|
846
|
+
`Promise`\<`Document`\>
|
|
847
|
+
|
|
848
|
+
the document, once open has everything it needs.
|
|
849
|
+
|
|
850
|
+
#### Throws
|
|
851
|
+
|
|
852
|
+
[LaminaPdfError](LaminaPdfError.md) as [Document.open](#open); `data-pending` when fetching made no
|
|
853
|
+
progress or `maxRounds` ran out; `source-budget-exceeded`; the source's own errors
|
|
854
|
+
(`fetch-failed`, `source-changed`); the signal's reason when aborted.
|