pdf-codec 5.4.0 → 5.5.1
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 +19 -1
- package/dist/codec.d.cts +8 -0
- package/dist/codec.d.ts +8 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +3 -2
- package/dist/layout.cjs +14 -1
- package/dist/layout.d.cts +21 -1
- package/dist/layout.d.ts +21 -1
- package/dist/layout.js +14 -2
- package/dist/read.cjs +26 -14
- package/dist/read.d.cts +22 -3
- package/dist/read.d.ts +22 -3
- package/dist/read.js +26 -14
- package/dist/write-skipped-surfaces.cjs +16 -0
- package/dist/write-skipped-surfaces.d.cts +12 -0
- package/dist/write-skipped-surfaces.d.ts +12 -0
- package/dist/write-skipped-surfaces.js +15 -0
- package/dist/write.cjs +2 -0
- package/dist/write.js +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -93,7 +93,25 @@ An encrypted PDF that opens without a password decrypts transparently — no ext
|
|
|
93
93
|
|
|
94
94
|
Both accept an optional `signal` (`AbortSignal`); `readPdf` additionally takes a `sink` (`PdfDiagnosticSink`, called once per recoverable parse diagnostic — see the three-tier failure policy under [Conventions](#conventions)), and `writePdf` an `onSubstitution` callback (called once per character not representable in a standard-14 font — see [Fidelity](#fidelity)).
|
|
95
95
|
|
|
96
|
-
**Reading a subset of pages.** `readPdf(bytes, { pages: [0, 1, 2, -1] })` reads only the listed pages: zero-based indices into the page tree, a negative index counted from the end (`-1` is the last page). What a selected read skips: an unselected page's content stream is never fetched, decoded or interpreted, so the fonts and images only unselected pages use are never resolved, and no embedded file is decoded, so `attachments` is absent from a page-selected result (an attachment is document-level payload whose size is independent of the pages asked for); an absent `attachments` therefore means "not read" whenever `pageCount` is set, which only a page-selected read does, so check `pageCount` before concluding a document has no attachments. The case this exists for is identifying a document from its first pages, or reading a code from its last page, inside a memory-capped runtime such as a Cloudflare Worker isolate, without paying for every page's content. What it still reads whole, because page references resolve against it or because it is document-level and holds no page content stream: the page tree, the outline, named destinations, optional-content layers, the AcroForm, the structure element tree and the `/ParentTree` number tree (both of which scale with the document), metadata and package residue. Two surfaces are built from page content and so cover selected pages only: the structure-ownership association an item's `structure` field names (with its parent-tree diagnostics) and the `page-boxes` residue row. A destination a link states as a direct array is minted into `destinations` (as `dest1`, `dest2`, ...) only when its page is interpreted, so an unselected page's direct link destinations are absent and a minted name depends on which pages were read; named destinations are unaffected. Duplicates collapse and the result's `pages` holds the selected pages in ascending document order, each carrying its source position as `index` (read it through `sourcePageIndex(page, position)`, which falls back to the position on a full read), with the page tree's length as the document's `pageCount`; every document-level page reference keeps naming source indices, so a reference to a selected page resolves through `index`, and one to an unselected page names a page the result does not hold. A full read sets neither field, because there `pages.length` and each page's position already state them. An empty selection is valid and reads no page, which makes `{ pages: [] }` the cheapest way to learn a file's page count and metadata. An entry naming no page (outside `-pageCount` to `pageCount - 1`, or not an integer, `NaN` and the infinities included; `-0` is page 0) throws `PdfPageSelectionError` (a `PdfParseError` with code `pdf/page-out-of-range` or `pdf/page-index-not-integer`, carrying `pageIndex` and `pageCount`) before any page is read. A page-selected `LayoutDocument` is a reading of part of a file, not a document to re-emit: `writePdf` refuses one (any document carrying `pageCount`) with `PdfPartialDocumentError`, since it places pages by position and the references would point at the wrong pages.
|
|
96
|
+
**Reading a subset of pages.** `readPdf(bytes, { pages: [0, 1, 2, -1] })` reads only the listed pages: zero-based indices into the page tree, a negative index counted from the end (`-1` is the last page). What a selected read skips: an unselected page's content stream is never fetched, decoded or interpreted, so the fonts and images only unselected pages use are never resolved, and no embedded file is decoded, so `attachments` is absent from a page-selected result (an attachment is document-level payload whose size is independent of the pages asked for); an absent `attachments` therefore means "not read" whenever `pageCount` is set, which only a page-selected read does, so check `pageCount` before concluding a document has no attachments. The case this exists for is identifying a document from its first pages, or reading a code from its last page, inside a memory-capped runtime such as a Cloudflare Worker isolate, without paying for every page's content. What it still reads whole, because page references resolve against it or because it is document-level and holds no page content stream: the page tree, the outline, named destinations, optional-content layers, the AcroForm, the structure element tree and the `/ParentTree` number tree (both of which scale with the document), metadata and package residue; every one of those but the page tree and metadata can be left out too, with `surfaces` (below). Two surfaces are built from page content and so cover selected pages only: the structure-ownership association an item's `structure` field names (with its parent-tree diagnostics) and the `page-boxes` residue row. A destination a link states as a direct array is minted into `destinations` (as `dest1`, `dest2`, ...) only when its page is interpreted, so an unselected page's direct link destinations are absent and a minted name depends on which pages were read (and on whether the outline was read, below); named destinations are unaffected. Duplicates collapse and the result's `pages` holds the selected pages in ascending document order, each carrying its source position as `index` (read it through `sourcePageIndex(page, position)`, which falls back to the position on a full read), with the page tree's length as the document's `pageCount`; every document-level page reference keeps naming source indices, so a reference to a selected page resolves through `index`, and one to an unselected page names a page the result does not hold. A full read sets neither field, because there `pages.length` and each page's position already state them. An empty selection is valid and reads no page, which makes `{ pages: [] }` the cheapest way to learn a file's page count and metadata. An entry naming no page (outside `-pageCount` to `pageCount - 1`, or not an integer, `NaN` and the infinities included; `-0` is page 0) throws `PdfPageSelectionError` (a `PdfParseError` with code `pdf/page-out-of-range` or `pdf/page-index-not-integer`, carrying `pageIndex` and `pageCount`) before any page is read. A page-selected `LayoutDocument` is a reading of part of a file, not a document to re-emit: `writePdf` refuses one (any document carrying `pageCount`) with `PdfPartialDocumentError`, since it places pages by position and the references would point at the wrong pages.
|
|
97
|
+
|
|
98
|
+
**Leaving document-level surfaces out.** `readPdf(bytes, { surfaces: { structure: false, outline: false } })` reads the document without the surfaces turned off. `ReadPdfOptions.surfaces` is one object of independent booleans (`ReadPdfSurfaces`), one per surface, each read unless set to `false`, so omitting the setting reads everything exactly as before. It is independent of `pages`, applying to a full read and a page-selected read alike, and combined with a small selection it is what keeps identifying a document cheap: on a long tagged PDF the structure element tree and its `/ParentTree` can be most of what a page-selected read still parses, and `{ pages: [0, 1, 2, -1], surfaces: { outline: false, destinations: false, form: false, layers: false, structure: false, residue: false } }` reads nothing beyond opening the document (cross-reference table, trailer, catalog and any encryption dictionary), the page tree, metadata and those four pages. A surface turned off is never parsed (its part of the catalog is not walked, so a malformed outline, form, layer list or structure tree reports no diagnostic), its `LayoutDocument` field is absent whatever the file holds, and the result names it in `skippedSurfaces` (in the order `LayoutDocumentSurfaceSchema` lists them, absent when every surface was read). An absent `outline`, `destinations`, `form`, `layers`, `structure` or `source` therefore means "not read" whenever `skippedSurfaces` names it, so check `skippedSurfaces` before concluding a document has none, as with `pageCount` and attachments.
|
|
99
|
+
|
|
100
|
+
Each surface, and what page items lose without it (everything else about every page item is exactly what a read with the surface on produces, apart from the renumbering a skipped outline causes):
|
|
101
|
+
|
|
102
|
+
- `outline`: the `/Outlines` bookmark tree (`outline`). Page items do not depend on it, except through minted names. A destination stated as a direct array is named with the first unused `destN` in the order the reader meets it, and the outline is read before any page, so an outline entry's direct destination takes a lower number than any link's. Without the outline, the names minted for page links' direct destinations are renumbered and `destinations` loses the entries only the outline minted, while each link still resolves to the same target.
|
|
103
|
+
|
|
104
|
+
- `destinations`: the named destinations of the catalog `/Dests` dictionary and the `/Names /Dests` name tree, and the registry links and outline entries name their targets through (`destinations`). Without it nothing can name an internal target, so a link whose target is internal (a `/Dest`, or a `/GoTo` action, whether it names a destination or states one directly) is left out of its page's items, and an outline entry, if the outline is read, carries no `destination`. A link to a URI is kept.
|
|
105
|
+
|
|
106
|
+
- `form`: the AcroForm field tree (`form`). Page items do not depend on it, since a widget annotation is never a page item or annotation either way.
|
|
107
|
+
|
|
108
|
+
- `layers`: optional content, the `/OCProperties` groups and their default visibility (`layers`). Without it no item carries a `layer`. The items themselves are all still read, so content the default configuration hides cannot be told from visible content, and a consumer that drops hidden-layer content (as documents.js's reconstruction does) keeps it.
|
|
109
|
+
|
|
110
|
+
- `structure`: the `/StructTreeRoot` element tree and its `/ParentTree` ownership map (`structure`). Without it no item carries a `structure` owner, and the parent-tree diagnostics are not reported.
|
|
111
|
+
|
|
112
|
+
- `residue`: the package-level residue rows (`source`), the per-page `page-boxes` row included. Page items do not depend on it, and `metadata` still reads the XMP packet it falls back to.
|
|
113
|
+
|
|
114
|
+
A `LayoutDocument` read with any surface skipped is a reading with parts of the file deliberately unread, so `writePdf` refuses one (any document carrying `skippedSurfaces`) with `PdfSkippedSurfacesError`, which names the skipped surfaces; a document that is also page-selected reports `PdfPartialDocumentError` first.
|
|
97
115
|
|
|
98
116
|
**Page boundaries: the crop box is the visible region** (ISO 32000-1 14.11.2). A page's reported `widthPt`/`heightPt` and coordinate frame come from its effective `/CropBox` — the rectangle a viewer displays and prints, inherited through the page tree like `/MediaBox` and defaulting to it — not from the media box: content an author placed outside the crop box (printer's marks, bleed, off-page slugs) is not visible and does not extract. Content wholly outside the crop box is dropped; content straddling the boundary keeps its original unclipped geometry (the item layer records what the file states — a viewer's clipping is a rendering fact, not source data); link annotations are anchored constructs rather than painted content and are never filtered, the same line the optional-content filter draws. The declared boundary rectangles a distinct crop box hides — plus `/BleedBox`/`/TrimBox`/`/ArtBox`, print-production facts with no field in the layout model — are quarantined verbatim as the `page-boxes` package-level residue row rather than silently dropped. A degenerate `/CropBox` (zero width or height) falls back to the media box with a `pdf/invalid-crop-box` warning.
|
|
99
117
|
|
package/dist/codec.d.cts
CHANGED
|
@@ -319,6 +319,14 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
319
319
|
}>;
|
|
320
320
|
xml: z.ZodString;
|
|
321
321
|
}, z.core.$strict>>>;
|
|
322
|
+
skippedSurfaces: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
323
|
+
structure: "structure";
|
|
324
|
+
destinations: "destinations";
|
|
325
|
+
outline: "outline";
|
|
326
|
+
layers: "layers";
|
|
327
|
+
form: "form";
|
|
328
|
+
residue: "residue";
|
|
329
|
+
}>>>;
|
|
322
330
|
}, z.core.$strip>>;
|
|
323
331
|
//#endregion
|
|
324
332
|
export { PdfBytesSchema, pdfCodec };
|
package/dist/codec.d.ts
CHANGED
|
@@ -319,6 +319,14 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
|
|
|
319
319
|
}>;
|
|
320
320
|
xml: z.ZodString;
|
|
321
321
|
}, z.core.$strict>>>;
|
|
322
|
+
skippedSurfaces: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
323
|
+
structure: "structure";
|
|
324
|
+
destinations: "destinations";
|
|
325
|
+
outline: "outline";
|
|
326
|
+
layers: "layers";
|
|
327
|
+
form: "form";
|
|
328
|
+
residue: "residue";
|
|
329
|
+
}>>>;
|
|
322
330
|
}, z.core.$strip>>;
|
|
323
331
|
//#endregion
|
|
324
332
|
export { PdfBytesSchema, pdfCodec };
|
package/dist/index.cjs
CHANGED
|
@@ -17,6 +17,7 @@ const require_math_stretch = require("./math-stretch.cjs");
|
|
|
17
17
|
const require_math_font = require("./math-font.cjs");
|
|
18
18
|
const require_font_registry = require("./font-registry.cjs");
|
|
19
19
|
const require_measure = require("./measure.cjs");
|
|
20
|
+
const require_write_skipped_surfaces = require("./write-skipped-surfaces.cjs");
|
|
20
21
|
const require_write = require("./write.cjs");
|
|
21
22
|
const require_codec = require("./codec.cjs");
|
|
22
23
|
const require_font_face = require("./font-face.cjs");
|
|
@@ -37,6 +38,7 @@ exports.LayoutAttachmentSchema = require_layout.LayoutAttachmentSchema;
|
|
|
37
38
|
exports.LayoutDestinationSchema = require_layout.LayoutDestinationSchema;
|
|
38
39
|
exports.LayoutDestinationTargetSchema = require_layout.LayoutDestinationTargetSchema;
|
|
39
40
|
exports.LayoutDocumentSchema = require_layout.LayoutDocumentSchema;
|
|
41
|
+
exports.LayoutDocumentSurfaceSchema = require_layout.LayoutDocumentSurfaceSchema;
|
|
40
42
|
exports.LayoutEllipseSchema = require_layout.LayoutEllipseSchema;
|
|
41
43
|
exports.LayoutFormFieldSchema = require_layout.LayoutFormFieldSchema;
|
|
42
44
|
exports.LayoutFormWidgetSchema = require_layout.LayoutFormWidgetSchema;
|
|
@@ -63,6 +65,7 @@ exports.PdfPageSelectionError = require_diagnostics.PdfPageSelectionError;
|
|
|
63
65
|
exports.PdfParseError = require_diagnostics.PdfParseError;
|
|
64
66
|
exports.PdfPartialDocumentError = require_write.PdfPartialDocumentError;
|
|
65
67
|
exports.PdfPasswordRequiredError = require_diagnostics.PdfPasswordRequiredError;
|
|
68
|
+
exports.PdfSkippedSurfacesError = require_write_skipped_surfaces.PdfSkippedSurfacesError;
|
|
66
69
|
exports.STANDARD_METRICS = require_afm_widths.STANDARD_METRICS;
|
|
67
70
|
exports.assembleStretchyGlyph = require_math_stretch.assembleStretchyGlyph;
|
|
68
71
|
exports.createFontMeasurer = require_measure.createFontMeasurer;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as STANDARD_METRICS, r as StandardFontName, t as FontMetrics } from "./afm-widths-D0Lu9kLv.cjs";
|
|
2
2
|
import { a as PdfEncryptedError, c as PdfPasswordRequiredError, i as PdfDiagnosticSink, n as PdfDiagnostic, o as PdfPageSelectionError, r as PdfDiagnosticSeverity, s as PdfParseError, t as NOOP_DIAGNOSTIC_SINK } from "./diagnostics-BkG_Ej2x.cjs";
|
|
3
|
-
import { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, sourcePageIndex } from "./layout.cjs";
|
|
3
|
+
import { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutDocumentSurface, LayoutDocumentSurfaceSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, sourcePageIndex } from "./layout.cjs";
|
|
4
4
|
import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
|
|
5
5
|
import { PdfBytesSchema, pdfCodec } from "./codec.cjs";
|
|
6
6
|
import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-CqePfvrl.cjs";
|
|
@@ -17,8 +17,9 @@ import { Jpeg2000ProgressionOrder, Jpeg2000QuantizationStyle, Jpeg2000Transform
|
|
|
17
17
|
import { Jpeg2000ParseError, Jpeg2000UnsupportedError } from "./image/jpeg2000-errors.cjs";
|
|
18
18
|
import { Jpeg2000ComponentMetadata, Jpeg2000DecodeOptions, Jpeg2000Image, Jpeg2000Metadata, decodeJpeg2000, readJpeg2000Metadata } from "./image/jpeg2000.cjs";
|
|
19
19
|
import { filterScanlines, unfilterScanlines } from "./image/png-filter.cjs";
|
|
20
|
-
import { ReadPdfOptions, readPdf } from "./read.cjs";
|
|
20
|
+
import { ReadPdfOptions, ReadPdfSurfaces, readPdf } from "./read.cjs";
|
|
21
21
|
import { PdfPartialDocumentError, WritePdfOptions, writePdf } from "./write.cjs";
|
|
22
|
+
import { PdfSkippedSurfacesError } from "./write-skipped-surfaces.cjs";
|
|
22
23
|
import { a as MathGlyphPart, c as MathVariants, n as MathGlyphAssembly, o as MathGlyphVariant, r as MathGlyphConstruction } from "./math-table-gFNB8DmQ.cjs";
|
|
23
24
|
import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-C2JanDAz.cjs";
|
|
24
25
|
import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } from "./math-font.cjs";
|
|
@@ -27,4 +28,4 @@ import { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_
|
|
|
27
28
|
import { PageRasteriser, RasterDrawOp, RasterFillRectOp, RasterFillSpec, RasterImageOp, RasterMatrix, RasterPageGeometry, RasterPathOp, RasterPathSegment, RasterRegionPt, RasterStrokeSpec, RasterSubpath, RenderPdfPageOptions, renderPdfPage } from "./raster.cjs";
|
|
28
29
|
import { FontRegistryOptions, FontSubstitution, MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, Point, PositionedFormula, ProvidedFont, StyledFragment, StyledRun, TextMeasurer, UnderlineMetrics, WrapOptions, WrappedLine } from "document-schema.js";
|
|
29
30
|
export * from "byte-codec";
|
|
30
|
-
export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_VERTICAL_METRIC_POLICY, DEFAULT_WORD_GAP_EM, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, type PageRasteriser, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfEncryptionError, type PdfEncryptionOptions, type PdfEncryptionPermissions, type PdfEncryptionScheme, PdfPageSelectionError, PdfParseError, PdfPartialDocumentError, PdfPasswordRequiredError, type PdfTextBox, type PdfTextGroupingOptions, type PdfTextLine, type PdfTextRunGeometry, type PdfTextWord, type PdfWordSeparator, type Point, type PositionedFormula, type ProvidedFont, type RasterDrawOp, type RasterFillRectOp, type RasterFillSpec, type RasterImageOp, type RasterMatrix, type RasterPageGeometry, type RasterPathOp, type RasterPathSegment, type RasterRegionPt, type RasterStrokeSpec, type RasterSubpath, type ReadPdfOptions, type RenderPdfPageOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runGapPt, runsShareBaseline, scaleMathStretchConstruction, sourcePageIndex, unfilterScanlines, writePdf };
|
|
31
|
+
export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_VERTICAL_METRIC_POLICY, DEFAULT_WORD_GAP_EM, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutDocumentSurface, LayoutDocumentSurfaceSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, type PageRasteriser, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfEncryptionError, type PdfEncryptionOptions, type PdfEncryptionPermissions, type PdfEncryptionScheme, PdfPageSelectionError, PdfParseError, PdfPartialDocumentError, PdfPasswordRequiredError, PdfSkippedSurfacesError, type PdfTextBox, type PdfTextGroupingOptions, type PdfTextLine, type PdfTextRunGeometry, type PdfTextWord, type PdfWordSeparator, type Point, type PositionedFormula, type ProvidedFont, type RasterDrawOp, type RasterFillRectOp, type RasterFillSpec, type RasterImageOp, type RasterMatrix, type RasterPageGeometry, type RasterPathOp, type RasterPathSegment, type RasterRegionPt, type RasterStrokeSpec, type RasterSubpath, type ReadPdfOptions, type ReadPdfSurfaces, type RenderPdfPageOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runGapPt, runsShareBaseline, scaleMathStretchConstruction, sourcePageIndex, unfilterScanlines, writePdf };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as STANDARD_METRICS, r as StandardFontName, t as FontMetrics } from "./afm-widths-D0Lu9kLv.js";
|
|
2
2
|
import { a as PdfEncryptedError, c as PdfPasswordRequiredError, i as PdfDiagnosticSink, n as PdfDiagnostic, o as PdfPageSelectionError, r as PdfDiagnosticSeverity, s as PdfParseError, t as NOOP_DIAGNOSTIC_SINK } from "./diagnostics-BkG_Ej2x.js";
|
|
3
|
-
import { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, sourcePageIndex } from "./layout.js";
|
|
3
|
+
import { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutDocumentSurface, LayoutDocumentSurfaceSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, sourcePageIndex } from "./layout.js";
|
|
4
4
|
import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.js";
|
|
5
5
|
import { PdfBytesSchema, pdfCodec } from "./codec.js";
|
|
6
6
|
import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-CQZbTTDM.js";
|
|
@@ -17,8 +17,9 @@ import { Jpeg2000ProgressionOrder, Jpeg2000QuantizationStyle, Jpeg2000Transform
|
|
|
17
17
|
import { Jpeg2000ParseError, Jpeg2000UnsupportedError } from "./image/jpeg2000-errors.js";
|
|
18
18
|
import { Jpeg2000ComponentMetadata, Jpeg2000DecodeOptions, Jpeg2000Image, Jpeg2000Metadata, decodeJpeg2000, readJpeg2000Metadata } from "./image/jpeg2000.js";
|
|
19
19
|
import { filterScanlines, unfilterScanlines } from "./image/png-filter.js";
|
|
20
|
-
import { ReadPdfOptions, readPdf } from "./read.js";
|
|
20
|
+
import { ReadPdfOptions, ReadPdfSurfaces, readPdf } from "./read.js";
|
|
21
21
|
import { PdfPartialDocumentError, WritePdfOptions, writePdf } from "./write.js";
|
|
22
|
+
import { PdfSkippedSurfacesError } from "./write-skipped-surfaces.js";
|
|
22
23
|
import { a as MathGlyphPart, c as MathVariants, n as MathGlyphAssembly, o as MathGlyphVariant, r as MathGlyphConstruction } from "./math-table-DhPrNoPa.js";
|
|
23
24
|
import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-BbC2o4Br.js";
|
|
24
25
|
import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } from "./math-font.js";
|
|
@@ -27,4 +28,4 @@ import { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_
|
|
|
27
28
|
import { PageRasteriser, RasterDrawOp, RasterFillRectOp, RasterFillSpec, RasterImageOp, RasterMatrix, RasterPageGeometry, RasterPathOp, RasterPathSegment, RasterRegionPt, RasterStrokeSpec, RasterSubpath, RenderPdfPageOptions, renderPdfPage } from "./raster.js";
|
|
28
29
|
import { FontRegistryOptions, FontSubstitution, MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, Point, PositionedFormula, ProvidedFont, StyledFragment, StyledRun, TextMeasurer, UnderlineMetrics, WrapOptions, WrappedLine } from "document-schema.js";
|
|
29
30
|
export * from "byte-codec";
|
|
30
|
-
export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_VERTICAL_METRIC_POLICY, DEFAULT_WORD_GAP_EM, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, type PageRasteriser, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfEncryptionError, type PdfEncryptionOptions, type PdfEncryptionPermissions, type PdfEncryptionScheme, PdfPageSelectionError, PdfParseError, PdfPartialDocumentError, PdfPasswordRequiredError, type PdfTextBox, type PdfTextGroupingOptions, type PdfTextLine, type PdfTextRunGeometry, type PdfTextWord, type PdfWordSeparator, type Point, type PositionedFormula, type ProvidedFont, type RasterDrawOp, type RasterFillRectOp, type RasterFillSpec, type RasterImageOp, type RasterMatrix, type RasterPageGeometry, type RasterPathOp, type RasterPathSegment, type RasterRegionPt, type RasterStrokeSpec, type RasterSubpath, type ReadPdfOptions, type RenderPdfPageOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runGapPt, runsShareBaseline, scaleMathStretchConstruction, sourcePageIndex, unfilterScanlines, writePdf };
|
|
31
|
+
export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_VERTICAL_METRIC_POLICY, DEFAULT_WORD_GAP_EM, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutDocumentSurface, LayoutDocumentSurfaceSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, type PageRasteriser, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfEncryptionError, type PdfEncryptionOptions, type PdfEncryptionPermissions, type PdfEncryptionScheme, PdfPageSelectionError, PdfParseError, PdfPartialDocumentError, PdfPasswordRequiredError, PdfSkippedSurfacesError, type PdfTextBox, type PdfTextGroupingOptions, type PdfTextLine, type PdfTextRunGeometry, type PdfTextWord, type PdfWordSeparator, type Point, type PositionedFormula, type ProvidedFont, type RasterDrawOp, type RasterFillRectOp, type RasterFillSpec, type RasterImageOp, type RasterMatrix, type RasterPageGeometry, type RasterPathOp, type RasterPathSegment, type RasterRegionPt, type RasterStrokeSpec, type RasterSubpath, type ReadPdfOptions, type ReadPdfSurfaces, type RenderPdfPageOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runGapPt, runsShareBaseline, scaleMathStretchConstruction, sourcePageIndex, unfilterScanlines, writePdf };
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { filterScanlines, unfilterScanlines } from "./image/png-filter.js";
|
|
|
6
6
|
import { Jpeg2000ParseError, Jpeg2000UnsupportedError } from "./image/jpeg2000-errors.js";
|
|
7
7
|
import { looksLikeBareCodestream, parseJp2Container } from "./image/jp2-boxes.js";
|
|
8
8
|
import { decodeJpeg2000, readJpeg2000Metadata } from "./image/jpeg2000.js";
|
|
9
|
-
import { LAYOUT_FORMAT_VERSION, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachmentSchema, LayoutDestinationSchema, LayoutDestinationTargetSchema, LayoutDocumentSchema, LayoutEllipseSchema, LayoutFormFieldSchema, LayoutFormWidgetSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLinkSchema, LayoutItemSchema, LayoutLayerSchema, LayoutLineSchema, LayoutLinkSchema, LayoutOutlineItemSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutStructureElementSchema, LayoutSubpathSchema, LayoutTextSchema, sourcePageIndex } from "./layout.js";
|
|
9
|
+
import { LAYOUT_FORMAT_VERSION, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachmentSchema, LayoutDestinationSchema, LayoutDestinationTargetSchema, LayoutDocumentSchema, LayoutDocumentSurfaceSchema, LayoutEllipseSchema, LayoutFormFieldSchema, LayoutFormWidgetSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLinkSchema, LayoutItemSchema, LayoutLayerSchema, LayoutLineSchema, LayoutLinkSchema, LayoutOutlineItemSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutStructureElementSchema, LayoutSubpathSchema, LayoutTextSchema, sourcePageIndex } from "./layout.js";
|
|
10
10
|
import { NOOP_DIAGNOSTIC_SINK, PdfEncryptedError, PdfPageSelectionError, PdfParseError, PdfPasswordRequiredError } from "./diagnostics.js";
|
|
11
11
|
import { resolveStandardFont } from "./fonts.js";
|
|
12
12
|
import { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, groupPdfTextRuns, runGapPt, runsShareBaseline } from "./text-group.js";
|
|
@@ -16,9 +16,10 @@ import { assembleStretchyGlyph, scaleMathStretchConstruction } from "./math-stre
|
|
|
16
16
|
import { loadMathFont } from "./math-font.js";
|
|
17
17
|
import { createFontRegistry, resolveFaceWithRegistry } from "./font-registry.js";
|
|
18
18
|
import { DEFAULT_VERTICAL_METRIC_POLICY, createFontMeasurer, createStandardFontMeasurer } from "./measure.js";
|
|
19
|
+
import { PdfSkippedSurfacesError } from "./write-skipped-surfaces.js";
|
|
19
20
|
import { PdfPartialDocumentError, writePdf } from "./write.js";
|
|
20
21
|
import { PdfBytesSchema, pdfCodec } from "./codec.js";
|
|
21
22
|
import { FontFaceParseError, readFontFace } from "./font-face.js";
|
|
22
23
|
import { r as renderPdfPage } from "./raster-DUmwfi3F.js";
|
|
23
24
|
export * from "byte-codec";
|
|
24
|
-
export { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_VERTICAL_METRIC_POLICY, DEFAULT_WORD_GAP_EM, FontFaceParseError, Jbig2ParseError, Jbig2UnsupportedError, Jpeg2000ParseError, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachmentSchema, LayoutDestinationSchema, LayoutDestinationTargetSchema, LayoutDocumentSchema, LayoutEllipseSchema, LayoutFormFieldSchema, LayoutFormWidgetSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLinkSchema, LayoutItemSchema, LayoutLayerSchema, LayoutLineSchema, LayoutLinkSchema, LayoutOutlineItemSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutStructureElementSchema, LayoutSubpathSchema, LayoutTextSchema, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, PdfEncryptedError, PdfEncryptionError, PdfPageSelectionError, PdfParseError, PdfPartialDocumentError, PdfPasswordRequiredError, STANDARD_METRICS, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runGapPt, runsShareBaseline, scaleMathStretchConstruction, sourcePageIndex, unfilterScanlines, writePdf };
|
|
25
|
+
export { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_VERTICAL_METRIC_POLICY, DEFAULT_WORD_GAP_EM, FontFaceParseError, Jbig2ParseError, Jbig2UnsupportedError, Jpeg2000ParseError, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachmentSchema, LayoutDestinationSchema, LayoutDestinationTargetSchema, LayoutDocumentSchema, LayoutDocumentSurfaceSchema, LayoutEllipseSchema, LayoutFormFieldSchema, LayoutFormWidgetSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLinkSchema, LayoutItemSchema, LayoutLayerSchema, LayoutLineSchema, LayoutLinkSchema, LayoutOutlineItemSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutStructureElementSchema, LayoutSubpathSchema, LayoutTextSchema, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, PdfEncryptedError, PdfEncryptionError, PdfPageSelectionError, PdfParseError, PdfPartialDocumentError, PdfPasswordRequiredError, PdfSkippedSurfacesError, STANDARD_METRICS, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runGapPt, runsShareBaseline, scaleMathStretchConstruction, sourcePageIndex, unfilterScanlines, writePdf };
|
package/dist/layout.cjs
CHANGED
|
@@ -269,6 +269,17 @@ const LayoutStructureElementSchema = zod.z.lazy(() => zod.z.object({
|
|
|
269
269
|
actualText: zod.z.string().optional(),
|
|
270
270
|
children: zod.z.array(LayoutStructureElementSchema)
|
|
271
271
|
}));
|
|
272
|
+
/**
|
|
273
|
+
* The document-level surfaces a read can leave out (`ReadPdfOptions.surfaces`), each named by the `LayoutDocument` field it fills: `outline`, `destinations`, `form`, `layers` and `structure` are those fields, and `residue` is the package-level `source` channel. A `LayoutDocument` lists the ones its read skipped in `skippedSurfaces`.
|
|
274
|
+
*/
|
|
275
|
+
const LayoutDocumentSurfaceSchema = zod.z.enum([
|
|
276
|
+
"outline",
|
|
277
|
+
"destinations",
|
|
278
|
+
"form",
|
|
279
|
+
"layers",
|
|
280
|
+
"structure",
|
|
281
|
+
"residue"
|
|
282
|
+
]);
|
|
272
283
|
const LayoutDocumentSchema = zod.z.object({
|
|
273
284
|
formatVersion: zod.z.literal(1),
|
|
274
285
|
metadata: document_schema_js.LayoutMetadataSchema,
|
|
@@ -281,7 +292,8 @@ const LayoutDocumentSchema = zod.z.object({
|
|
|
281
292
|
layers: zod.z.array(LayoutLayerSchema).optional(),
|
|
282
293
|
structure: zod.z.array(LayoutStructureElementSchema).optional(),
|
|
283
294
|
form: zod.z.array(LayoutFormFieldSchema).optional(),
|
|
284
|
-
source: zod.z.record(zod.z.string(), document_schema_js.SourceResidueSchema).optional()
|
|
295
|
+
source: zod.z.record(zod.z.string(), document_schema_js.SourceResidueSchema).optional(),
|
|
296
|
+
skippedSurfaces: zod.z.array(LayoutDocumentSurfaceSchema).min(1).optional()
|
|
285
297
|
});
|
|
286
298
|
//#endregion
|
|
287
299
|
exports.LAYOUT_FORMAT_VERSION = LAYOUT_FORMAT_VERSION;
|
|
@@ -291,6 +303,7 @@ exports.LayoutAttachmentSchema = LayoutAttachmentSchema;
|
|
|
291
303
|
exports.LayoutDestinationSchema = LayoutDestinationSchema;
|
|
292
304
|
exports.LayoutDestinationTargetSchema = LayoutDestinationTargetSchema;
|
|
293
305
|
exports.LayoutDocumentSchema = LayoutDocumentSchema;
|
|
306
|
+
exports.LayoutDocumentSurfaceSchema = LayoutDocumentSurfaceSchema;
|
|
294
307
|
exports.LayoutEllipseSchema = LayoutEllipseSchema;
|
|
295
308
|
exports.LayoutFormFieldSchema = LayoutFormFieldSchema;
|
|
296
309
|
exports.LayoutFormWidgetSchema = LayoutFormWidgetSchema;
|
package/dist/layout.d.cts
CHANGED
|
@@ -784,6 +784,18 @@ interface LayoutStructureElement {
|
|
|
784
784
|
readonly actualText?: string;
|
|
785
785
|
readonly children: readonly LayoutStructureElement[];
|
|
786
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* The document-level surfaces a read can leave out (`ReadPdfOptions.surfaces`), each named by the `LayoutDocument` field it fills: `outline`, `destinations`, `form`, `layers` and `structure` are those fields, and `residue` is the package-level `source` channel. A `LayoutDocument` lists the ones its read skipped in `skippedSurfaces`.
|
|
789
|
+
*/
|
|
790
|
+
declare const LayoutDocumentSurfaceSchema: z.ZodEnum<{
|
|
791
|
+
structure: "structure";
|
|
792
|
+
destinations: "destinations";
|
|
793
|
+
outline: "outline";
|
|
794
|
+
layers: "layers";
|
|
795
|
+
form: "form";
|
|
796
|
+
residue: "residue";
|
|
797
|
+
}>;
|
|
798
|
+
type LayoutDocumentSurface = z.infer<typeof LayoutDocumentSurfaceSchema>;
|
|
787
799
|
declare const LayoutDocumentSchema: z.ZodObject<{
|
|
788
800
|
formatVersion: z.ZodLiteral<1>;
|
|
789
801
|
metadata: z.ZodObject<{
|
|
@@ -1101,7 +1113,15 @@ declare const LayoutDocumentSchema: z.ZodObject<{
|
|
|
1101
1113
|
}>;
|
|
1102
1114
|
xml: z.ZodString;
|
|
1103
1115
|
}, z.core.$strict>>>;
|
|
1116
|
+
skippedSurfaces: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
1117
|
+
structure: "structure";
|
|
1118
|
+
destinations: "destinations";
|
|
1119
|
+
outline: "outline";
|
|
1120
|
+
layers: "layers";
|
|
1121
|
+
form: "form";
|
|
1122
|
+
residue: "residue";
|
|
1123
|
+
}>>>;
|
|
1104
1124
|
}, z.core.$strip>;
|
|
1105
1125
|
type LayoutDocument = z.infer<typeof LayoutDocumentSchema>;
|
|
1106
1126
|
//#endregion
|
|
1107
|
-
export { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, sourcePageIndex };
|
|
1127
|
+
export { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutDocumentSurface, LayoutDocumentSurfaceSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, sourcePageIndex };
|
package/dist/layout.d.ts
CHANGED
|
@@ -784,6 +784,18 @@ interface LayoutStructureElement {
|
|
|
784
784
|
readonly actualText?: string;
|
|
785
785
|
readonly children: readonly LayoutStructureElement[];
|
|
786
786
|
}
|
|
787
|
+
/**
|
|
788
|
+
* The document-level surfaces a read can leave out (`ReadPdfOptions.surfaces`), each named by the `LayoutDocument` field it fills: `outline`, `destinations`, `form`, `layers` and `structure` are those fields, and `residue` is the package-level `source` channel. A `LayoutDocument` lists the ones its read skipped in `skippedSurfaces`.
|
|
789
|
+
*/
|
|
790
|
+
declare const LayoutDocumentSurfaceSchema: z.ZodEnum<{
|
|
791
|
+
structure: "structure";
|
|
792
|
+
destinations: "destinations";
|
|
793
|
+
outline: "outline";
|
|
794
|
+
layers: "layers";
|
|
795
|
+
form: "form";
|
|
796
|
+
residue: "residue";
|
|
797
|
+
}>;
|
|
798
|
+
type LayoutDocumentSurface = z.infer<typeof LayoutDocumentSurfaceSchema>;
|
|
787
799
|
declare const LayoutDocumentSchema: z.ZodObject<{
|
|
788
800
|
formatVersion: z.ZodLiteral<1>;
|
|
789
801
|
metadata: z.ZodObject<{
|
|
@@ -1101,7 +1113,15 @@ declare const LayoutDocumentSchema: z.ZodObject<{
|
|
|
1101
1113
|
}>;
|
|
1102
1114
|
xml: z.ZodString;
|
|
1103
1115
|
}, z.core.$strict>>>;
|
|
1116
|
+
skippedSurfaces: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
1117
|
+
structure: "structure";
|
|
1118
|
+
destinations: "destinations";
|
|
1119
|
+
outline: "outline";
|
|
1120
|
+
layers: "layers";
|
|
1121
|
+
form: "form";
|
|
1122
|
+
residue: "residue";
|
|
1123
|
+
}>>>;
|
|
1104
1124
|
}, z.core.$strip>;
|
|
1105
1125
|
type LayoutDocument = z.infer<typeof LayoutDocumentSchema>;
|
|
1106
1126
|
//#endregion
|
|
1107
|
-
export { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, sourcePageIndex };
|
|
1127
|
+
export { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutDocumentSurface, LayoutDocumentSurfaceSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, sourcePageIndex };
|
package/dist/layout.js
CHANGED
|
@@ -268,6 +268,17 @@ const LayoutStructureElementSchema = z.lazy(() => z.object({
|
|
|
268
268
|
actualText: z.string().optional(),
|
|
269
269
|
children: z.array(LayoutStructureElementSchema)
|
|
270
270
|
}));
|
|
271
|
+
/**
|
|
272
|
+
* The document-level surfaces a read can leave out (`ReadPdfOptions.surfaces`), each named by the `LayoutDocument` field it fills: `outline`, `destinations`, `form`, `layers` and `structure` are those fields, and `residue` is the package-level `source` channel. A `LayoutDocument` lists the ones its read skipped in `skippedSurfaces`.
|
|
273
|
+
*/
|
|
274
|
+
const LayoutDocumentSurfaceSchema = z.enum([
|
|
275
|
+
"outline",
|
|
276
|
+
"destinations",
|
|
277
|
+
"form",
|
|
278
|
+
"layers",
|
|
279
|
+
"structure",
|
|
280
|
+
"residue"
|
|
281
|
+
]);
|
|
271
282
|
const LayoutDocumentSchema = z.object({
|
|
272
283
|
formatVersion: z.literal(1),
|
|
273
284
|
metadata: LayoutMetadataSchema,
|
|
@@ -280,7 +291,8 @@ const LayoutDocumentSchema = z.object({
|
|
|
280
291
|
layers: z.array(LayoutLayerSchema).optional(),
|
|
281
292
|
structure: z.array(LayoutStructureElementSchema).optional(),
|
|
282
293
|
form: z.array(LayoutFormFieldSchema).optional(),
|
|
283
|
-
source: z.record(z.string(), SourceResidueSchema).optional()
|
|
294
|
+
source: z.record(z.string(), SourceResidueSchema).optional(),
|
|
295
|
+
skippedSurfaces: z.array(LayoutDocumentSurfaceSchema).min(1).optional()
|
|
284
296
|
});
|
|
285
297
|
//#endregion
|
|
286
|
-
export { LAYOUT_FORMAT_VERSION, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachmentSchema, LayoutDestinationSchema, LayoutDestinationTargetSchema, LayoutDocumentSchema, LayoutEllipseSchema, LayoutFormFieldSchema, LayoutFormWidgetSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLinkSchema, LayoutItemSchema, LayoutLayerSchema, LayoutLineSchema, LayoutLinkSchema, LayoutOutlineItemSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutStructureElementSchema, LayoutSubpathSchema, LayoutTextSchema, sourcePageIndex };
|
|
298
|
+
export { LAYOUT_FORMAT_VERSION, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachmentSchema, LayoutDestinationSchema, LayoutDestinationTargetSchema, LayoutDocumentSchema, LayoutDocumentSurfaceSchema, LayoutEllipseSchema, LayoutFormFieldSchema, LayoutFormWidgetSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLinkSchema, LayoutItemSchema, LayoutLayerSchema, LayoutLineSchema, LayoutLinkSchema, LayoutOutlineItemSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutStructureElementSchema, LayoutSubpathSchema, LayoutTextSchema, sourcePageIndex };
|
package/dist/read.cjs
CHANGED
|
@@ -12,7 +12,7 @@ const require_form = require("./form.cjs");
|
|
|
12
12
|
const require_xmp = require("./xmp.cjs");
|
|
13
13
|
const require_optional_content = require("./optional-content.cjs");
|
|
14
14
|
const require_structure = require("./structure.cjs");
|
|
15
|
-
require("./layout.cjs");
|
|
15
|
+
const require_layout = require("./layout.cjs");
|
|
16
16
|
const require_diagnostics = require("./diagnostics.cjs");
|
|
17
17
|
const require_document = require("./document.cjs");
|
|
18
18
|
const require_util_abort = require("./util/abort.cjs");
|
|
@@ -20,6 +20,13 @@ const require_font_read = require("./font-read.cjs");
|
|
|
20
20
|
const require_interpret = require("./interpret-BDVrFWhd.cjs");
|
|
21
21
|
const require_navigation = require("./navigation.cjs");
|
|
22
22
|
//#region src/read.ts
|
|
23
|
+
function skippedSurfacesOf(surfaces) {
|
|
24
|
+
return require_layout.LayoutDocumentSurfaceSchema.options.filter((surface) => surfaces?.[surface] === false);
|
|
25
|
+
}
|
|
26
|
+
const UNREAD_DESTINATION_REGISTRY = {
|
|
27
|
+
entries: [],
|
|
28
|
+
intern: () => void 0
|
|
29
|
+
};
|
|
23
30
|
function resolvePageSelection(selection, pageCount) {
|
|
24
31
|
const resolved = /* @__PURE__ */ new Set();
|
|
25
32
|
for (const requested of selection) {
|
|
@@ -55,25 +62,27 @@ function readPdf(bytes, options) {
|
|
|
55
62
|
const imageIdCache = /* @__PURE__ */ new Map();
|
|
56
63
|
const pageDicts = doc.pages();
|
|
57
64
|
const selection = options?.pages === void 0 ? void 0 : resolvePageSelection(options.pages, pageDicts.length);
|
|
58
|
-
const
|
|
59
|
-
const
|
|
65
|
+
const skippedSurfaces = skippedSurfacesOf(options?.surfaces);
|
|
66
|
+
const reads = (surface) => !skippedSurfaces.includes(surface);
|
|
67
|
+
const destinationRegistry = reads("destinations") ? require_navigation.createDestinationRegistry(doc.catalog, doc, (obj) => doc.pageIndex(obj), sink) : UNREAD_DESTINATION_REGISTRY;
|
|
68
|
+
const outline = reads("outline") ? require_navigation.readOutline(doc.catalog, destinationRegistry, doc, sink) : void 0;
|
|
60
69
|
const attachments = selection === void 0 ? require_attachments.readAttachments(doc.catalog, pageDicts, doc, sink) : [];
|
|
61
|
-
const optionalContent = require_optional_content.readOptionalContent(doc.catalog, doc, sink);
|
|
62
|
-
const form = require_form.readAcroForm(doc.catalog, doc, (obj) => doc.pageIndex(obj), sink);
|
|
63
|
-
const structure = require_structure.readStructure(doc.catalog, pageDicts, (index) => selection === void 0 || selection.has(index), doc, sink);
|
|
64
|
-
const source = readDocumentResidue(doc, sink);
|
|
70
|
+
const optionalContent = reads("layers") ? require_optional_content.readOptionalContent(doc.catalog, doc, sink) : void 0;
|
|
71
|
+
const form = reads("form") ? require_form.readAcroForm(doc.catalog, doc, (obj) => doc.pageIndex(obj), sink) : void 0;
|
|
72
|
+
const structure = reads("structure") ? require_structure.readStructure(doc.catalog, pageDicts, (index) => selection === void 0 || selection.has(index), doc, sink) : void 0;
|
|
73
|
+
const source = reads("residue") ? readDocumentResidue(doc, sink) : void 0;
|
|
65
74
|
const pageBoxRows = [];
|
|
66
75
|
const pages = pageDicts.flatMap((pageDict, index) => {
|
|
67
76
|
if (selection !== void 0 && !selection.has(index)) return [];
|
|
68
77
|
require_util_abort.throwIfAborted(signal);
|
|
69
|
-
const read = readPage(index, pageDict, doc, fontResolver, images, imageIdCache, destinationRegistry, optionalContent
|
|
78
|
+
const read = readPage(index, pageDict, doc, fontResolver, images, imageIdCache, destinationRegistry, optionalContent?.layerNameOf ?? noLayerName, structure?.ownerOf ?? noStructureOwner, sink);
|
|
70
79
|
if (read.boxRow !== void 0) pageBoxRows.push(read.boxRow);
|
|
71
80
|
return [selection === void 0 ? read.page : {
|
|
72
81
|
...read.page,
|
|
73
82
|
index
|
|
74
83
|
}];
|
|
75
84
|
});
|
|
76
|
-
if (pageBoxRows.length > 0) source["page-boxes"] = {
|
|
85
|
+
if (source !== void 0 && pageBoxRows.length > 0) source["page-boxes"] = {
|
|
77
86
|
format: "pdf",
|
|
78
87
|
xml: require_serialize.serializeObjectToText(require_objects.pdfArray(pageBoxRows))
|
|
79
88
|
};
|
|
@@ -84,14 +93,17 @@ function readPdf(bytes, options) {
|
|
|
84
93
|
...selection !== void 0 ? { pageCount: pageDicts.length } : {},
|
|
85
94
|
images,
|
|
86
95
|
...destinationRegistry.entries.length > 0 ? { destinations: [...destinationRegistry.entries] } : {},
|
|
87
|
-
...outline.length > 0 ? { outline } : {},
|
|
96
|
+
...outline !== void 0 && outline.length > 0 ? { outline } : {},
|
|
88
97
|
...attachments.length > 0 ? { attachments } : {},
|
|
89
|
-
...optionalContent.layers.length > 0 ? { layers: [...optionalContent.layers] } : {},
|
|
90
|
-
...form.length > 0 ? { form } : {},
|
|
91
|
-
...structure.tree.length > 0 ? { structure: [...structure.tree] } : {},
|
|
92
|
-
...Object.keys(source).length > 0 ? { source } : {}
|
|
98
|
+
...optionalContent !== void 0 && optionalContent.layers.length > 0 ? { layers: [...optionalContent.layers] } : {},
|
|
99
|
+
...form !== void 0 && form.length > 0 ? { form } : {},
|
|
100
|
+
...structure !== void 0 && structure.tree.length > 0 ? { structure: [...structure.tree] } : {},
|
|
101
|
+
...source !== void 0 && Object.keys(source).length > 0 ? { source } : {},
|
|
102
|
+
...skippedSurfaces.length > 0 ? { skippedSurfaces } : {}
|
|
93
103
|
};
|
|
94
104
|
}
|
|
105
|
+
function noLayerName() {}
|
|
106
|
+
function noStructureOwner() {}
|
|
95
107
|
function readDeclaredPageBox(page, key) {
|
|
96
108
|
const arr = require_objects.asArray(require_objects.dictGet(page, key));
|
|
97
109
|
if (arr === void 0) return;
|
package/dist/read.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as PdfDiagnosticSink } from "./diagnostics-BkG_Ej2x.cjs";
|
|
2
2
|
import { r as Matrix } from "./matrix-B7_SBKQ5.cjs";
|
|
3
|
-
import { LayoutDocument } from "./layout.cjs";
|
|
3
|
+
import { LayoutDocument, LayoutDocumentSurface } from "./layout.cjs";
|
|
4
4
|
//#region src/read.d.ts
|
|
5
5
|
interface ReadPdfOptions {
|
|
6
6
|
readonly sink?: PdfDiagnosticSink;
|
|
@@ -10,12 +10,31 @@ interface ReadPdfOptions {
|
|
|
10
10
|
*
|
|
11
11
|
* What a selected read skips: an unselected page's content stream is never fetched, decoded or interpreted, so the fonts and images only unselected pages use are never resolved; embedded-file payloads are never decoded, so `attachments` is absent from a page-selected result (an attachment is document-level payload whose size is independent of the pages asked for, and decoding it would cost the same whichever pages were selected).
|
|
12
12
|
*
|
|
13
|
-
* What it still reads whole, because a negative index and every document-level page reference resolve against it or because it is document-level and holds no page content stream: the page tree, the outline, named destinations, optional-content layers, the AcroForm, the structure element tree and the /ParentTree number tree (both of which scale with the document), metadata and package residue
|
|
13
|
+
* What it still reads whole, because a negative index and every document-level page reference resolve against it or because it is document-level and holds no page content stream: the page tree, the outline, named destinations, optional-content layers, the AcroForm, the structure element tree and the /ParentTree number tree (both of which scale with the document), metadata and package residue; every one of those but the page tree and metadata can be left out as well with `surfaces`. Two surfaces are built from page content and so cover selected pages only: the structure-ownership association an item's `structure` field names (and its parent-tree diagnostics), and the `page-boxes` residue row. Destinations a link states as a direct array are minted into `destinations` (as `dest1`, `dest2`, ...) only when their page is interpreted, so an unselected page's direct link destinations are absent and a minted name depends on which pages were read (and on whether the outline was read: see `surfaces`); named destinations are unaffected.
|
|
14
14
|
*
|
|
15
15
|
* Duplicates collapse, and the result's `pages` holds the selected pages in ascending document order whatever order they were asked for in, each carrying its source position as `index`, with the document's total as `pageCount`; every document-level reference keeps naming source indices. An empty array is a valid selection: it reads no page and returns the document-level surfaces with `pageCount`, the cheapest way to learn a file's length and metadata. An entry naming no page throws `PdfPageSelectionError` rather than being skipped.
|
|
16
16
|
*/
|
|
17
17
|
readonly pages?: readonly number[];
|
|
18
|
+
/**
|
|
19
|
+
* Which document-level surfaces to read. Each is read unless its entry is `false`, so omitting the setting, or an entry, reads it as before. Independent of `pages`: it applies to a full read and a page-selected read alike.
|
|
20
|
+
*
|
|
21
|
+
* A surface turned off is never parsed (its part of the catalog is not walked, so a malformed outline, form, layer list or structure tree reports no diagnostic) and its field is absent from the result whatever the file holds; the result lists it in `skippedSurfaces`, which is how a caller tells "not read" from "none". What each one covers, and what page items lose without it:
|
|
22
|
+
*
|
|
23
|
+
* - `outline`: the `/Outlines` bookmark tree (`outline`). Page items do not depend on it, except through minted names: a destination stated as a direct array is named with the first unused `destN` in the order the reader meets it, and the outline is read before any page, so an outline entry's direct destination takes a lower number than any link's. Without the outline, the names minted for page links' direct destinations are renumbered, and `destinations` loses the entries only the outline minted; each link still resolves to the same target.
|
|
24
|
+
* - `destinations`: the named destinations of the catalog `/Dests` dictionary and the `/Names /Dests` name tree, and the registry links and outline entries name their targets through (`destinations`). Without it nothing can name an internal target, so a link whose target is internal (a `/Dest`, or a `/GoTo` action, named or direct) is left out of its page's items, and a read outline entry carries no `destination`; a link to a URI is kept as usual.
|
|
25
|
+
* - `form`: the AcroForm field tree (`form`). Page items do not depend on it: a widget annotation is never a page item or annotation either way.
|
|
26
|
+
* - `layers`: optional content, the `/OCProperties` groups and their default visibility (`layers`). Without it no item carries a `layer`, since an `/OC` membership resolves to no name; the items themselves are all still read, so content the default view hides is indistinguishable from visible content.
|
|
27
|
+
* - `structure`: the `/StructTreeRoot` element tree and its `/ParentTree` ownership map (`structure`). Without it no item carries a `structure` owner, and the parent-tree diagnostics are not reported.
|
|
28
|
+
* - `residue`: the package-level residue rows (`source`), including the per-page `page-boxes` row. Page items do not depend on it; `metadata` still reads the XMP packet it falls back to.
|
|
29
|
+
*
|
|
30
|
+
* Apart from those stated losses and the renumbering a skipped outline causes, every page item is exactly what a read with the surface on produces.
|
|
31
|
+
*/
|
|
32
|
+
readonly surfaces?: ReadPdfSurfaces;
|
|
18
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* One entry per document-level surface `readPdf` can leave out, each read unless set to `false` (see `ReadPdfOptions.surfaces` for what each covers and what page items lose without it).
|
|
36
|
+
*/
|
|
37
|
+
type ReadPdfSurfaces = Readonly<Partial<Record<LayoutDocumentSurface, boolean>>>;
|
|
19
38
|
declare function readPdf(bytes: Uint8Array<ArrayBuffer>, options?: ReadPdfOptions): LayoutDocument;
|
|
20
39
|
type PageRotation = 0 | 90 | 180 | 270;
|
|
21
40
|
declare function normalizeRotation(rotate: number | undefined): PageRotation;
|
|
@@ -26,4 +45,4 @@ interface PageRotationResult {
|
|
|
26
45
|
}
|
|
27
46
|
declare function pageRotationTransform(rotation: PageRotation, w: number, h: number): PageRotationResult;
|
|
28
47
|
//#endregion
|
|
29
|
-
export { ReadPdfOptions, normalizeRotation, pageRotationTransform, readPdf };
|
|
48
|
+
export { ReadPdfOptions, ReadPdfSurfaces, normalizeRotation, pageRotationTransform, readPdf };
|
package/dist/read.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as PdfDiagnosticSink } from "./diagnostics-BkG_Ej2x.js";
|
|
2
2
|
import { r as Matrix } from "./matrix-B7_SBKQ5.js";
|
|
3
|
-
import { LayoutDocument } from "./layout.js";
|
|
3
|
+
import { LayoutDocument, LayoutDocumentSurface } from "./layout.js";
|
|
4
4
|
//#region src/read.d.ts
|
|
5
5
|
interface ReadPdfOptions {
|
|
6
6
|
readonly sink?: PdfDiagnosticSink;
|
|
@@ -10,12 +10,31 @@ interface ReadPdfOptions {
|
|
|
10
10
|
*
|
|
11
11
|
* What a selected read skips: an unselected page's content stream is never fetched, decoded or interpreted, so the fonts and images only unselected pages use are never resolved; embedded-file payloads are never decoded, so `attachments` is absent from a page-selected result (an attachment is document-level payload whose size is independent of the pages asked for, and decoding it would cost the same whichever pages were selected).
|
|
12
12
|
*
|
|
13
|
-
* What it still reads whole, because a negative index and every document-level page reference resolve against it or because it is document-level and holds no page content stream: the page tree, the outline, named destinations, optional-content layers, the AcroForm, the structure element tree and the /ParentTree number tree (both of which scale with the document), metadata and package residue
|
|
13
|
+
* What it still reads whole, because a negative index and every document-level page reference resolve against it or because it is document-level and holds no page content stream: the page tree, the outline, named destinations, optional-content layers, the AcroForm, the structure element tree and the /ParentTree number tree (both of which scale with the document), metadata and package residue; every one of those but the page tree and metadata can be left out as well with `surfaces`. Two surfaces are built from page content and so cover selected pages only: the structure-ownership association an item's `structure` field names (and its parent-tree diagnostics), and the `page-boxes` residue row. Destinations a link states as a direct array are minted into `destinations` (as `dest1`, `dest2`, ...) only when their page is interpreted, so an unselected page's direct link destinations are absent and a minted name depends on which pages were read (and on whether the outline was read: see `surfaces`); named destinations are unaffected.
|
|
14
14
|
*
|
|
15
15
|
* Duplicates collapse, and the result's `pages` holds the selected pages in ascending document order whatever order they were asked for in, each carrying its source position as `index`, with the document's total as `pageCount`; every document-level reference keeps naming source indices. An empty array is a valid selection: it reads no page and returns the document-level surfaces with `pageCount`, the cheapest way to learn a file's length and metadata. An entry naming no page throws `PdfPageSelectionError` rather than being skipped.
|
|
16
16
|
*/
|
|
17
17
|
readonly pages?: readonly number[];
|
|
18
|
+
/**
|
|
19
|
+
* Which document-level surfaces to read. Each is read unless its entry is `false`, so omitting the setting, or an entry, reads it as before. Independent of `pages`: it applies to a full read and a page-selected read alike.
|
|
20
|
+
*
|
|
21
|
+
* A surface turned off is never parsed (its part of the catalog is not walked, so a malformed outline, form, layer list or structure tree reports no diagnostic) and its field is absent from the result whatever the file holds; the result lists it in `skippedSurfaces`, which is how a caller tells "not read" from "none". What each one covers, and what page items lose without it:
|
|
22
|
+
*
|
|
23
|
+
* - `outline`: the `/Outlines` bookmark tree (`outline`). Page items do not depend on it, except through minted names: a destination stated as a direct array is named with the first unused `destN` in the order the reader meets it, and the outline is read before any page, so an outline entry's direct destination takes a lower number than any link's. Without the outline, the names minted for page links' direct destinations are renumbered, and `destinations` loses the entries only the outline minted; each link still resolves to the same target.
|
|
24
|
+
* - `destinations`: the named destinations of the catalog `/Dests` dictionary and the `/Names /Dests` name tree, and the registry links and outline entries name their targets through (`destinations`). Without it nothing can name an internal target, so a link whose target is internal (a `/Dest`, or a `/GoTo` action, named or direct) is left out of its page's items, and a read outline entry carries no `destination`; a link to a URI is kept as usual.
|
|
25
|
+
* - `form`: the AcroForm field tree (`form`). Page items do not depend on it: a widget annotation is never a page item or annotation either way.
|
|
26
|
+
* - `layers`: optional content, the `/OCProperties` groups and their default visibility (`layers`). Without it no item carries a `layer`, since an `/OC` membership resolves to no name; the items themselves are all still read, so content the default view hides is indistinguishable from visible content.
|
|
27
|
+
* - `structure`: the `/StructTreeRoot` element tree and its `/ParentTree` ownership map (`structure`). Without it no item carries a `structure` owner, and the parent-tree diagnostics are not reported.
|
|
28
|
+
* - `residue`: the package-level residue rows (`source`), including the per-page `page-boxes` row. Page items do not depend on it; `metadata` still reads the XMP packet it falls back to.
|
|
29
|
+
*
|
|
30
|
+
* Apart from those stated losses and the renumbering a skipped outline causes, every page item is exactly what a read with the surface on produces.
|
|
31
|
+
*/
|
|
32
|
+
readonly surfaces?: ReadPdfSurfaces;
|
|
18
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* One entry per document-level surface `readPdf` can leave out, each read unless set to `false` (see `ReadPdfOptions.surfaces` for what each covers and what page items lose without it).
|
|
36
|
+
*/
|
|
37
|
+
type ReadPdfSurfaces = Readonly<Partial<Record<LayoutDocumentSurface, boolean>>>;
|
|
19
38
|
declare function readPdf(bytes: Uint8Array<ArrayBuffer>, options?: ReadPdfOptions): LayoutDocument;
|
|
20
39
|
type PageRotation = 0 | 90 | 180 | 270;
|
|
21
40
|
declare function normalizeRotation(rotate: number | undefined): PageRotation;
|
|
@@ -26,4 +45,4 @@ interface PageRotationResult {
|
|
|
26
45
|
}
|
|
27
46
|
declare function pageRotationTransform(rotation: PageRotation, w: number, h: number): PageRotationResult;
|
|
28
47
|
//#endregion
|
|
29
|
-
export { ReadPdfOptions, normalizeRotation, pageRotationTransform, readPdf };
|
|
48
|
+
export { ReadPdfOptions, ReadPdfSurfaces, normalizeRotation, pageRotationTransform, readPdf };
|
package/dist/read.js
CHANGED
|
@@ -11,7 +11,7 @@ import { readAcroForm } from "./form.js";
|
|
|
11
11
|
import { readXmpMetadata } from "./xmp.js";
|
|
12
12
|
import { readOptionalContent } from "./optional-content.js";
|
|
13
13
|
import { readStructure } from "./structure.js";
|
|
14
|
-
import "./layout.js";
|
|
14
|
+
import { LayoutDocumentSurfaceSchema } from "./layout.js";
|
|
15
15
|
import { NOOP_DIAGNOSTIC_SINK, PdfPageSelectionError, PdfParseError } from "./diagnostics.js";
|
|
16
16
|
import { openPdfDocument } from "./document.js";
|
|
17
17
|
import { throwIfAborted } from "./util/abort.js";
|
|
@@ -19,6 +19,13 @@ import { createFontResolver } from "./font-read.js";
|
|
|
19
19
|
import { t as interpretContentStream } from "./interpret---0lZPlv.js";
|
|
20
20
|
import { createDestinationRegistry, readOutline } from "./navigation.js";
|
|
21
21
|
//#region src/read.ts
|
|
22
|
+
function skippedSurfacesOf(surfaces) {
|
|
23
|
+
return LayoutDocumentSurfaceSchema.options.filter((surface) => surfaces?.[surface] === false);
|
|
24
|
+
}
|
|
25
|
+
const UNREAD_DESTINATION_REGISTRY = {
|
|
26
|
+
entries: [],
|
|
27
|
+
intern: () => void 0
|
|
28
|
+
};
|
|
22
29
|
function resolvePageSelection(selection, pageCount) {
|
|
23
30
|
const resolved = /* @__PURE__ */ new Set();
|
|
24
31
|
for (const requested of selection) {
|
|
@@ -54,25 +61,27 @@ function readPdf(bytes, options) {
|
|
|
54
61
|
const imageIdCache = /* @__PURE__ */ new Map();
|
|
55
62
|
const pageDicts = doc.pages();
|
|
56
63
|
const selection = options?.pages === void 0 ? void 0 : resolvePageSelection(options.pages, pageDicts.length);
|
|
57
|
-
const
|
|
58
|
-
const
|
|
64
|
+
const skippedSurfaces = skippedSurfacesOf(options?.surfaces);
|
|
65
|
+
const reads = (surface) => !skippedSurfaces.includes(surface);
|
|
66
|
+
const destinationRegistry = reads("destinations") ? createDestinationRegistry(doc.catalog, doc, (obj) => doc.pageIndex(obj), sink) : UNREAD_DESTINATION_REGISTRY;
|
|
67
|
+
const outline = reads("outline") ? readOutline(doc.catalog, destinationRegistry, doc, sink) : void 0;
|
|
59
68
|
const attachments = selection === void 0 ? readAttachments(doc.catalog, pageDicts, doc, sink) : [];
|
|
60
|
-
const optionalContent = readOptionalContent(doc.catalog, doc, sink);
|
|
61
|
-
const form = readAcroForm(doc.catalog, doc, (obj) => doc.pageIndex(obj), sink);
|
|
62
|
-
const structure = readStructure(doc.catalog, pageDicts, (index) => selection === void 0 || selection.has(index), doc, sink);
|
|
63
|
-
const source = readDocumentResidue(doc, sink);
|
|
69
|
+
const optionalContent = reads("layers") ? readOptionalContent(doc.catalog, doc, sink) : void 0;
|
|
70
|
+
const form = reads("form") ? readAcroForm(doc.catalog, doc, (obj) => doc.pageIndex(obj), sink) : void 0;
|
|
71
|
+
const structure = reads("structure") ? readStructure(doc.catalog, pageDicts, (index) => selection === void 0 || selection.has(index), doc, sink) : void 0;
|
|
72
|
+
const source = reads("residue") ? readDocumentResidue(doc, sink) : void 0;
|
|
64
73
|
const pageBoxRows = [];
|
|
65
74
|
const pages = pageDicts.flatMap((pageDict, index) => {
|
|
66
75
|
if (selection !== void 0 && !selection.has(index)) return [];
|
|
67
76
|
throwIfAborted(signal);
|
|
68
|
-
const read = readPage(index, pageDict, doc, fontResolver, images, imageIdCache, destinationRegistry, optionalContent
|
|
77
|
+
const read = readPage(index, pageDict, doc, fontResolver, images, imageIdCache, destinationRegistry, optionalContent?.layerNameOf ?? noLayerName, structure?.ownerOf ?? noStructureOwner, sink);
|
|
69
78
|
if (read.boxRow !== void 0) pageBoxRows.push(read.boxRow);
|
|
70
79
|
return [selection === void 0 ? read.page : {
|
|
71
80
|
...read.page,
|
|
72
81
|
index
|
|
73
82
|
}];
|
|
74
83
|
});
|
|
75
|
-
if (pageBoxRows.length > 0) source["page-boxes"] = {
|
|
84
|
+
if (source !== void 0 && pageBoxRows.length > 0) source["page-boxes"] = {
|
|
76
85
|
format: "pdf",
|
|
77
86
|
xml: serializeObjectToText(pdfArray(pageBoxRows))
|
|
78
87
|
};
|
|
@@ -83,14 +92,17 @@ function readPdf(bytes, options) {
|
|
|
83
92
|
...selection !== void 0 ? { pageCount: pageDicts.length } : {},
|
|
84
93
|
images,
|
|
85
94
|
...destinationRegistry.entries.length > 0 ? { destinations: [...destinationRegistry.entries] } : {},
|
|
86
|
-
...outline.length > 0 ? { outline } : {},
|
|
95
|
+
...outline !== void 0 && outline.length > 0 ? { outline } : {},
|
|
87
96
|
...attachments.length > 0 ? { attachments } : {},
|
|
88
|
-
...optionalContent.layers.length > 0 ? { layers: [...optionalContent.layers] } : {},
|
|
89
|
-
...form.length > 0 ? { form } : {},
|
|
90
|
-
...structure.tree.length > 0 ? { structure: [...structure.tree] } : {},
|
|
91
|
-
...Object.keys(source).length > 0 ? { source } : {}
|
|
97
|
+
...optionalContent !== void 0 && optionalContent.layers.length > 0 ? { layers: [...optionalContent.layers] } : {},
|
|
98
|
+
...form !== void 0 && form.length > 0 ? { form } : {},
|
|
99
|
+
...structure !== void 0 && structure.tree.length > 0 ? { structure: [...structure.tree] } : {},
|
|
100
|
+
...source !== void 0 && Object.keys(source).length > 0 ? { source } : {},
|
|
101
|
+
...skippedSurfaces.length > 0 ? { skippedSurfaces } : {}
|
|
92
102
|
};
|
|
93
103
|
}
|
|
104
|
+
function noLayerName() {}
|
|
105
|
+
function noStructureOwner() {}
|
|
94
106
|
function readDeclaredPageBox(page, key) {
|
|
95
107
|
const arr = asArray(dictGet(page, key));
|
|
96
108
|
if (arr === void 0) return;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/write-skipped-surfaces.ts
|
|
3
|
+
/**
|
|
4
|
+
* writePdf was handed a LayoutDocument from a read that left document-level surfaces out (one carrying `skippedSurfaces`, which only `ReadPdfOptions.surfaces` sets). Such a document is a reading with parts of the file deliberately unread, not a document to re-emit: each skipped surface's field is absent whatever the source holds, and its page items lack what depended on it (internal links without destinations, structure owners without the structure tree, layer names without layers), so writing it would silently drop the source's outline, form, layers, structure or residue. Thrown rather than writing a file that looks complete. Checked after `PdfPartialDocumentError`, so a page-selected read that also skipped surfaces reports the page selection.
|
|
5
|
+
*/
|
|
6
|
+
var PdfSkippedSurfacesError = class extends Error {
|
|
7
|
+
/** The surfaces the read skipped, as the document's `skippedSurfaces` lists them. */
|
|
8
|
+
skippedSurfaces;
|
|
9
|
+
constructor(skippedSurfaces) {
|
|
10
|
+
super(`this LayoutDocument was read with ${skippedSurfaces.join(", ")} left out (it carries skippedSurfaces, which only a read with ReadPdfOptions.surfaces sets); writing it would drop whatever the source holds there, so it cannot be written as a document of its own`);
|
|
11
|
+
this.name = "PdfSkippedSurfacesError";
|
|
12
|
+
this.skippedSurfaces = skippedSurfaces;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.PdfSkippedSurfacesError = PdfSkippedSurfacesError;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LayoutDocumentSurface } from "./layout.cjs";
|
|
2
|
+
//#region src/write-skipped-surfaces.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* writePdf was handed a LayoutDocument from a read that left document-level surfaces out (one carrying `skippedSurfaces`, which only `ReadPdfOptions.surfaces` sets). Such a document is a reading with parts of the file deliberately unread, not a document to re-emit: each skipped surface's field is absent whatever the source holds, and its page items lack what depended on it (internal links without destinations, structure owners without the structure tree, layer names without layers), so writing it would silently drop the source's outline, form, layers, structure or residue. Thrown rather than writing a file that looks complete. Checked after `PdfPartialDocumentError`, so a page-selected read that also skipped surfaces reports the page selection.
|
|
5
|
+
*/
|
|
6
|
+
declare class PdfSkippedSurfacesError extends Error {
|
|
7
|
+
/** The surfaces the read skipped, as the document's `skippedSurfaces` lists them. */
|
|
8
|
+
readonly skippedSurfaces: readonly LayoutDocumentSurface[];
|
|
9
|
+
constructor(skippedSurfaces: readonly LayoutDocumentSurface[]);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { PdfSkippedSurfacesError };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LayoutDocumentSurface } from "./layout.js";
|
|
2
|
+
//#region src/write-skipped-surfaces.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* writePdf was handed a LayoutDocument from a read that left document-level surfaces out (one carrying `skippedSurfaces`, which only `ReadPdfOptions.surfaces` sets). Such a document is a reading with parts of the file deliberately unread, not a document to re-emit: each skipped surface's field is absent whatever the source holds, and its page items lack what depended on it (internal links without destinations, structure owners without the structure tree, layer names without layers), so writing it would silently drop the source's outline, form, layers, structure or residue. Thrown rather than writing a file that looks complete. Checked after `PdfPartialDocumentError`, so a page-selected read that also skipped surfaces reports the page selection.
|
|
5
|
+
*/
|
|
6
|
+
declare class PdfSkippedSurfacesError extends Error {
|
|
7
|
+
/** The surfaces the read skipped, as the document's `skippedSurfaces` lists them. */
|
|
8
|
+
readonly skippedSurfaces: readonly LayoutDocumentSurface[];
|
|
9
|
+
constructor(skippedSurfaces: readonly LayoutDocumentSurface[]);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { PdfSkippedSurfacesError };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/write-skipped-surfaces.ts
|
|
2
|
+
/**
|
|
3
|
+
* writePdf was handed a LayoutDocument from a read that left document-level surfaces out (one carrying `skippedSurfaces`, which only `ReadPdfOptions.surfaces` sets). Such a document is a reading with parts of the file deliberately unread, not a document to re-emit: each skipped surface's field is absent whatever the source holds, and its page items lack what depended on it (internal links without destinations, structure owners without the structure tree, layer names without layers), so writing it would silently drop the source's outline, form, layers, structure or residue. Thrown rather than writing a file that looks complete. Checked after `PdfPartialDocumentError`, so a page-selected read that also skipped surfaces reports the page selection.
|
|
4
|
+
*/
|
|
5
|
+
var PdfSkippedSurfacesError = class extends Error {
|
|
6
|
+
/** The surfaces the read skipped, as the document's `skippedSurfaces` lists them. */
|
|
7
|
+
skippedSurfaces;
|
|
8
|
+
constructor(skippedSurfaces) {
|
|
9
|
+
super(`this LayoutDocument was read with ${skippedSurfaces.join(", ")} left out (it carries skippedSurfaces, which only a read with ReadPdfOptions.surfaces sets); writing it would drop whatever the source holds there, so it cannot be written as a document of its own`);
|
|
10
|
+
this.name = "PdfSkippedSurfacesError";
|
|
11
|
+
this.skippedSurfaces = skippedSurfaces;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { PdfSkippedSurfacesError };
|
package/dist/write.cjs
CHANGED
|
@@ -15,6 +15,7 @@ const require_font_registry = require("./font-registry.cjs");
|
|
|
15
15
|
const require_measure = require("./measure.cjs");
|
|
16
16
|
const require_write_page_emit = require("./write-page-emit.cjs");
|
|
17
17
|
const require_write_outline = require("./write-outline.cjs");
|
|
18
|
+
const require_write_skipped_surfaces = require("./write-skipped-surfaces.cjs");
|
|
18
19
|
let byte_codec = require("byte-codec");
|
|
19
20
|
//#region src/write.ts
|
|
20
21
|
const MATH_FONT_RESOURCE_NAME = "MF";
|
|
@@ -84,6 +85,7 @@ var PdfPartialDocumentError = class extends Error {
|
|
|
84
85
|
};
|
|
85
86
|
function writePdf(doc, options = {}) {
|
|
86
87
|
if (doc.pageCount !== void 0) throw new PdfPartialDocumentError(doc.pageCount, doc.pages.length);
|
|
88
|
+
if (doc.skippedSurfaces !== void 0) throw new require_write_skipped_surfaces.PdfSkippedSurfacesError(doc.skippedSurfaces);
|
|
87
89
|
const compress = options.compress ?? true;
|
|
88
90
|
const registry = options.fonts;
|
|
89
91
|
const measurer = require_measure.createFontMeasurer(registry);
|
package/dist/write.js
CHANGED
|
@@ -14,6 +14,7 @@ import { resolveFaceWithRegistry } from "./font-registry.js";
|
|
|
14
14
|
import { createFontMeasurer } from "./measure.js";
|
|
15
15
|
import { emitPageObjects } from "./write-page-emit.js";
|
|
16
16
|
import { emitOutlineObjects } from "./write-outline.js";
|
|
17
|
+
import { PdfSkippedSurfacesError } from "./write-skipped-surfaces.js";
|
|
17
18
|
import { base64ToBytes } from "byte-codec";
|
|
18
19
|
//#region src/write.ts
|
|
19
20
|
const MATH_FONT_RESOURCE_NAME = "MF";
|
|
@@ -83,6 +84,7 @@ var PdfPartialDocumentError = class extends Error {
|
|
|
83
84
|
};
|
|
84
85
|
function writePdf(doc, options = {}) {
|
|
85
86
|
if (doc.pageCount !== void 0) throw new PdfPartialDocumentError(doc.pageCount, doc.pages.length);
|
|
87
|
+
if (doc.skippedSurfaces !== void 0) throw new PdfSkippedSurfacesError(doc.skippedSurfaces);
|
|
86
88
|
const compress = options.compress ?? true;
|
|
87
89
|
const registry = options.fonts;
|
|
88
90
|
const measurer = createFontMeasurer(registry);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdf-codec",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.1",
|
|
4
4
|
"description": "Hand-written, dependency-minimal PDF codec: parses arbitrary real-world PDFs and generates new ones, built on its own codec-owned LayoutDocument item model and Zod 4 codecs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"packageManager": "pnpm@12.4.1+sha512.2e81e399d73fe8390dab25e06aa788ab7a5908248d2f5a370f82b481147a6a7a367bf8048f9a6fdb6460f21a66f0542dedb8b94ca2c8723596741920b1656d4c",
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"byte-codec": "2.0.2",
|
|
103
|
-
"document-schema.js": "7.16.
|
|
103
|
+
"document-schema.js": "7.16.2",
|
|
104
104
|
"fflate": "0.8.3",
|
|
105
105
|
"zod": "4.4.3"
|
|
106
106
|
},
|