pdf-codec 1.11.11 → 2.0.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 CHANGED
@@ -17,6 +17,7 @@ graph TD
17
17
  odf("odf.js")
18
18
  pdfcodec("pdf-codec")
19
19
  mdcodec("markdown-codec")
20
+ bytecodec("byte-codec")
20
21
  documents("documents.js")
21
22
  mcp("document-mcp")
22
23
  cli("document-cli")
@@ -30,6 +31,8 @@ graph TD
30
31
  odf --> documents
31
32
  pdfcodec --> documents
32
33
  mdcodec --> documents
34
+ bytecodec --> pdfcodec
35
+ bytecodec --> documents
33
36
  documents --> mcp
34
37
  pdfcodec --> mcp
35
38
  documents --> cli
@@ -41,6 +44,7 @@ graph TD
41
44
  click odf "https://github.com/ExaDev/odf.js" "odf.js"
42
45
  click pdfcodec "https://github.com/ExaDev/pdf-codec" "pdf-codec"
43
46
  click mdcodec "https://github.com/ExaDev/markdown-codec" "markdown-codec"
47
+ click bytecodec "https://github.com/ExaDev/byte-codec" "byte-codec"
44
48
  click documents "https://github.com/ExaDev/documents.js" "documents.js"
45
49
  click mcp "https://github.com/ExaDev/document-mcp" "document-mcp"
46
50
  click cli "https://github.com/ExaDev/document-cli" "document-cli"
@@ -125,20 +129,19 @@ The one thing a glyph ID cannot carry is meaning: an unencoded glyph gets no ToU
125
129
 
126
130
  `MathFontMetrics.stretch` is the layout-facing form of all this, and the one a layout engine actually calls: it resolves a construction at a target size and additionally **measures** it — `inkAscentPt`/`inkDescentPt` are the whole construction's real ink extent about its drawing origin, taken from actual glyph outlines. Without that a caller cannot place the result, since a construction's ink neither starts at its drawing origin (a large parenthesis variant straddles the baseline) nor is bounded by its advance-derived `size`.
127
131
 
128
- Building a layout engine on top of this codec (this is what `documents.js`'s own `src/layout/` does for docx/pptx/odt/odp/ods/odg): `TextMeasurer`/`createStandardFontMeasurer` and `wrapRunsToWidth` answer "how wide does this text render, and where does this line break" against the standard-14 metrics; `resolveStandardFont`/`STANDARD_METRICS` map an arbitrary requested family/weight/style onto one of the 14 standard PDF faces and that face's own AFM-derived metrics; `rotatePointAboutCenter` handles shape-rotation placement math. None of these do any PDF I/O themselves they're the same primitives `writePdf`/`readPdf` use internally, exported so a caller assembling its own `LayoutDocument` (from any source format) can measure and wrap text identically to how this package will actually render it.
132
+ Building a layout engine on top of this codec (this is what `documents.js`'s own `src/layout/` does for docx/pptx/odt/odp/ods/odg): `TextMeasurer`/`createStandardFontMeasurer` answer "how wide does this text render, and where does this line break" against the standard-14 metrics; `resolveStandardFont`/`STANDARD_METRICS` map an arbitrary requested family/weight/style onto one of the 14 standard PDF faces and that face's own AFM-derived metrics. The text-wrapping primitive (`wrapRunsToWidth`) and the shape-rotation geometry (`rotatePointAboutCenter`) a layout engine also needs now live in documents.js itself (they had no internal pdf-codec caller), so they are no longer exported here; the port types they consume (`TextMeasurer`, `StyledRun`, `WrappedLine`, `ProvidedFont`, the `MathBox`/`MathFontMetrics` family) live in `document-schema.js`, the neutral shared-schema package, so a layout engine never reaches into this backend for its contracts.
129
133
 
130
134
  Embedding real fonts instead of substituting standard-14 faces, via a `FontRegistry` (see `src/font-registry.ts` for the full source-document → caller-supplied → vendored-substitute → standard-14 resolution order). Pass the same registry to both the measurer and `writePdf`, so what was measured and what gets drawn come from one font:
131
135
 
132
136
  ```ts
133
- import { createFontMeasurer, createFontRegistry, wrapRunsToWidth, writePdf } from 'pdf-codec';
137
+ import { createFontMeasurer, createFontRegistry, writePdf } from 'pdf-codec';
134
138
 
135
139
  // With no `fonts`/`sourceFonts` of its own, the registry still maps Calibri onto the vendored,
136
140
  // metric-compatible Carlito face this package embeds (and Cambria onto Caladea).
137
141
  const fonts = createFontRegistry();
138
142
 
139
143
  const measurer = createFontMeasurer(fonts);
140
- const lines = wrapRunsToWidth(runs, measurer, columnWidthPt);
141
- // ... build a LayoutDocument from `lines` ...
144
+ // ... wrap text + build a LayoutDocument using the measurer (documents.js owns wrapRunsToWidth) ...
142
145
  const pdfBytes = writePdf(doc, { fonts, onMissingGlyph: (m) => console.warn('no glyph for', m.from) });
143
146
  ```
144
147
 
@@ -169,7 +172,7 @@ const image = decodeJpeg2000(jp2OrCodestreamBytes); // -> { width, height, bitDe
169
172
 
170
173
  Both accept a whole JP2 file or a bare codestream; `decodeJpeg2000` takes an optional `onWarning` for the recoverable cases (a truncated codestream decodes to whatever packets did arrive) and throws `Jpeg2000UnsupportedError` naming the feature for anything outside [JPEG 2000 scope](#jpeg-2000-scope). Inside a PDF none of this needs calling: `readPdf` decodes a `/JPXDecode` image XObject through the same path automatically.
171
174
 
172
- The full `src/bytes/`/`src/image/` surface is exported too — `crc32`, `deflate`/`inflate`/`inflateTolerant`, `ByteReader`/`ByteWriter`/`concatBytes`, `readJpegInfo`, `decodePng`/`encodePng`, `unfilterScanlines`/`filterScanlines`, `decodeCcittFax`, `decodeJbig2Embedded`, `decodeJpeg2000`/`readJpeg2000Metadata`/`parseJp2Container` generic byte- and image-container primitives with zero PDF-specific knowledge of their own, useful independently of anything PDF-related.
175
+ The generic byte- and image-container primitives (`crc32`, `deflate`/`inflate`/`inflateTolerant`, `ByteReader`/`ByteWriter`/`concatBytes`, `readJpegInfo`, `decodePng`/`encodePng`, `unfilterScanlines`/`filterScanlines`) are re-exported from [byte-codec](https://github.com/ExaDev/byte-codec), the neutral shared package both pdf-codec and documents.js consume — pdf-codec keeps its own internal copies (its read/write/interpret paths use them) but its public barrel delegates to byte-codec. The PDF-specific image codecs (`decodeCcittFax`, `decodeJbig2Embedded`, `decodeJpeg2000`/`readJpeg2000Metadata`/`parseJp2Container`) stay here they are genuine PDF-format concerns.
173
176
 
174
177
  Every module under `src/` is also deep-importable directly by its own subpath, for a caller that wants one internal module (not part of the curated barrel above) without pulling in the rest:
175
178
 
package/dist/codec.d.cts CHANGED
@@ -24,12 +24,12 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
24
24
  font: z.ZodObject<{
25
25
  family: z.ZodString;
26
26
  weight: z.ZodEnum<{
27
- normal: "normal";
28
27
  bold: "bold";
28
+ normal: "normal";
29
29
  }>;
30
30
  style: z.ZodEnum<{
31
- normal: "normal";
32
31
  italic: "italic";
32
+ normal: "normal";
33
33
  }>;
34
34
  }, z.core.$strip>;
35
35
  sizePt: z.ZodNumber;
package/dist/codec.d.ts CHANGED
@@ -24,12 +24,12 @@ declare const pdfCodec: z.ZodCodec<z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Arr
24
24
  font: z.ZodObject<{
25
25
  family: z.ZodString;
26
26
  weight: z.ZodEnum<{
27
- normal: "normal";
28
27
  bold: "bold";
28
+ normal: "normal";
29
29
  }>;
30
30
  style: z.ZodEnum<{
31
- normal: "normal";
32
31
  italic: "italic";
32
+ normal: "normal";
33
33
  }>;
34
34
  }, z.core.$strip>;
35
35
  sizePt: z.ZodNumber;
package/dist/index.cjs CHANGED
@@ -1,22 +1,14 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_afm_widths = require("./afm-widths-BoeTOK2r.cjs");
3
- const require_bytes_reader = require("./bytes/reader.cjs");
4
- const require_bytes_crc32 = require("./bytes/crc32.cjs");
5
- const require_bytes_writer = require("./bytes/writer.cjs");
6
3
  const require_diagnostics = require("./diagnostics.cjs");
7
- const require_bytes_flate = require("./bytes/flate.cjs");
8
4
  const require_image_ccitt = require("./image/ccitt.cjs");
9
5
  const require_image_jbig2_errors = require("./image/jbig2-errors.cjs");
10
6
  const require_image_jbig2 = require("./image/jbig2.cjs");
11
7
  const require_image_png_filter = require("./image/png-filter.cjs");
12
8
  const require_fonts = require("./fonts.cjs");
13
- const require_image_png_encode = require("./image/png-encode.cjs");
14
- const require_image_jpeg_info = require("./image/jpeg-info.cjs");
15
9
  const require_image_jpeg2000_errors = require("./image/jpeg2000-errors.cjs");
16
10
  const require_image_jp2_boxes = require("./image/jp2-boxes.cjs");
17
11
  const require_image_jpeg2000 = require("./image/jpeg2000.cjs");
18
- const require_matrix = require("./matrix.cjs");
19
- const require_image_png_decode = require("./image/png-decode.cjs");
20
12
  const require_font_registry = require("./font-registry.cjs");
21
13
  const require_math_stretch = require("./math-stretch.cjs");
22
14
  const require_math_font = require("./math-font.cjs");
@@ -25,16 +17,12 @@ const require_write = require("./write.cjs");
25
17
  const require_read = require("./read.cjs");
26
18
  const require_codec = require("./codec.cjs");
27
19
  const require_font_face = require("./font-face.cjs");
28
- const require_text_layout = require("./text-layout.cjs");
29
- exports.ByteReader = require_bytes_reader.ByteReader;
30
- exports.ByteWriter = require_bytes_writer.ByteWriter;
31
20
  exports.DEFAULT_VERTICAL_METRIC_POLICY = require_measure.DEFAULT_VERTICAL_METRIC_POLICY;
32
21
  exports.FontFaceParseError = require_font_face.FontFaceParseError;
33
22
  exports.Jbig2ParseError = require_image_jbig2_errors.Jbig2ParseError;
34
23
  exports.Jbig2UnsupportedError = require_image_jbig2_errors.Jbig2UnsupportedError;
35
24
  exports.Jpeg2000ParseError = require_image_jpeg2000_errors.Jpeg2000ParseError;
36
25
  exports.Jpeg2000UnsupportedError = require_image_jpeg2000_errors.Jpeg2000UnsupportedError;
37
- exports.MAX_INFLATE_OUTPUT_BYTES = require_bytes_flate.MAX_INFLATE_OUTPUT_BYTES;
38
26
  exports.NOOP_DIAGNOSTIC_SINK = require_diagnostics.NOOP_DIAGNOSTIC_SINK;
39
27
  exports.PdfBytesSchema = require_codec.PdfBytesSchema;
40
28
  exports.PdfEncryptedError = require_diagnostics.PdfEncryptedError;
@@ -42,33 +30,31 @@ exports.PdfParseError = require_diagnostics.PdfParseError;
42
30
  exports.PdfPasswordRequiredError = require_diagnostics.PdfPasswordRequiredError;
43
31
  exports.STANDARD_METRICS = require_afm_widths.STANDARD_METRICS;
44
32
  exports.assembleStretchyGlyph = require_math_stretch.assembleStretchyGlyph;
45
- exports.concatBytes = require_bytes_writer.concatBytes;
46
- exports.crc32 = require_bytes_crc32.crc32;
47
33
  exports.createFontMeasurer = require_measure.createFontMeasurer;
48
34
  exports.createFontRegistry = require_font_registry.createFontRegistry;
49
35
  exports.createStandardFontMeasurer = require_measure.createStandardFontMeasurer;
50
36
  exports.decodeCcittFax = require_image_ccitt.decodeCcittFax;
51
37
  exports.decodeJbig2Embedded = require_image_jbig2.decodeJbig2Embedded;
52
38
  exports.decodeJpeg2000 = require_image_jpeg2000.decodeJpeg2000;
53
- exports.decodePng = require_image_png_decode.decodePng;
54
- exports.deflate = require_bytes_flate.deflate;
55
- exports.encodePng = require_image_png_encode.encodePng;
56
39
  exports.filterScanlines = require_image_png_filter.filterScanlines;
57
- exports.inflate = require_bytes_flate.inflate;
58
- exports.inflateTolerant = require_bytes_flate.inflateTolerant;
59
- exports.isAsciiWhitespace = require_bytes_reader.isAsciiWhitespace;
60
40
  exports.loadMathFont = require_math_font.loadMathFont;
61
41
  exports.looksLikeBareCodestream = require_image_jp2_boxes.looksLikeBareCodestream;
62
42
  exports.parseJp2Container = require_image_jp2_boxes.parseJp2Container;
63
43
  exports.pdfCodec = require_codec.pdfCodec;
64
44
  exports.readFontFace = require_font_face.readFontFace;
65
45
  exports.readJpeg2000Metadata = require_image_jpeg2000.readJpeg2000Metadata;
66
- exports.readJpegInfo = require_image_jpeg_info.readJpegInfo;
67
46
  exports.readPdf = require_read.readPdf;
68
47
  exports.resolveFaceWithRegistry = require_font_registry.resolveFaceWithRegistry;
69
48
  exports.resolveStandardFont = require_fonts.resolveStandardFont;
70
- exports.rotatePointAboutCenter = require_matrix.rotatePointAboutCenter;
71
49
  exports.scaleMathStretchConstruction = require_math_stretch.scaleMathStretchConstruction;
72
50
  exports.unfilterScanlines = require_image_png_filter.unfilterScanlines;
73
- exports.wrapRunsToWidth = require_text_layout.wrapRunsToWidth;
74
51
  exports.writePdf = require_write.writePdf;
52
+ var byte_codec = require("byte-codec");
53
+ Object.keys(byte_codec).forEach(function(k) {
54
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
55
+ enumerable: true,
56
+ get: function() {
57
+ return byte_codec[k];
58
+ }
59
+ });
60
+ });
package/dist/index.d.cts CHANGED
@@ -1,8 +1,4 @@
1
1
  import { n as STANDARD_METRICS, r as StandardFontName, t as FontMetrics } from "./afm-widths-DyDq56Ph.cjs";
2
- import { crc32 } from "./bytes/crc32.cjs";
3
- import { DeflateLevel, InflateResult, MAX_INFLATE_OUTPUT_BYTES, deflate, inflate, inflateTolerant } from "./bytes/flate.cjs";
4
- import { ByteReader, isAsciiWhitespace } from "./bytes/reader.cjs";
5
- import { ByteWriter, concatBytes } from "./bytes/writer.cjs";
6
2
  import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
7
3
  import { NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError } from "./diagnostics.cjs";
8
4
  import { PdfBytesSchema, pdfCodec } from "./codec.cjs";
@@ -11,25 +7,23 @@ import { a as ResolvedFace, i as ProvidedFont, n as FontRegistryOptions, o as cr
11
7
  import { DEFAULT_VERTICAL_METRIC_POLICY, FontMeasurerOptions, StandardFontMeasurerOptions, TextMeasurer, UnderlineMetrics, VerticalMetricPolicy, createFontMeasurer, createStandardFontMeasurer } from "./measure.cjs";
12
8
  import { WinAnsiSubstitution } from "./winansi.cjs";
13
9
  import { FontFace, FontFaceParseError, readFontFace } from "./font-face.cjs";
14
- import { i as Point, u as rotatePointAboutCenter } from "./matrix-CC7OdJhv.cjs";
10
+ import { i as Point } from "./matrix-CC7OdJhv.cjs";
15
11
  import { ResolvedFont, resolveStandardFont } from "./fonts.cjs";
16
12
  import { PositionedFormula } from "./formula.cjs";
17
13
  import { CcittFaxImage, CcittFaxOptions, decodeCcittFax } from "./image/ccitt.cjs";
18
14
  import { n as Jbig2UnsupportedError, t as Jbig2ParseError } from "./jbig2-errors-Bj6MPxrx.cjs";
19
15
  import { Jbig2DecodeOptions, Jbig2Image, decodeJbig2Embedded } from "./image/jbig2.cjs";
20
16
  import { Jp2ChannelDefinition, Jp2ColourSpace, Jp2Container, Jp2ImageHeader, looksLikeBareCodestream, parseJp2Container } from "./image/jp2-boxes.cjs";
21
- import { JpegInfo, readJpegInfo } from "./image/jpeg-info.cjs";
22
17
  import { Jpeg2000ProgressionOrder, Jpeg2000QuantizationStyle, Jpeg2000Transform } from "./image/jpeg2000-codestream.cjs";
23
18
  import { Jpeg2000ParseError, Jpeg2000UnsupportedError } from "./image/jpeg2000-errors.cjs";
24
19
  import { Jpeg2000ComponentMetadata, Jpeg2000DecodeOptions, Jpeg2000Image, Jpeg2000Metadata, decodeJpeg2000, readJpeg2000Metadata } from "./image/jpeg2000.cjs";
25
- import { PngDecodeOptions, RawImage, decodePng } from "./image/png-decode.cjs";
26
- import { PngEncodeOptions, encodePng } from "./image/png-encode.cjs";
27
- import { PngFilterType, filterScanlines, unfilterScanlines } from "./image/png-filter.cjs";
20
+ import { filterScanlines, unfilterScanlines } from "./image/png-filter.cjs";
28
21
  import { ReadPdfOptions, readPdf } from "./read.cjs";
29
22
  import { WritePdfOptions, writePdf } from "./write.cjs";
30
23
  import { a as MathGlyphPart, c as MathVariants, n as MathGlyphAssembly, o as MathGlyphVariant, r as MathGlyphConstruction } from "./math-table-gFNB8DmQ.cjs";
31
24
  import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-E26z6byT.cjs";
32
25
  import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } from "./math-font.cjs";
33
- import { StyledFragment, StyledRun, WrapOptions, WrappedLine, wrapRunsToWidth } from "./text-layout.cjs";
26
+ import { StyledFragment, StyledRun, WrapOptions, WrappedLine } from "./text-layout.cjs";
34
27
  import { MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke } from "document-schema.js";
35
- export { ByteReader, ByteWriter, type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type DeflateLevel, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type InflateResult, 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, type JpegInfo, type LoadedMathFont, MAX_INFLATE_OUTPUT_BYTES, 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, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, type PngDecodeOptions, type PngEncodeOptions, type PngFilterType, type Point, type PositionedFormula, type ProvidedFont, type RawImage, type ReadPdfOptions, 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, concatBytes, crc32, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, decodePng, deflate, encodePng, filterScanlines, inflate, inflateTolerant, isAsciiWhitespace, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readJpegInfo, readPdf, resolveFaceWithRegistry, resolveStandardFont, rotatePointAboutCenter, scaleMathStretchConstruction, unfilterScanlines, wrapRunsToWidth, writePdf };
28
+ export * from "byte-codec";
29
+ export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, 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, 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, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, type Point, type PositionedFormula, type ProvidedFont, type ReadPdfOptions, 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, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,4 @@
1
1
  import { n as STANDARD_METRICS, r as StandardFontName, t as FontMetrics } from "./afm-widths-DyDq56Ph.js";
2
- import { crc32 } from "./bytes/crc32.js";
3
- import { DeflateLevel, InflateResult, MAX_INFLATE_OUTPUT_BYTES, deflate, inflate, inflateTolerant } from "./bytes/flate.js";
4
- import { ByteReader, isAsciiWhitespace } from "./bytes/reader.js";
5
- import { ByteWriter, concatBytes } from "./bytes/writer.js";
6
2
  import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.js";
7
3
  import { NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError } from "./diagnostics.js";
8
4
  import { PdfBytesSchema, pdfCodec } from "./codec.js";
@@ -11,25 +7,23 @@ import { a as ResolvedFace, i as ProvidedFont, n as FontRegistryOptions, o as cr
11
7
  import { DEFAULT_VERTICAL_METRIC_POLICY, FontMeasurerOptions, StandardFontMeasurerOptions, TextMeasurer, UnderlineMetrics, VerticalMetricPolicy, createFontMeasurer, createStandardFontMeasurer } from "./measure.js";
12
8
  import { WinAnsiSubstitution } from "./winansi.js";
13
9
  import { FontFace, FontFaceParseError, readFontFace } from "./font-face.js";
14
- import { i as Point, u as rotatePointAboutCenter } from "./matrix-CC7OdJhv.js";
10
+ import { i as Point } from "./matrix-CC7OdJhv.js";
15
11
  import { ResolvedFont, resolveStandardFont } from "./fonts.js";
16
12
  import { PositionedFormula } from "./formula.js";
17
13
  import { CcittFaxImage, CcittFaxOptions, decodeCcittFax } from "./image/ccitt.js";
18
14
  import { n as Jbig2UnsupportedError, t as Jbig2ParseError } from "./jbig2-errors-Bj6MPxrx.js";
19
15
  import { Jbig2DecodeOptions, Jbig2Image, decodeJbig2Embedded } from "./image/jbig2.js";
20
16
  import { Jp2ChannelDefinition, Jp2ColourSpace, Jp2Container, Jp2ImageHeader, looksLikeBareCodestream, parseJp2Container } from "./image/jp2-boxes.js";
21
- import { JpegInfo, readJpegInfo } from "./image/jpeg-info.js";
22
17
  import { Jpeg2000ProgressionOrder, Jpeg2000QuantizationStyle, Jpeg2000Transform } from "./image/jpeg2000-codestream.js";
23
18
  import { Jpeg2000ParseError, Jpeg2000UnsupportedError } from "./image/jpeg2000-errors.js";
24
19
  import { Jpeg2000ComponentMetadata, Jpeg2000DecodeOptions, Jpeg2000Image, Jpeg2000Metadata, decodeJpeg2000, readJpeg2000Metadata } from "./image/jpeg2000.js";
25
- import { PngDecodeOptions, RawImage, decodePng } from "./image/png-decode.js";
26
- import { PngEncodeOptions, encodePng } from "./image/png-encode.js";
27
- import { PngFilterType, filterScanlines, unfilterScanlines } from "./image/png-filter.js";
20
+ import { filterScanlines, unfilterScanlines } from "./image/png-filter.js";
28
21
  import { ReadPdfOptions, readPdf } from "./read.js";
29
22
  import { WritePdfOptions, writePdf } from "./write.js";
30
23
  import { a as MathGlyphPart, c as MathVariants, n as MathGlyphAssembly, o as MathGlyphVariant, r as MathGlyphConstruction } from "./math-table-DhPrNoPa.js";
31
24
  import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-a_rHNRvc.js";
32
25
  import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } from "./math-font.js";
33
- import { StyledFragment, StyledRun, WrapOptions, WrappedLine, wrapRunsToWidth } from "./text-layout.js";
26
+ import { StyledFragment, StyledRun, WrapOptions, WrappedLine } from "./text-layout.js";
34
27
  import { MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke } from "document-schema.js";
35
- export { ByteReader, ByteWriter, type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type DeflateLevel, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type InflateResult, 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, type JpegInfo, type LoadedMathFont, MAX_INFLATE_OUTPUT_BYTES, 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, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, type PngDecodeOptions, type PngEncodeOptions, type PngFilterType, type Point, type PositionedFormula, type ProvidedFont, type RawImage, type ReadPdfOptions, 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, concatBytes, crc32, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, decodePng, deflate, encodePng, filterScanlines, inflate, inflateTolerant, isAsciiWhitespace, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readJpegInfo, readPdf, resolveFaceWithRegistry, resolveStandardFont, rotatePointAboutCenter, scaleMathStretchConstruction, unfilterScanlines, wrapRunsToWidth, writePdf };
28
+ export * from "byte-codec";
29
+ export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, 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, 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, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, type Point, type PositionedFormula, type ProvidedFont, type ReadPdfOptions, 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, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
package/dist/index.js CHANGED
@@ -1,21 +1,13 @@
1
1
  import { t as STANDARD_METRICS } from "./afm-widths-Dxucrg7D.js";
2
- import { ByteReader, isAsciiWhitespace } from "./bytes/reader.js";
3
- import { crc32 } from "./bytes/crc32.js";
4
- import { ByteWriter, concatBytes } from "./bytes/writer.js";
5
2
  import { NOOP_DIAGNOSTIC_SINK, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError } from "./diagnostics.js";
6
- import { MAX_INFLATE_OUTPUT_BYTES, deflate, inflate, inflateTolerant } from "./bytes/flate.js";
7
3
  import { decodeCcittFax } from "./image/ccitt.js";
8
4
  import { Jbig2ParseError, Jbig2UnsupportedError } from "./image/jbig2-errors.js";
9
5
  import { decodeJbig2Embedded } from "./image/jbig2.js";
10
6
  import { filterScanlines, unfilterScanlines } from "./image/png-filter.js";
11
7
  import { resolveStandardFont } from "./fonts.js";
12
- import { encodePng } from "./image/png-encode.js";
13
- import { readJpegInfo } from "./image/jpeg-info.js";
14
8
  import { Jpeg2000ParseError, Jpeg2000UnsupportedError } from "./image/jpeg2000-errors.js";
15
9
  import { looksLikeBareCodestream, parseJp2Container } from "./image/jp2-boxes.js";
16
10
  import { decodeJpeg2000, readJpeg2000Metadata } from "./image/jpeg2000.js";
17
- import { rotatePointAboutCenter } from "./matrix.js";
18
- import { decodePng } from "./image/png-decode.js";
19
11
  import { createFontRegistry, resolveFaceWithRegistry } from "./font-registry.js";
20
12
  import { assembleStretchyGlyph, scaleMathStretchConstruction } from "./math-stretch.js";
21
13
  import { loadMathFont } from "./math-font.js";
@@ -24,5 +16,5 @@ import { writePdf } from "./write.js";
24
16
  import { readPdf } from "./read.js";
25
17
  import { PdfBytesSchema, pdfCodec } from "./codec.js";
26
18
  import { FontFaceParseError, readFontFace } from "./font-face.js";
27
- import { wrapRunsToWidth } from "./text-layout.js";
28
- export { ByteReader, ByteWriter, DEFAULT_VERTICAL_METRIC_POLICY, FontFaceParseError, Jbig2ParseError, Jbig2UnsupportedError, Jpeg2000ParseError, Jpeg2000UnsupportedError, MAX_INFLATE_OUTPUT_BYTES, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, STANDARD_METRICS, assembleStretchyGlyph, concatBytes, crc32, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, decodePng, deflate, encodePng, filterScanlines, inflate, inflateTolerant, isAsciiWhitespace, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readJpegInfo, readPdf, resolveFaceWithRegistry, resolveStandardFont, rotatePointAboutCenter, scaleMathStretchConstruction, unfilterScanlines, wrapRunsToWidth, writePdf };
19
+ export * from "byte-codec";
20
+ export { DEFAULT_VERTICAL_METRIC_POLICY, FontFaceParseError, Jbig2ParseError, Jbig2UnsupportedError, Jpeg2000ParseError, Jpeg2000UnsupportedError, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, STANDARD_METRICS, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdf-codec",
3
- "version": "1.11.11",
3
+ "version": "2.0.1",
4
4
  "description": "Hand-written, dependency-minimal PDF codec: parses arbitrary real-world PDFs and generates new ones, built on document-schema.js's LayoutDocument pivot and Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -50,6 +50,7 @@
50
50
  "lint": "eslint . --fix --cache --max-warnings 0",
51
51
  "typecheck": "tsc --noEmit",
52
52
  "test": "vitest run --project unit",
53
+ "test:workers": "vitest run --config vitest.workers.config.ts",
53
54
  "test:watch": "vitest --project unit",
54
55
  "test:coverage": "vitest run --project unit --coverage",
55
56
  "test:corpus": "vitest run --project corpus",
@@ -70,12 +71,14 @@
70
71
  "license": "MIT",
71
72
  "packageManager": "pnpm@11.6.0",
72
73
  "dependencies": {
73
- "document-schema.js": "^2.4.0",
74
+ "byte-codec": "^1.0.4",
75
+ "document-schema.js": "^2.4.4",
74
76
  "fflate": "^0.8.3",
75
77
  "zod": "^4.4.3"
76
78
  },
77
79
  "devDependencies": {
78
80
  "@arethetypeswrong/cli": "^0.18.5",
81
+ "@cloudflare/vitest-pool-workers": "^0.20.2",
79
82
  "@commitlint/cli": "^21.2.1",
80
83
  "@commitlint/config-conventional": "^21.2.0",
81
84
  "@eslint/js": "^10.0.1",