@laminapdf/sdk 0.0.0-stage → 0.2.0-alpha.3
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 +243 -2
- package/dist/api.d.ts +26 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +12 -0
- package/dist/api.js.map +1 -0
- package/dist/builder.d.ts +335 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +574 -0
- package/dist/builder.js.map +1 -0
- package/dist/defined.d.ts +5 -0
- package/dist/defined.d.ts.map +1 -0
- package/dist/defined.js +7 -0
- package/dist/defined.js.map +1 -0
- package/dist/document.d.ts +267 -0
- package/dist/document.d.ts.map +1 -0
- package/dist/document.js +472 -0
- package/dist/document.js.map +1 -0
- package/dist/entry/node.d.ts +30 -0
- package/dist/entry/node.d.ts.map +1 -0
- package/dist/entry/node.js +37 -0
- package/dist/entry/node.js.map +1 -0
- package/dist/entry/workerd.d.ts +30 -0
- package/dist/entry/workerd.d.ts.map +1 -0
- package/dist/entry/workerd.js +37 -0
- package/dist/entry/workerd.js.map +1 -0
- package/dist/errors.d.ts +102 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +131 -0
- package/dist/errors.js.map +1 -0
- package/dist/explain.d.ts +20 -0
- package/dist/explain.d.ts.map +1 -0
- package/dist/explain.js +14 -0
- package/dist/explain.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 +73 -0
- package/dist/font.d.ts.map +1 -0
- package/dist/font.js +133 -0
- package/dist/font.js.map +1 -0
- package/dist/generated/builder-enums.d.ts +29 -0
- package/dist/generated/builder-enums.d.ts.map +1 -0
- package/dist/generated/builder-enums.js +80 -0
- package/dist/generated/builder-enums.js.map +1 -0
- package/dist/generated/codes.d.ts +109 -0
- package/dist/generated/codes.d.ts.map +1 -0
- package/dist/generated/codes.js +508 -0
- package/dist/generated/codes.js.map +1 -0
- package/dist/generated/explain.d.ts +6 -0
- package/dist/generated/explain.d.ts.map +1 -0
- package/dist/generated/explain.js +155 -0
- package/dist/generated/explain.js.map +1 -0
- package/dist/generated/extract.d.ts +235 -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/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +88 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +139 -0
- package/dist/init.js.map +1 -0
- 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/loader/fetch.d.ts +3 -0
- package/dist/loader/fetch.d.ts.map +1 -0
- package/dist/loader/fetch.js +2 -0
- package/dist/loader/fetch.js.map +1 -0
- package/dist/loader/node.d.ts +3 -0
- package/dist/loader/node.d.ts.map +1 -0
- package/dist/loader/node.js +9 -0
- package/dist/loader/node.js.map +1 -0
- package/dist/loader/workerd.d.ts +3 -0
- package/dist/loader/workerd.d.ts.map +1 -0
- package/dist/loader/workerd.js +15 -0
- package/dist/loader/workerd.js.map +1 -0
- package/dist/matrix.d.ts +16 -0
- package/dist/matrix.d.ts.map +1 -0
- package/dist/matrix.js +36 -0
- package/dist/matrix.js.map +1 -0
- package/dist/path.d.ts +34 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +49 -0
- package/dist/path.js.map +1 -0
- package/dist/source/http.d.ts +36 -0
- package/dist/source/http.d.ts.map +1 -0
- package/dist/source/http.js +211 -0
- package/dist/source/http.js.map +1 -0
- package/dist/source/range.d.ts +75 -0
- package/dist/source/range.d.ts.map +1 -0
- package/dist/source/range.js +100 -0
- package/dist/source/range.js.map +1 -0
- package/dist/text.d.ts +90 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +127 -0
- package/dist/text.js.map +1 -0
- package/dist/transaction.d.ts +36 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transaction.js +47 -0
- package/dist/transaction.js.map +1 -0
- package/dist/types.d.ts +79 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/worker/client.d.ts +88 -0
- package/dist/worker/client.d.ts.map +1 -0
- package/dist/worker/client.js +407 -0
- package/dist/worker/client.js.map +1 -0
- package/dist/worker/emitter.d.ts +12 -0
- package/dist/worker/emitter.d.ts.map +1 -0
- package/dist/worker/emitter.js +34 -0
- package/dist/worker/emitter.js.map +1 -0
- package/dist/worker/entry.d.ts +2 -0
- package/dist/worker/entry.d.ts.map +1 -0
- package/dist/worker/entry.js +4 -0
- package/dist/worker/entry.js.map +1 -0
- package/dist/worker/index.d.ts +7 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +4 -0
- package/dist/worker/index.js.map +1 -0
- package/dist/worker/protocol.d.ts +82 -0
- package/dist/worker/protocol.d.ts.map +1 -0
- package/dist/worker/protocol.js +11 -0
- package/dist/worker/protocol.js.map +1 -0
- package/dist/worker/server.d.ts +51 -0
- package/dist/worker/server.d.ts.map +1 -0
- package/dist/worker/server.js +493 -0
- package/dist/worker/server.js.map +1 -0
- package/dist/worker/support.d.ts +43 -0
- package/dist/worker/support.d.ts.map +1 -0
- package/dist/worker/support.js +26 -0
- package/dist/worker/support.js.map +1 -0
- package/dist/worker/transfer.d.ts +3 -0
- package/dist/worker/transfer.d.ts.map +1 -0
- package/dist/worker/transfer.js +13 -0
- package/dist/worker/transfer.js.map +1 -0
- package/dist/worker/types.d.ts +50 -0
- package/dist/worker/types.d.ts.map +1 -0
- package/dist/worker/types.js +2 -0
- package/dist/worker/types.js.map +1 -0
- package/docs/AGENTS.md +14 -0
- package/docs/api/README.md +147 -0
- package/docs/api/classes/Builder.md +467 -0
- package/docs/api/classes/Document.md +742 -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 +326 -0
- package/docs/api/classes/Transaction.md +111 -0
- package/docs/api/functions/callbackSource.md +33 -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/HttpRangeOptions.md +78 -0
- package/docs/api/interfaces/InitOptions.md +40 -0
- package/docs/api/interfaces/Leak.md +21 -0
- package/docs/api/interfaces/Location.md +53 -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/ExtractedBlock.md +82 -0
- package/docs/api/type-aliases/ExtractedPage.md +65 -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 +41 -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/Op.md +15 -0
- package/docs/api/type-aliases/OutlineEntry.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/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 +63 -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/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/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 +156 -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/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-limit-blocks.md +35 -0
- package/docs/errors/extract-module-not-loaded.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/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 +35 -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-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/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/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/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/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/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 +88 -0
- package/docs/pages/concepts/dependencies.md +44 -0
- package/docs/pages/concepts/errors-and-warnings.md +64 -0
- package/docs/pages/concepts/how-lamina-thinks.md +86 -0
- package/docs/pages/concepts/pages-and-coordinates.md +67 -0
- package/docs/pages/guides/accessible-pdfs.md +260 -0
- package/docs/pages/guides/archival-pdfs.md +429 -0
- package/docs/pages/guides/edit-a-pdf.md +137 -0
- package/docs/pages/guides/fonts-and-text.md +202 -0
- package/docs/pages/guides/images-and-vectors.md +219 -0
- package/docs/pages/guides/keep-the-page-responsive.md +81 -0
- package/docs/pages/guides/links-outlines-and-metadata.md +222 -0
- package/docs/pages/guides/password-protected-files.md +70 -0
- package/docs/pages/guides/save-a-pdf.md +144 -0
- package/docs/pages/guides/untrusted-files.md +80 -0
- package/docs/pages/index.md +33 -0
- package/docs/pages/install.md +75 -0
- package/docs/pages/quick-start/browser.md +67 -0
- package/docs/pages/quick-start/bun.md +60 -0
- package/docs/pages/quick-start/deno.md +58 -0
- package/docs/pages/quick-start/node.md +61 -0
- package/docs/pages/quick-start/rust.md +58 -0
- package/docs/pages/quick-start/workers.md +139 -0
- package/docs/pages/recipes/cloudflare-worker.md +115 -0
- package/docs/pages/recipes/extract-markdown.md +114 -0
- package/docs/pages/recipes/generate-then-edit.md +135 -0
- package/docs/pages/recipes/hello.md +94 -0
- package/docs/pages/recipes/images-and-vectors.md +209 -0
- package/docs/pages/recipes/invoice.md +226 -0
- package/docs/pages/recipes/links-and-outlines.md +215 -0
- package/docs/pages/recipes/multilingual.md +189 -0
- package/docs/pages/recipes/open-untrusted.md +65 -0
- package/docs/pages/recipes/pdf-a-archive.md +205 -0
- package/docs/pages/recipes/pdf-a3-invoice-with-xml.md +222 -0
- package/docs/pages/recipes/pdf-ua-report.md +237 -0
- package/docs/pages/recipes/report.md +125 -0
- package/docs/pages/recipes/web-worker-client.md +64 -0
- package/docs/pages/recipes.md +47 -0
- package/docs/pages/reference/changelog.md +86 -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 +77 -0
- package/docs/pages/troubleshooting.md +74 -0
- package/docs/renames.json +86 -0
- package/docs/schemas/error.schema.json +305 -0
- package/docs/schemas/renames.schema.json +29 -0
- package/package.json +93 -3
- package/schemas/error.schema.json +305 -0
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
---
|
|
2
|
+
version: "0.2.0-alpha.3"
|
|
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
|
+
### owned
|
|
116
|
+
|
|
117
|
+
#### Get Signature
|
|
118
|
+
|
|
119
|
+
> **get** `protected` **owned**(): `boolean`
|
|
120
|
+
|
|
121
|
+
Whether the handle's raw objects can be freed: its instance is current and hasn't trapped.
|
|
122
|
+
|
|
123
|
+
##### Returns
|
|
124
|
+
|
|
125
|
+
`boolean`
|
|
126
|
+
|
|
127
|
+
#### Inherited from
|
|
128
|
+
|
|
129
|
+
`Handle.owned`
|
|
130
|
+
|
|
131
|
+
***
|
|
132
|
+
|
|
133
|
+
### pageCount
|
|
134
|
+
|
|
135
|
+
#### Get Signature
|
|
136
|
+
|
|
137
|
+
> **get** **pageCount**(): `number`
|
|
138
|
+
|
|
139
|
+
The number of pages.
|
|
140
|
+
|
|
141
|
+
##### Throws
|
|
142
|
+
|
|
143
|
+
[LaminaPdfError](LaminaPdfError.md) reading errors.
|
|
144
|
+
|
|
145
|
+
##### Returns
|
|
146
|
+
|
|
147
|
+
`number`
|
|
148
|
+
|
|
149
|
+
***
|
|
150
|
+
|
|
151
|
+
### pages
|
|
152
|
+
|
|
153
|
+
#### Get Signature
|
|
154
|
+
|
|
155
|
+
> **get** **pages**(): readonly `PageInfoJs`[]
|
|
156
|
+
|
|
157
|
+
Every page's facts, in order (one page-tree walk).
|
|
158
|
+
|
|
159
|
+
##### Throws
|
|
160
|
+
|
|
161
|
+
[LaminaPdfError](LaminaPdfError.md) reading errors.
|
|
162
|
+
|
|
163
|
+
##### Returns
|
|
164
|
+
|
|
165
|
+
readonly `PageInfoJs`[]
|
|
166
|
+
|
|
167
|
+
***
|
|
168
|
+
|
|
169
|
+
### warnings
|
|
170
|
+
|
|
171
|
+
#### Get Signature
|
|
172
|
+
|
|
173
|
+
> **get** **warnings**(): readonly [`LaminaPdfWarning`](../type-aliases/LaminaPdfWarning.md)[]
|
|
174
|
+
|
|
175
|
+
Every warning so far (build warnings first), each the ADR 0026 §1 object.
|
|
176
|
+
|
|
177
|
+
##### Returns
|
|
178
|
+
|
|
179
|
+
readonly [`LaminaPdfWarning`](../type-aliases/LaminaPdfWarning.md)[]
|
|
180
|
+
|
|
181
|
+
## Methods
|
|
182
|
+
|
|
183
|
+
### \[dispose\]()
|
|
184
|
+
|
|
185
|
+
> **\[dispose\]**(): `void`
|
|
186
|
+
|
|
187
|
+
Frees the handle at the end of a `using` block (an alias of `free()`).
|
|
188
|
+
|
|
189
|
+
#### Returns
|
|
190
|
+
|
|
191
|
+
`void`
|
|
192
|
+
|
|
193
|
+
#### Inherited from
|
|
194
|
+
|
|
195
|
+
`Handle.[dispose]`
|
|
196
|
+
|
|
197
|
+
***
|
|
198
|
+
|
|
199
|
+
### apply()
|
|
200
|
+
|
|
201
|
+
> **apply**(`ops`): `EditedJs`
|
|
202
|
+
|
|
203
|
+
Applies `ops` in order as one transaction: all of them, or none.
|
|
204
|
+
|
|
205
|
+
#### Parameters
|
|
206
|
+
|
|
207
|
+
##### ops
|
|
208
|
+
|
|
209
|
+
readonly `Op`[]
|
|
210
|
+
|
|
211
|
+
#### Returns
|
|
212
|
+
|
|
213
|
+
`EditedJs`
|
|
214
|
+
|
|
215
|
+
the pages the edit touched.
|
|
216
|
+
|
|
217
|
+
#### Throws
|
|
218
|
+
|
|
219
|
+
[LaminaPdfError](LaminaPdfError.md) `unknown-option` / `invalid-argument` for a value that isn't an op;
|
|
220
|
+
the first failing op's error (`unknown-page`, …), with nothing applied.
|
|
221
|
+
|
|
222
|
+
***
|
|
223
|
+
|
|
224
|
+
### applyLog()
|
|
225
|
+
|
|
226
|
+
> **applyLog**(`log`): `EditedJs`
|
|
227
|
+
|
|
228
|
+
Applies an op log (`{ v: 1, ops }`, as JSON text or an object) as one transaction.
|
|
229
|
+
|
|
230
|
+
#### Parameters
|
|
231
|
+
|
|
232
|
+
##### log
|
|
233
|
+
|
|
234
|
+
`string` \| [`OpLog`](../interfaces/OpLog.md)
|
|
235
|
+
|
|
236
|
+
#### Returns
|
|
237
|
+
|
|
238
|
+
`EditedJs`
|
|
239
|
+
|
|
240
|
+
#### Throws
|
|
241
|
+
|
|
242
|
+
[LaminaPdfError](LaminaPdfError.md) `invalid-op-log`, `unsupported-version`; as [Document.apply](#apply).
|
|
243
|
+
|
|
244
|
+
***
|
|
245
|
+
|
|
246
|
+
### assertLive()
|
|
247
|
+
|
|
248
|
+
> `protected` **assertLive**(): `void`
|
|
249
|
+
|
|
250
|
+
#### Returns
|
|
251
|
+
|
|
252
|
+
`void`
|
|
253
|
+
|
|
254
|
+
#### Throws
|
|
255
|
+
|
|
256
|
+
[LaminaPdfError](LaminaPdfError.md) `disposed` after `free()` (here or on the parent);
|
|
257
|
+
`instance-reset` when the instance was replaced (a trapped one is replaced first).
|
|
258
|
+
|
|
259
|
+
#### Inherited from
|
|
260
|
+
|
|
261
|
+
`Handle.assertLive`
|
|
262
|
+
|
|
263
|
+
***
|
|
264
|
+
|
|
265
|
+
### call()
|
|
266
|
+
|
|
267
|
+
> `protected` **call**\<`T`\>(`f`): `T`
|
|
268
|
+
|
|
269
|
+
Runs `f` (calls into the glue) on this live handle; see Instance.call.
|
|
270
|
+
|
|
271
|
+
#### Type Parameters
|
|
272
|
+
|
|
273
|
+
##### T
|
|
274
|
+
|
|
275
|
+
`T`
|
|
276
|
+
|
|
277
|
+
#### Parameters
|
|
278
|
+
|
|
279
|
+
##### f
|
|
280
|
+
|
|
281
|
+
(`glue`) => `T`
|
|
282
|
+
|
|
283
|
+
#### Returns
|
|
284
|
+
|
|
285
|
+
`T`
|
|
286
|
+
|
|
287
|
+
#### Inherited from
|
|
288
|
+
|
|
289
|
+
`Handle.call`
|
|
290
|
+
|
|
291
|
+
***
|
|
292
|
+
|
|
293
|
+
### ensure()
|
|
294
|
+
|
|
295
|
+
> **ensure**\<`T`\>(`f`, `options?`): `Promise`\<`T`\>
|
|
296
|
+
|
|
297
|
+
Runs a synchronous call on this document, fetching what it needs first: for a document
|
|
298
|
+
from [Document.openRange](#openrange), a `data-pending` makes it fetch the ranges asked for and
|
|
299
|
+
call `f` again. For other documents it just returns `f()`.
|
|
300
|
+
|
|
301
|
+
#### Type Parameters
|
|
302
|
+
|
|
303
|
+
##### T
|
|
304
|
+
|
|
305
|
+
`T`
|
|
306
|
+
|
|
307
|
+
#### Parameters
|
|
308
|
+
|
|
309
|
+
##### f
|
|
310
|
+
|
|
311
|
+
() => `T` \| `Promise`\<`T`\>
|
|
312
|
+
|
|
313
|
+
the call (it may run several times; keep it free of side effects). An async
|
|
314
|
+
function works too: its `data-pending` rejections are caught the same way.
|
|
315
|
+
|
|
316
|
+
##### options?
|
|
317
|
+
|
|
318
|
+
`signal` aborts this call's fetches (the open's signal applies to the open
|
|
319
|
+
only).
|
|
320
|
+
|
|
321
|
+
###### signal?
|
|
322
|
+
|
|
323
|
+
`AbortSignal`
|
|
324
|
+
|
|
325
|
+
#### Returns
|
|
326
|
+
|
|
327
|
+
`Promise`\<`T`\>
|
|
328
|
+
|
|
329
|
+
what `f` returns.
|
|
330
|
+
|
|
331
|
+
#### Example
|
|
332
|
+
|
|
333
|
+
```ts
|
|
334
|
+
const doc = await Document.openRange(httpRangeSource(url));
|
|
335
|
+
const pages = await doc.ensure(() => doc.pages);
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
#### Throws
|
|
339
|
+
|
|
340
|
+
what `f` throws, and as [Document.openRange](#openrange).
|
|
341
|
+
|
|
342
|
+
***
|
|
343
|
+
|
|
344
|
+
### extract()
|
|
345
|
+
|
|
346
|
+
> **extract**\<`F`\>(`options`): [`ExtractResult`](../interfaces/ExtractResult.md)\[`F`\]
|
|
347
|
+
|
|
348
|
+
The document's text for retrieval and LLMs: Markdown or plain text in reading order, the
|
|
349
|
+
`laminapdf.extract/1` JSON with a box for every block, or chunks sized for retrieval. Tables
|
|
350
|
+
drawn with lines come out as tables, and text a reader can't see is left out. Needs a
|
|
351
|
+
document opened while the extract or text module was loaded.
|
|
352
|
+
|
|
353
|
+
#### Type Parameters
|
|
354
|
+
|
|
355
|
+
##### F
|
|
356
|
+
|
|
357
|
+
`F` *extends* [`ExtractFormat`](../type-aliases/ExtractFormat.md)
|
|
358
|
+
|
|
359
|
+
#### Parameters
|
|
360
|
+
|
|
361
|
+
##### options
|
|
362
|
+
|
|
363
|
+
[`ExtractOptions`](../interfaces/ExtractOptions.md)\<`F`\>
|
|
364
|
+
|
|
365
|
+
#### Returns
|
|
366
|
+
|
|
367
|
+
[`ExtractResult`](../interfaces/ExtractResult.md)\[`F`\]
|
|
368
|
+
|
|
369
|
+
a string for `"markdown"` and `"text"`, an [Extraction](../type-aliases/Extraction.md) for `"json"`,
|
|
370
|
+
[Chunk](../type-aliases/Chunk.md)s for `"chunks"`.
|
|
371
|
+
|
|
372
|
+
#### Example
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
await init({ extract: true });
|
|
376
|
+
const doc = Document.open(bytes);
|
|
377
|
+
const markdown = doc.extract({ format: "markdown" });
|
|
378
|
+
const chunks = doc.extract({ format: "chunks", chunk: { maxTokens: 400 } });
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
#### Throws
|
|
382
|
+
|
|
383
|
+
[LaminaPdfError](LaminaPdfError.md) `extract-module-not-loaded` for a document opened in the base
|
|
384
|
+
module; `page-index-out-of-range`; `unknown-option` (with `didYouMean`) / `invalid-argument`
|
|
385
|
+
for bad options; reading errors (`data-pending` for a range document: use `ensure`).
|
|
386
|
+
|
|
387
|
+
***
|
|
388
|
+
|
|
389
|
+
### free()
|
|
390
|
+
|
|
391
|
+
> **free**(): `void`
|
|
392
|
+
|
|
393
|
+
Frees the handle's memory now; without it, the garbage collector frees it later. A second
|
|
394
|
+
call does nothing, and any other call afterwards throws `disposed`. Prefer `using`, which
|
|
395
|
+
calls this at the end of the block.
|
|
396
|
+
|
|
397
|
+
#### Returns
|
|
398
|
+
|
|
399
|
+
`void`
|
|
400
|
+
|
|
401
|
+
#### Inherited from
|
|
402
|
+
|
|
403
|
+
`Handle.free`
|
|
404
|
+
|
|
405
|
+
***
|
|
406
|
+
|
|
407
|
+
### page()
|
|
408
|
+
|
|
409
|
+
> **page**(`index`): [`PageRef`](PageRef.md)
|
|
410
|
+
|
|
411
|
+
A handle on page `index` that follows the page by its ID.
|
|
412
|
+
|
|
413
|
+
#### Parameters
|
|
414
|
+
|
|
415
|
+
##### index
|
|
416
|
+
|
|
417
|
+
`number`
|
|
418
|
+
|
|
419
|
+
#### Returns
|
|
420
|
+
|
|
421
|
+
[`PageRef`](PageRef.md)
|
|
422
|
+
|
|
423
|
+
#### Throws
|
|
424
|
+
|
|
425
|
+
[LaminaPdfError](LaminaPdfError.md) `page-index-out-of-range`.
|
|
426
|
+
|
|
427
|
+
***
|
|
428
|
+
|
|
429
|
+
### pageById()
|
|
430
|
+
|
|
431
|
+
> **pageById**(`id`): [`PageRef`](PageRef.md)
|
|
432
|
+
|
|
433
|
+
A handle on the page with `id` (`p12.0`).
|
|
434
|
+
|
|
435
|
+
#### Parameters
|
|
436
|
+
|
|
437
|
+
##### id
|
|
438
|
+
|
|
439
|
+
`string`
|
|
440
|
+
|
|
441
|
+
#### Returns
|
|
442
|
+
|
|
443
|
+
[`PageRef`](PageRef.md)
|
|
444
|
+
|
|
445
|
+
#### Throws
|
|
446
|
+
|
|
447
|
+
[LaminaPdfError](LaminaPdfError.md) `invalid-argument`, `unknown-page`.
|
|
448
|
+
|
|
449
|
+
***
|
|
450
|
+
|
|
451
|
+
### pageInfo()
|
|
452
|
+
|
|
453
|
+
> **pageInfo**(`index`): `PageInfoJs`
|
|
454
|
+
|
|
455
|
+
Page `index`'s facts.
|
|
456
|
+
|
|
457
|
+
#### Parameters
|
|
458
|
+
|
|
459
|
+
##### index
|
|
460
|
+
|
|
461
|
+
`number`
|
|
462
|
+
|
|
463
|
+
#### Returns
|
|
464
|
+
|
|
465
|
+
`PageInfoJs`
|
|
466
|
+
|
|
467
|
+
#### Throws
|
|
468
|
+
|
|
469
|
+
[LaminaPdfError](LaminaPdfError.md) `page-index-out-of-range`.
|
|
470
|
+
|
|
471
|
+
***
|
|
472
|
+
|
|
473
|
+
### rebase()
|
|
474
|
+
|
|
475
|
+
> **rebase**(`bytes`): `void`
|
|
476
|
+
|
|
477
|
+
Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
|
|
478
|
+
|
|
479
|
+
#### Parameters
|
|
480
|
+
|
|
481
|
+
##### bytes
|
|
482
|
+
|
|
483
|
+
`Uint8Array`
|
|
484
|
+
|
|
485
|
+
#### Returns
|
|
486
|
+
|
|
487
|
+
`void`
|
|
488
|
+
|
|
489
|
+
#### Throws
|
|
490
|
+
|
|
491
|
+
[LaminaPdfError](LaminaPdfError.md) `no-pending-save`; reading errors in `bytes`.
|
|
492
|
+
|
|
493
|
+
***
|
|
494
|
+
|
|
495
|
+
### redo()
|
|
496
|
+
|
|
497
|
+
> **redo**(): `UndoOutcomeJs` \| `undefined`
|
|
498
|
+
|
|
499
|
+
Redoes the newest undone transaction.
|
|
500
|
+
|
|
501
|
+
#### Returns
|
|
502
|
+
|
|
503
|
+
`UndoOutcomeJs` \| `undefined`
|
|
504
|
+
|
|
505
|
+
how it went, or `undefined` when there is nothing to redo.
|
|
506
|
+
|
|
507
|
+
#### Throws
|
|
508
|
+
|
|
509
|
+
[LaminaPdfError](LaminaPdfError.md) as [Document.undo](#undo).
|
|
510
|
+
|
|
511
|
+
***
|
|
512
|
+
|
|
513
|
+
### release()
|
|
514
|
+
|
|
515
|
+
> `protected` **release**(): `void`
|
|
516
|
+
|
|
517
|
+
Frees the WebAssembly side; called at most once, and only while [owned](#owned).
|
|
518
|
+
|
|
519
|
+
#### Returns
|
|
520
|
+
|
|
521
|
+
`void`
|
|
522
|
+
|
|
523
|
+
#### Overrides
|
|
524
|
+
|
|
525
|
+
`Handle.release`
|
|
526
|
+
|
|
527
|
+
***
|
|
528
|
+
|
|
529
|
+
### save()
|
|
530
|
+
|
|
531
|
+
> **save**(`options?`): `Uint8Array`\<`ArrayBuffer`\>
|
|
532
|
+
|
|
533
|
+
Saves and rebases onto the output (later edits and saves build on it).
|
|
534
|
+
|
|
535
|
+
#### Parameters
|
|
536
|
+
|
|
537
|
+
##### options?
|
|
538
|
+
|
|
539
|
+
`SaveOptionsInit`
|
|
540
|
+
|
|
541
|
+
`mode` (`auto`, `incremental`, `fullRewrite`), overrides, output form.
|
|
542
|
+
|
|
543
|
+
#### Returns
|
|
544
|
+
|
|
545
|
+
`Uint8Array`\<`ArrayBuffer`\>
|
|
546
|
+
|
|
547
|
+
the file's bytes.
|
|
548
|
+
|
|
549
|
+
#### Throws
|
|
550
|
+
|
|
551
|
+
[LaminaPdfError](LaminaPdfError.md) `would-invalidate-signatures`, `requires-rewrite`, `encrypted-base`, …
|
|
552
|
+
|
|
553
|
+
***
|
|
554
|
+
|
|
555
|
+
### saveJob()
|
|
556
|
+
|
|
557
|
+
> **saveJob**(`options?`): [`SaveJob`](SaveJob.md)
|
|
558
|
+
|
|
559
|
+
A save as a job stepped by the caller (to keep a UI responsive).
|
|
560
|
+
|
|
561
|
+
#### Parameters
|
|
562
|
+
|
|
563
|
+
##### options?
|
|
564
|
+
|
|
565
|
+
`SaveOptionsInit`
|
|
566
|
+
|
|
567
|
+
#### Returns
|
|
568
|
+
|
|
569
|
+
[`SaveJob`](SaveJob.md)
|
|
570
|
+
|
|
571
|
+
#### Throws
|
|
572
|
+
|
|
573
|
+
[LaminaPdfError](LaminaPdfError.md) `unknown-option` / `invalid-argument` for bad options.
|
|
574
|
+
|
|
575
|
+
***
|
|
576
|
+
|
|
577
|
+
### saveWithReport()
|
|
578
|
+
|
|
579
|
+
> **saveWithReport**(`options?`): `object`
|
|
580
|
+
|
|
581
|
+
As [Document.save](#save), with the save's report (mode used, bytes written, renumbering, …).
|
|
582
|
+
|
|
583
|
+
#### Parameters
|
|
584
|
+
|
|
585
|
+
##### options?
|
|
586
|
+
|
|
587
|
+
`SaveOptionsInit`
|
|
588
|
+
|
|
589
|
+
#### Returns
|
|
590
|
+
|
|
591
|
+
`object`
|
|
592
|
+
|
|
593
|
+
##### bytes
|
|
594
|
+
|
|
595
|
+
> `readonly` **bytes**: `Uint8Array`\<`ArrayBuffer`\>
|
|
596
|
+
|
|
597
|
+
##### report
|
|
598
|
+
|
|
599
|
+
> `readonly` **report**: `SaveReportJs`
|
|
600
|
+
|
|
601
|
+
#### Throws
|
|
602
|
+
|
|
603
|
+
[LaminaPdfError](LaminaPdfError.md) as [Document.save](#save).
|
|
604
|
+
|
|
605
|
+
***
|
|
606
|
+
|
|
607
|
+
### transact()
|
|
608
|
+
|
|
609
|
+
> **transact**\<`T`\>(`edit`): `T`
|
|
610
|
+
|
|
611
|
+
Runs `edit` with a transaction handle and applies what it collected as one transaction
|
|
612
|
+
(ADR 0006 §2). When `edit` throws, nothing is applied and the error propagates. The ops are
|
|
613
|
+
applied when `edit` returns: reads inside `edit` see the document before the transaction.
|
|
614
|
+
|
|
615
|
+
#### Type Parameters
|
|
616
|
+
|
|
617
|
+
##### T
|
|
618
|
+
|
|
619
|
+
`T`
|
|
620
|
+
|
|
621
|
+
#### Parameters
|
|
622
|
+
|
|
623
|
+
##### edit
|
|
624
|
+
|
|
625
|
+
(`tx`) => `T`
|
|
626
|
+
|
|
627
|
+
collects ops on `tx`; synchronous only (a callback returning a promise is
|
|
628
|
+
refused with `invalid-argument` and nothing is applied).
|
|
629
|
+
|
|
630
|
+
#### Returns
|
|
631
|
+
|
|
632
|
+
`T`
|
|
633
|
+
|
|
634
|
+
what `edit` returned.
|
|
635
|
+
|
|
636
|
+
#### Throws
|
|
637
|
+
|
|
638
|
+
[LaminaPdfError](LaminaPdfError.md) `nested-transaction` when called (or when `apply`, `undo`, `redo`,
|
|
639
|
+
`save`… are called) inside a `transact` of the same document; `invalid-argument` for an
|
|
640
|
+
async callback; as [Document.apply](#apply).
|
|
641
|
+
|
|
642
|
+
#### Example
|
|
643
|
+
|
|
644
|
+
```ts
|
|
645
|
+
doc.transact((tx) => {
|
|
646
|
+
tx.setInfo({ title: "Report" });
|
|
647
|
+
tx.rotatePage(doc.page(0).id, 90);
|
|
648
|
+
});
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
***
|
|
652
|
+
|
|
653
|
+
### undo()
|
|
654
|
+
|
|
655
|
+
> **undo**(): `UndoOutcomeJs` \| `undefined`
|
|
656
|
+
|
|
657
|
+
Undoes the newest transaction.
|
|
658
|
+
|
|
659
|
+
#### Returns
|
|
660
|
+
|
|
661
|
+
`UndoOutcomeJs` \| `undefined`
|
|
662
|
+
|
|
663
|
+
how it went, or `undefined` when there is nothing to undo.
|
|
664
|
+
|
|
665
|
+
#### Throws
|
|
666
|
+
|
|
667
|
+
[LaminaPdfError](LaminaPdfError.md) `saved-not-rebased`; reading errors.
|
|
668
|
+
|
|
669
|
+
***
|
|
670
|
+
|
|
671
|
+
### open()
|
|
672
|
+
|
|
673
|
+
> `static` **open**(`bytes`, `options?`): `Document`
|
|
674
|
+
|
|
675
|
+
Opens a document from its bytes (the bytes are copied into the WASM memory).
|
|
676
|
+
|
|
677
|
+
The password is tried as given. When that fails with `wrong-password` and its NFKC form
|
|
678
|
+
differs, the NFKC form is tried too: R5/R6 passwords are prepared with SASLprep, whose
|
|
679
|
+
normalisation the WASM modules leave out (ADR 0016 §7), while R2–R4 passwords must reach
|
|
680
|
+
the core unchanged.
|
|
681
|
+
|
|
682
|
+
#### Parameters
|
|
683
|
+
|
|
684
|
+
##### bytes
|
|
685
|
+
|
|
686
|
+
`ArrayBuffer` \| `Uint8Array`\<`ArrayBufferLike`\>
|
|
687
|
+
|
|
688
|
+
the PDF file.
|
|
689
|
+
|
|
690
|
+
##### options?
|
|
691
|
+
|
|
692
|
+
[`OpenOptions`](../interfaces/OpenOptions.md)
|
|
693
|
+
|
|
694
|
+
password, strict mode, limits.
|
|
695
|
+
|
|
696
|
+
#### Returns
|
|
697
|
+
|
|
698
|
+
`Document`
|
|
699
|
+
|
|
700
|
+
the document.
|
|
701
|
+
|
|
702
|
+
#### Throws
|
|
703
|
+
|
|
704
|
+
[LaminaPdfError](LaminaPdfError.md) `not-pdf`, `password-required`, `wrong-password`, `limit-exceeded`,
|
|
705
|
+
`strict`, …; `unknown-option` / `invalid-argument` for bad options; `not-initialized`.
|
|
706
|
+
|
|
707
|
+
***
|
|
708
|
+
|
|
709
|
+
### openRange()
|
|
710
|
+
|
|
711
|
+
> `static` **openRange**(`source`, `options?`): `Promise`\<`Document`\>
|
|
712
|
+
|
|
713
|
+
Opens a document whose bytes are fetched range by range ([httpRangeSource](../functions/httpRangeSource.md),
|
|
714
|
+
[callbackSource](../functions/callbackSource.md)): only what the open needs is fetched (the end of the file, the xref,
|
|
715
|
+
the catalog). Calls on the document stay synchronous; one that needs bytes not fetched yet
|
|
716
|
+
throws `data-pending` with `ranges`, so wrap later reads in [Document.ensure](#ensure).
|
|
717
|
+
|
|
718
|
+
#### Parameters
|
|
719
|
+
|
|
720
|
+
##### source
|
|
721
|
+
|
|
722
|
+
[`RangeSource`](../interfaces/RangeSource.md) \| `Promise`\<[`RangeSource`](../interfaces/RangeSource.md)\>
|
|
723
|
+
|
|
724
|
+
the file (or a promise of it, as `httpRangeSource` returns).
|
|
725
|
+
|
|
726
|
+
##### options?
|
|
727
|
+
|
|
728
|
+
[`OpenOptions`](../interfaces/OpenOptions.md) & [`RangeOptions`](../interfaces/RangeOptions.md) = `{}`
|
|
729
|
+
|
|
730
|
+
open options (password, strict, limits) and fetch options.
|
|
731
|
+
|
|
732
|
+
#### Returns
|
|
733
|
+
|
|
734
|
+
`Promise`\<`Document`\>
|
|
735
|
+
|
|
736
|
+
the document, once open has everything it needs.
|
|
737
|
+
|
|
738
|
+
#### Throws
|
|
739
|
+
|
|
740
|
+
[LaminaPdfError](LaminaPdfError.md) as [Document.open](#open); `data-pending` when fetching made no
|
|
741
|
+
progress or `maxRounds` ran out; `source-budget-exceeded`; the source's own errors
|
|
742
|
+
(`fetch-failed`, `source-changed`); the signal's reason when aborted.
|