pdf-codec 5.7.4 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -79,6 +79,7 @@ exports.filterScanlines = require_image_png_filter.filterScanlines;
79
79
  exports.groupPdfTextRuns = require_text_group.groupPdfTextRuns;
80
80
  exports.loadMathFont = require_math_font.loadMathFont;
81
81
  exports.looksLikeBareCodestream = require_image_jp2_boxes.looksLikeBareCodestream;
82
+ exports.normalisedRotationDeg = require_text_group.normalisedRotationDeg;
82
83
  exports.parseJp2Container = require_image_jp2_boxes.parseJp2Container;
83
84
  exports.pdfCodec = require_codec.pdfCodec;
84
85
  exports.readFontFace = require_font_face.readFontFace;
@@ -87,6 +88,7 @@ exports.readPdf = require_read.readPdf;
87
88
  exports.renderPdfPage = require_raster.renderPdfPage;
88
89
  exports.resolveFaceWithRegistry = require_font_registry.resolveFaceWithRegistry;
89
90
  exports.resolveStandardFont = require_fonts.resolveStandardFont;
91
+ exports.runAlongBaselinePt = require_text_group.runAlongBaselinePt;
90
92
  exports.runGapPt = require_text_group.runGapPt;
91
93
  exports.runsShareBaseline = require_text_group.runsShareBaseline;
92
94
  exports.scaleMathStretchConstruction = require_math_stretch.scaleMathStretchConstruction;
package/dist/index.d.cts CHANGED
@@ -24,8 +24,8 @@ import { a as MathGlyphPart, c as MathVariants, n as MathGlyphAssembly, o as Mat
24
24
  import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-C2JanDAz.cjs";
25
25
  import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } from "./math-font.cjs";
26
26
  import { DEFAULT_VERTICAL_METRIC_POLICY, FontMeasurerOptions, StandardFontMeasurerOptions, VerticalMetricPolicy, createFontMeasurer, createStandardFontMeasurer } from "./measure.cjs";
27
- import { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, PdfLineWithScripts, PdfScriptPosition, PdfTextBox, PdfTextGroupingOptions, PdfTextLine, PdfTextRunGeometry, PdfTextWord, PdfWordSeparator, attachScriptRuns, groupPdfTextRuns, runGapPt, runsShareBaseline, scriptPositionOf } from "./text-group.cjs";
27
+ import { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, PdfLineWithScripts, PdfScriptPosition, PdfTextBox, PdfTextGroupingOptions, PdfTextLine, PdfTextRunGeometry, PdfTextWord, PdfWordSeparator, attachScriptRuns, groupPdfTextRuns, normalisedRotationDeg, runAlongBaselinePt, runGapPt, runsShareBaseline, scriptPositionOf } from "./text-group.cjs";
28
28
  import { PageRasteriser, RasterDrawOp, RasterFillRectOp, RasterFillSpec, RasterImageOp, RasterMatrix, RasterPageGeometry, RasterPathOp, RasterPathSegment, RasterRegionPt, RasterStrokeSpec, RasterSubpath, RenderPdfPageOptions, renderPdfPage } from "./raster.cjs";
29
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";
30
30
  export * from "byte-codec";
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, type PdfLineWithScripts, PdfPageSelectionError, PdfParseError, PdfPartialDocumentError, PdfPasswordRequiredError, type PdfScriptPosition, 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, attachScriptRuns, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runGapPt, runsShareBaseline, scaleMathStretchConstruction, scriptPositionOf, 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, type PdfLineWithScripts, PdfPageSelectionError, PdfParseError, PdfPartialDocumentError, PdfPasswordRequiredError, type PdfScriptPosition, 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, attachScriptRuns, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, normalisedRotationDeg, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runAlongBaselinePt, runGapPt, runsShareBaseline, scaleMathStretchConstruction, scriptPositionOf, sourcePageIndex, unfilterScanlines, writePdf };
package/dist/index.d.ts CHANGED
@@ -24,8 +24,8 @@ import { a as MathGlyphPart, c as MathVariants, n as MathGlyphAssembly, o as Mat
24
24
  import { a as scaleMathStretchConstruction, i as assembleStretchyGlyph, n as MathStretchOptions, r as MathStretchPlacement, t as MathStretchConstruction } from "./math-stretch-BbC2o4Br.js";
25
25
  import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } from "./math-font.js";
26
26
  import { DEFAULT_VERTICAL_METRIC_POLICY, FontMeasurerOptions, StandardFontMeasurerOptions, VerticalMetricPolicy, createFontMeasurer, createStandardFontMeasurer } from "./measure.js";
27
- import { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, PdfLineWithScripts, PdfScriptPosition, PdfTextBox, PdfTextGroupingOptions, PdfTextLine, PdfTextRunGeometry, PdfTextWord, PdfWordSeparator, attachScriptRuns, groupPdfTextRuns, runGapPt, runsShareBaseline, scriptPositionOf } from "./text-group.js";
27
+ import { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, PdfLineWithScripts, PdfScriptPosition, PdfTextBox, PdfTextGroupingOptions, PdfTextLine, PdfTextRunGeometry, PdfTextWord, PdfWordSeparator, attachScriptRuns, groupPdfTextRuns, normalisedRotationDeg, runAlongBaselinePt, runGapPt, runsShareBaseline, scriptPositionOf } from "./text-group.js";
28
28
  import { PageRasteriser, RasterDrawOp, RasterFillRectOp, RasterFillSpec, RasterImageOp, RasterMatrix, RasterPageGeometry, RasterPathOp, RasterPathSegment, RasterRegionPt, RasterStrokeSpec, RasterSubpath, RenderPdfPageOptions, renderPdfPage } from "./raster.js";
29
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";
30
30
  export * from "byte-codec";
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, type PdfLineWithScripts, PdfPageSelectionError, PdfParseError, PdfPartialDocumentError, PdfPasswordRequiredError, type PdfScriptPosition, 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, attachScriptRuns, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runGapPt, runsShareBaseline, scaleMathStretchConstruction, scriptPositionOf, 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, type PdfLineWithScripts, PdfPageSelectionError, PdfParseError, PdfPartialDocumentError, PdfPasswordRequiredError, type PdfScriptPosition, 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, attachScriptRuns, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, normalisedRotationDeg, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runAlongBaselinePt, runGapPt, runsShareBaseline, scaleMathStretchConstruction, scriptPositionOf, sourcePageIndex, unfilterScanlines, writePdf };
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { decodeJpeg2000, readJpeg2000Metadata } from "./image/jpeg2000.js";
9
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
- import { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, attachScriptRuns, groupPdfTextRuns, runGapPt, runsShareBaseline, scriptPositionOf } from "./text-group.js";
12
+ import { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, attachScriptRuns, groupPdfTextRuns, normalisedRotationDeg, runAlongBaselinePt, runGapPt, runsShareBaseline, scriptPositionOf } from "./text-group.js";
13
13
  import { readPdf } from "./read.js";
14
14
  import { PdfEncryptionError } from "./encrypt-write.js";
15
15
  import { assembleStretchyGlyph, scaleMathStretchConstruction } from "./math-stretch.js";
@@ -22,4 +22,4 @@ import { PdfBytesSchema, pdfCodec } from "./codec.js";
22
22
  import { FontFaceParseError, readFontFace } from "./font-face.js";
23
23
  import { r as renderPdfPage } from "./raster-dqtea8ku.js";
24
24
  export * from "byte-codec";
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, attachScriptRuns, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runGapPt, runsShareBaseline, scaleMathStretchConstruction, scriptPositionOf, 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, attachScriptRuns, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, groupPdfTextRuns, loadMathFont, looksLikeBareCodestream, normalisedRotationDeg, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, renderPdfPage, resolveFaceWithRegistry, resolveStandardFont, runAlongBaselinePt, runGapPt, runsShareBaseline, scaleMathStretchConstruction, scriptPositionOf, sourcePageIndex, unfilterScanlines, writePdf };
@@ -5,9 +5,16 @@ const DEFAULT_COLUMN_GAP_EM = 1;
5
5
  const ROTATION_NOISE_DEG = 1e-6;
6
6
  const DEGREES_PER_TURN = 360;
7
7
  const VERTICAL_ADVANCE_OFFSET_DEG = -90;
8
+ /**
9
+ * An anticlockwise rotation as one canonical number: normalised into [0, 360) and rounded to remove the last-bit noise atan2 leaves, so two runs set at one angle report the identical value and a comparison against a quarter turn is exact.
10
+ * @param rotationDeg - a rotation in degrees, anticlockwise from the page's x-axis; absent means zero
11
+ * @returns the same angle in [0, 360)
12
+ */
13
+ function normalisedRotationDeg(rotationDeg) {
14
+ return (Math.round((rotationDeg ?? 0) / ROTATION_NOISE_DEG) * ROTATION_NOISE_DEG % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN;
15
+ }
8
16
  function advanceAngleDeg(run) {
9
- const raw = (run.rotationDeg ?? 0) + (run.writingMode === "vertical" ? VERTICAL_ADVANCE_OFFSET_DEG : 0);
10
- return (Math.round(raw / ROTATION_NOISE_DEG) * ROTATION_NOISE_DEG % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN;
17
+ return normalisedRotationDeg((run.rotationDeg ?? 0) + (run.writingMode === "vertical" ? VERTICAL_ADVANCE_OFFSET_DEG : 0));
11
18
  }
12
19
  const RADIANS_PER_TURN = 2 * Math.PI;
13
20
  function baselineAxis(rotationDeg) {
@@ -49,6 +56,14 @@ function runsShareBaseline(a, b, options = {}) {
49
56
  return Math.abs(project(a, rotationDeg).acrossPt - project(b, rotationDeg).acrossPt) <= toleranceEm * Math.min(a.sizePt, b.sizePt);
50
57
  }
51
58
  /**
59
+ * Where a run starts along the direction it advances in: the coordinate that puts the runs of one line in reading order, at whatever angle the line is set. For an upright run it is the run's `xPt`; for a run turned a quarter turn anticlockwise, read upward, it is its `yPt`.
60
+ * @param run - a positioned run
61
+ * @returns the run's origin projected onto its own baseline, in points
62
+ */
63
+ function runAlongBaselinePt(run) {
64
+ return project(run, advanceAngleDeg(run)).alongPt;
65
+ }
66
+ /**
52
67
  * The horizontal gap along the baseline between the end of `previous` and the start of `next`, or undefined when the geometry does not state one.
53
68
  *
54
69
  * Undefined has exactly two causes, and a caller must treat both as "no evidence of a space" rather than substituting zero: `previous` stated no advance width, so where it ends is unknown; or the two runs are set at different angles, so they share no axis to measure along. A negative result is real and means the two runs overlap.
@@ -298,6 +313,8 @@ exports.DEFAULT_COLUMN_GAP_EM = DEFAULT_COLUMN_GAP_EM;
298
313
  exports.DEFAULT_WORD_GAP_EM = DEFAULT_WORD_GAP_EM;
299
314
  exports.attachScriptRuns = attachScriptRuns;
300
315
  exports.groupPdfTextRuns = groupPdfTextRuns;
316
+ exports.normalisedRotationDeg = normalisedRotationDeg;
317
+ exports.runAlongBaselinePt = runAlongBaselinePt;
301
318
  exports.runGapPt = runGapPt;
302
319
  exports.runsShareBaseline = runsShareBaseline;
303
320
  exports.scriptPositionOf = scriptPositionOf;
@@ -37,6 +37,12 @@ interface PdfTextGroupingOptions {
37
37
  declare const DEFAULT_BASELINE_TOLERANCE_EM: number;
38
38
  declare const DEFAULT_WORD_GAP_EM: number;
39
39
  declare const DEFAULT_COLUMN_GAP_EM = 1;
40
+ /**
41
+ * An anticlockwise rotation as one canonical number: normalised into [0, 360) and rounded to remove the last-bit noise atan2 leaves, so two runs set at one angle report the identical value and a comparison against a quarter turn is exact.
42
+ * @param rotationDeg - a rotation in degrees, anticlockwise from the page's x-axis; absent means zero
43
+ * @returns the same angle in [0, 360)
44
+ */
45
+ declare function normalisedRotationDeg(rotationDeg: number | undefined): number;
40
46
  /**
41
47
  * Whether two positioned runs sit on one visual line.
42
48
  *
@@ -47,6 +53,12 @@ declare const DEFAULT_COLUMN_GAP_EM = 1;
47
53
  * @returns true when the two baselines are within tolerance of each other
48
54
  */
49
55
  declare function runsShareBaseline(a: PdfTextRunGeometry, b: PdfTextRunGeometry, options?: PdfTextGroupingOptions): boolean;
56
+ /**
57
+ * Where a run starts along the direction it advances in: the coordinate that puts the runs of one line in reading order, at whatever angle the line is set. For an upright run it is the run's `xPt`; for a run turned a quarter turn anticlockwise, read upward, it is its `yPt`.
58
+ * @param run - a positioned run
59
+ * @returns the run's origin projected onto its own baseline, in points
60
+ */
61
+ declare function runAlongBaselinePt(run: PdfTextRunGeometry): number;
50
62
  /**
51
63
  * The horizontal gap along the baseline between the end of `previous` and the start of `next`, or undefined when the geometry does not state one.
52
64
  *
@@ -95,4 +107,4 @@ declare function attachScriptRuns<TLine, TRun extends PdfTextRunGeometry>(lines:
95
107
  */
96
108
  declare function groupPdfTextRuns<TRun extends PdfTextRunGeometry>(runs: readonly TRun[], options?: PdfTextGroupingOptions): PdfTextLine<TRun>[];
97
109
  //#endregion
98
- export { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, PdfLineWithScripts, PdfScriptPosition, PdfTextBox, PdfTextGroupingOptions, PdfTextLine, PdfTextRunGeometry, PdfTextWord, PdfWordSeparator, attachScriptRuns, groupPdfTextRuns, runGapPt, runsShareBaseline, scriptPositionOf };
110
+ export { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, PdfLineWithScripts, PdfScriptPosition, PdfTextBox, PdfTextGroupingOptions, PdfTextLine, PdfTextRunGeometry, PdfTextWord, PdfWordSeparator, attachScriptRuns, groupPdfTextRuns, normalisedRotationDeg, runAlongBaselinePt, runGapPt, runsShareBaseline, scriptPositionOf };
@@ -37,6 +37,12 @@ interface PdfTextGroupingOptions {
37
37
  declare const DEFAULT_BASELINE_TOLERANCE_EM: number;
38
38
  declare const DEFAULT_WORD_GAP_EM: number;
39
39
  declare const DEFAULT_COLUMN_GAP_EM = 1;
40
+ /**
41
+ * An anticlockwise rotation as one canonical number: normalised into [0, 360) and rounded to remove the last-bit noise atan2 leaves, so two runs set at one angle report the identical value and a comparison against a quarter turn is exact.
42
+ * @param rotationDeg - a rotation in degrees, anticlockwise from the page's x-axis; absent means zero
43
+ * @returns the same angle in [0, 360)
44
+ */
45
+ declare function normalisedRotationDeg(rotationDeg: number | undefined): number;
40
46
  /**
41
47
  * Whether two positioned runs sit on one visual line.
42
48
  *
@@ -47,6 +53,12 @@ declare const DEFAULT_COLUMN_GAP_EM = 1;
47
53
  * @returns true when the two baselines are within tolerance of each other
48
54
  */
49
55
  declare function runsShareBaseline(a: PdfTextRunGeometry, b: PdfTextRunGeometry, options?: PdfTextGroupingOptions): boolean;
56
+ /**
57
+ * Where a run starts along the direction it advances in: the coordinate that puts the runs of one line in reading order, at whatever angle the line is set. For an upright run it is the run's `xPt`; for a run turned a quarter turn anticlockwise, read upward, it is its `yPt`.
58
+ * @param run - a positioned run
59
+ * @returns the run's origin projected onto its own baseline, in points
60
+ */
61
+ declare function runAlongBaselinePt(run: PdfTextRunGeometry): number;
50
62
  /**
51
63
  * The horizontal gap along the baseline between the end of `previous` and the start of `next`, or undefined when the geometry does not state one.
52
64
  *
@@ -95,4 +107,4 @@ declare function attachScriptRuns<TLine, TRun extends PdfTextRunGeometry>(lines:
95
107
  */
96
108
  declare function groupPdfTextRuns<TRun extends PdfTextRunGeometry>(runs: readonly TRun[], options?: PdfTextGroupingOptions): PdfTextLine<TRun>[];
97
109
  //#endregion
98
- export { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, PdfLineWithScripts, PdfScriptPosition, PdfTextBox, PdfTextGroupingOptions, PdfTextLine, PdfTextRunGeometry, PdfTextWord, PdfWordSeparator, attachScriptRuns, groupPdfTextRuns, runGapPt, runsShareBaseline, scriptPositionOf };
110
+ export { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, PdfLineWithScripts, PdfScriptPosition, PdfTextBox, PdfTextGroupingOptions, PdfTextLine, PdfTextRunGeometry, PdfTextWord, PdfWordSeparator, attachScriptRuns, groupPdfTextRuns, normalisedRotationDeg, runAlongBaselinePt, runGapPt, runsShareBaseline, scriptPositionOf };
@@ -4,9 +4,16 @@ const DEFAULT_COLUMN_GAP_EM = 1;
4
4
  const ROTATION_NOISE_DEG = 1e-6;
5
5
  const DEGREES_PER_TURN = 360;
6
6
  const VERTICAL_ADVANCE_OFFSET_DEG = -90;
7
+ /**
8
+ * An anticlockwise rotation as one canonical number: normalised into [0, 360) and rounded to remove the last-bit noise atan2 leaves, so two runs set at one angle report the identical value and a comparison against a quarter turn is exact.
9
+ * @param rotationDeg - a rotation in degrees, anticlockwise from the page's x-axis; absent means zero
10
+ * @returns the same angle in [0, 360)
11
+ */
12
+ function normalisedRotationDeg(rotationDeg) {
13
+ return (Math.round((rotationDeg ?? 0) / ROTATION_NOISE_DEG) * ROTATION_NOISE_DEG % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN;
14
+ }
7
15
  function advanceAngleDeg(run) {
8
- const raw = (run.rotationDeg ?? 0) + (run.writingMode === "vertical" ? VERTICAL_ADVANCE_OFFSET_DEG : 0);
9
- return (Math.round(raw / ROTATION_NOISE_DEG) * ROTATION_NOISE_DEG % DEGREES_PER_TURN + DEGREES_PER_TURN) % DEGREES_PER_TURN;
16
+ return normalisedRotationDeg((run.rotationDeg ?? 0) + (run.writingMode === "vertical" ? VERTICAL_ADVANCE_OFFSET_DEG : 0));
10
17
  }
11
18
  const RADIANS_PER_TURN = 2 * Math.PI;
12
19
  function baselineAxis(rotationDeg) {
@@ -48,6 +55,14 @@ function runsShareBaseline(a, b, options = {}) {
48
55
  return Math.abs(project(a, rotationDeg).acrossPt - project(b, rotationDeg).acrossPt) <= toleranceEm * Math.min(a.sizePt, b.sizePt);
49
56
  }
50
57
  /**
58
+ * Where a run starts along the direction it advances in: the coordinate that puts the runs of one line in reading order, at whatever angle the line is set. For an upright run it is the run's `xPt`; for a run turned a quarter turn anticlockwise, read upward, it is its `yPt`.
59
+ * @param run - a positioned run
60
+ * @returns the run's origin projected onto its own baseline, in points
61
+ */
62
+ function runAlongBaselinePt(run) {
63
+ return project(run, advanceAngleDeg(run)).alongPt;
64
+ }
65
+ /**
51
66
  * The horizontal gap along the baseline between the end of `previous` and the start of `next`, or undefined when the geometry does not state one.
52
67
  *
53
68
  * Undefined has exactly two causes, and a caller must treat both as "no evidence of a space" rather than substituting zero: `previous` stated no advance width, so where it ends is unknown; or the two runs are set at different angles, so they share no axis to measure along. A negative result is real and means the two runs overlap.
@@ -292,4 +307,4 @@ function groupPdfTextRuns(runs, options = {}) {
292
307
  return result;
293
308
  }
294
309
  //#endregion
295
- export { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, attachScriptRuns, groupPdfTextRuns, runGapPt, runsShareBaseline, scriptPositionOf };
310
+ export { DEFAULT_BASELINE_TOLERANCE_EM, DEFAULT_COLUMN_GAP_EM, DEFAULT_WORD_GAP_EM, attachScriptRuns, groupPdfTextRuns, normalisedRotationDeg, runAlongBaselinePt, runGapPt, runsShareBaseline, scriptPositionOf };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdf-codec",
3
- "version": "5.7.4",
3
+ "version": "5.8.0",
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": {