aurochs 0.5.0 → 0.6.2
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/@aurochs/pdf/src/domain/color/color-space.d.ts +12 -0
- package/dist/@aurochs/pdf/src/domain/color/index.d.ts +9 -0
- package/dist/@aurochs/pdf/src/domain/color/primitives.d.ts +109 -0
- package/dist/@aurochs/pdf/src/domain/constants.d.ts +24 -0
- package/dist/@aurochs/pdf/src/domain/content-stream/index.d.ts +8 -0
- package/dist/@aurochs/pdf/src/domain/content-stream/tokenizer.d.ts +24 -0
- package/dist/@aurochs/pdf/src/domain/coordinate/index.d.ts +8 -0
- package/dist/@aurochs/pdf/src/domain/coordinate/matrix.d.ts +81 -0
- package/dist/@aurochs/pdf/src/domain/document/index.d.ts +7 -0
- package/dist/@aurochs/pdf/src/domain/document/types.d.ts +114 -0
- package/dist/@aurochs/pdf/src/domain/font/cff/cff-cid-parser.d.ts +19 -0
- package/dist/@aurochs/pdf/src/domain/font/cid/adobe-japan1-cid-to-unicode.d.ts +13 -0
- package/dist/@aurochs/pdf/src/domain/font/cid/cid-ordering.d.ts +26 -0
- package/dist/@aurochs/pdf/src/domain/font/cid/japan1-kanji-mappings.d.ts +4 -0
- package/dist/@aurochs/pdf/src/domain/font/cmap/cmap-parser.d.ts +64 -0
- package/dist/@aurochs/pdf/src/domain/font/decoding/cid-glyph-fallback.d.ts +24 -0
- package/dist/@aurochs/pdf/src/domain/font/decoding/text-decoder.d.ts +7 -0
- package/dist/@aurochs/pdf/src/domain/font/defaults.d.ts +23 -0
- package/dist/@aurochs/pdf/src/domain/font/encoding-maps.d.ts +70 -0
- package/dist/@aurochs/pdf/src/domain/font/font-css-generator.d.ts +22 -0
- package/dist/@aurochs/pdf/src/domain/font/font-extractor.d.ts +7 -0
- package/dist/@aurochs/pdf/src/domain/font/font-extractor.native.d.ts +4 -0
- package/dist/@aurochs/pdf/src/domain/font/font-name-map.d.ts +23 -0
- package/dist/@aurochs/pdf/src/domain/font/font-repair.d.ts +21 -0
- package/dist/@aurochs/pdf/src/domain/font/font-style.d.ts +31 -0
- package/dist/@aurochs/pdf/src/domain/font/index.d.ts +22 -0
- package/dist/@aurochs/pdf/src/domain/font/truetype-parser.d.ts +74 -0
- package/dist/@aurochs/pdf/src/domain/font/truetype-table-builders.d.ts +34 -0
- package/dist/@aurochs/pdf/src/domain/graphics-state/defaults.d.ts +8 -0
- package/dist/@aurochs/pdf/src/domain/graphics-state/index.d.ts +10 -0
- package/dist/@aurochs/pdf/src/domain/graphics-state/stack.d.ts +62 -0
- package/dist/@aurochs/pdf/src/domain/index.d.ts +21 -0
- package/dist/@aurochs/pdf/src/image/pixel-converter.d.ts +39 -0
- package/dist/@aurochs/pdf/src/index.d.ts +17 -0
- package/dist/@aurochs/pdf/src/native/core/encoding.d.ts +17 -0
- package/dist/@aurochs/pdf/src/native/core/scan.d.ts +11 -0
- package/dist/@aurochs/pdf/src/native/document/document.d.ts +43 -0
- package/dist/@aurochs/pdf/src/native/encryption/aes.d.ts +45 -0
- package/dist/@aurochs/pdf/src/native/encryption/bytes.d.ts +11 -0
- package/dist/@aurochs/pdf/src/native/encryption/decrypt-object.d.ts +15 -0
- package/dist/@aurochs/pdf/src/native/encryption/md5.d.ts +5 -0
- package/dist/@aurochs/pdf/src/native/encryption/r6-hash.d.ts +16 -0
- package/dist/@aurochs/pdf/src/native/encryption/rc4.d.ts +5 -0
- package/dist/@aurochs/pdf/src/native/encryption/saslprep.d.ts +12 -0
- package/dist/@aurochs/pdf/src/native/encryption/saslprep.tables.d.ts +11 -0
- package/dist/@aurochs/pdf/src/native/encryption/sha256.d.ts +5 -0
- package/dist/@aurochs/pdf/src/native/encryption/sha512.d.ts +7 -0
- package/dist/@aurochs/pdf/src/native/encryption/standard.d.ts +18 -0
- package/dist/@aurochs/pdf/src/native/filters/ascii-hex.d.ts +5 -0
- package/dist/@aurochs/pdf/src/native/filters/ascii85.d.ts +5 -0
- package/dist/@aurochs/pdf/src/native/filters/flate.d.ts +3 -0
- package/dist/@aurochs/pdf/src/native/filters/index.d.ts +8 -0
- package/dist/@aurochs/pdf/src/native/filters/lzw.d.ts +22 -0
- package/dist/@aurochs/pdf/src/native/filters/predictor.d.ts +3 -0
- package/dist/@aurochs/pdf/src/native/filters/run-length.d.ts +5 -0
- package/dist/@aurochs/pdf/src/native/index.d.ts +6 -0
- package/dist/@aurochs/pdf/src/native/resolver/resolver.d.ts +17 -0
- package/dist/@aurochs/pdf/src/native/stream/stream.d.ts +3 -0
- package/dist/@aurochs/pdf/src/native/syntax/lexer.d.ts +37 -0
- package/dist/@aurochs/pdf/src/native/syntax/object-parser.d.ts +19 -0
- package/dist/@aurochs/pdf/src/native/xmp/xmp.d.ts +7 -0
- package/dist/@aurochs/pdf/src/native/xref/xref.d.ts +23 -0
- package/dist/@aurochs/pdf/src/parser/clip/clip-mask-apply.native.d.ts +5 -0
- package/dist/@aurochs/pdf/src/parser/clip/form-bbox-clip-mask.native.d.ts +5 -0
- package/dist/@aurochs/pdf/src/parser/color/color-space.native.d.ts +13 -0
- package/dist/@aurochs/pdf/src/parser/color/icc-profile.native.d.ts +55 -0
- package/dist/@aurochs/pdf/src/parser/core/native-load.d.ts +4 -0
- package/dist/@aurochs/pdf/src/parser/core/pdf-context-rewrite.d.ts +34 -0
- package/dist/@aurochs/pdf/src/parser/core/pdf-load-error.d.ts +33 -0
- package/dist/@aurochs/pdf/src/parser/core/pdf-parser.d.ts +29 -0
- package/dist/@aurochs/pdf/src/parser/core/pdf-parser.native.d.ts +66 -0
- package/dist/@aurochs/pdf/src/parser/font/cid-ordering-heuristics.d.ts +19 -0
- package/dist/@aurochs/pdf/src/parser/font/font-decoder.native.d.ts +9 -0
- package/dist/@aurochs/pdf/src/parser/graphics-state/ext-gstate.native.d.ts +48 -0
- package/dist/@aurochs/pdf/src/parser/image/ccitt-fax-decode.d.ts +45 -0
- package/dist/@aurochs/pdf/src/parser/image/image-extractor.native.d.ts +25 -0
- package/dist/@aurochs/pdf/src/parser/image/inline-image.native.d.ts +10 -0
- package/dist/@aurochs/pdf/src/parser/image/jpeg-decode.d.ts +13 -0
- package/dist/@aurochs/pdf/src/parser/jpeg2000/jpx-decoder.d.ts +20 -0
- package/dist/@aurochs/pdf/src/parser/operator/color-handlers.d.ts +35 -0
- package/dist/@aurochs/pdf/src/parser/operator/graphics-state-handlers.d.ts +16 -0
- package/dist/@aurochs/pdf/src/parser/operator/index.d.ts +21 -0
- package/dist/@aurochs/pdf/src/parser/operator/parse.d.ts +131 -0
- package/dist/@aurochs/pdf/src/parser/operator/path-handlers.d.ts +24 -0
- package/dist/@aurochs/pdf/src/parser/operator/shading-handlers.d.ts +5 -0
- package/dist/@aurochs/pdf/src/parser/operator/stack-ops.d.ts +67 -0
- package/dist/@aurochs/pdf/src/parser/operator/text-handlers.d.ts +79 -0
- package/dist/@aurochs/pdf/src/parser/operator/xobject-handlers.d.ts +8 -0
- package/dist/@aurochs/pdf/src/parser/pattern/pattern-fill-raster.d.ts +8 -0
- package/dist/@aurochs/pdf/src/parser/pattern/pattern-tiling-raster.d.ts +8 -0
- package/dist/@aurochs/pdf/src/parser/pattern/pattern.native.d.ts +6 -0
- package/dist/@aurochs/pdf/src/parser/shading/shading-raster.d.ts +4 -0
- package/dist/@aurochs/pdf/src/parser/shading/shading.native.d.ts +8 -0
- package/dist/@aurochs/pdf/src/parser/soft-mask/soft-mask-apply.native.d.ts +3 -0
- package/dist/@aurochs/pdf/src/parser/soft-mask/soft-mask-raster.native.d.ts +10 -0
- package/dist/@aurochs/pdf/src/parser/soft-mask/soft-mask-text-raster.native.d.ts +5 -0
- package/dist/@aurochs/pdf/src/parser/type3/type3-expand.native.d.ts +19 -0
- package/dist/@aurochs/pdf/src/parser/type3/type3-glyph.native.d.ts +29 -0
- package/dist/@aurochs/pdf/src/writer/content-stream/graphics-state-operators.d.ts +68 -0
- package/dist/@aurochs/pdf/src/writer/content-stream/index.d.ts +6 -0
- package/dist/@aurochs/pdf/src/writer/content-stream/path-operators.d.ts +27 -0
- package/dist/@aurochs/pdf/src/writer/content-stream/text-operators.d.ts +33 -0
- package/dist/@aurochs/pdf/src/writer/document/font-builder.d.ts +32 -0
- package/dist/@aurochs/pdf/src/writer/document/image-builder.d.ts +18 -0
- package/dist/@aurochs/pdf/src/writer/document/index.d.ts +8 -0
- package/dist/@aurochs/pdf/src/writer/document/object-tracker.d.ts +66 -0
- package/dist/@aurochs/pdf/src/writer/document/page-builder.d.ts +30 -0
- package/dist/@aurochs/pdf/src/writer/document/resource-builder.d.ts +27 -0
- package/dist/@aurochs/pdf/src/writer/document-writer.d.ts +22 -0
- package/dist/@aurochs/pdf/src/writer/encode-filters.d.ts +23 -0
- package/dist/@aurochs/pdf/src/writer/index.d.ts +10 -0
- package/dist/@aurochs/pdf/src/writer/object-serializer.d.ts +63 -0
- package/dist/@aurochs/pdf/src/writer/stream-encoder.d.ts +42 -0
- package/dist/@aurochs/pdf/src/writer/xref-builder.d.ts +55 -0
- package/dist/@aurochs-builder/pdf/src/builder.d.ts +21 -0
- package/dist/@aurochs-builder/pdf/src/index.d.ts +7 -0
- package/dist/@aurochs-builder/pdf/src/pdf-document-builder.d.ts +4 -0
- package/dist/@aurochs-office/docx/src/constants.d.ts +26 -31
- package/dist/@aurochs-office/docx/src/domain/text-utils.d.ts +31 -0
- package/dist/@aurochs-office/docx/src/extract/index.d.ts +53 -0
- package/dist/@aurochs-office/docx/src/index.d.ts +1 -0
- package/dist/@aurochs-office/pptx/src/domain/content-types.d.ts +5 -0
- package/dist/@aurochs-office/pptx/src/domain/relationships.d.ts +1 -2
- package/dist/@aurochs-office/pptx/src/domain/text-utils.d.ts +27 -0
- package/dist/@aurochs-office/pptx/src/extract/index.d.ts +43 -0
- package/dist/@aurochs-office/pptx/src/index.d.ts +1 -0
- package/dist/@aurochs-office/xlsx/src/extract/index.d.ts +42 -0
- package/dist/@aurochs-office/xlsx/src/index.d.ts +1 -0
- package/dist/@aurochs-office/xlsx/src/parser/index.d.ts +4 -0
- package/dist/@aurochs-office/xlsx/src/text-utils.d.ts +30 -0
- package/dist/@aurochs-renderer/pdf/src/react/PdfDocumentRenderer.d.ts +14 -0
- package/dist/@aurochs-renderer/pdf/src/react/PdfPageRenderer.d.ts +11 -0
- package/dist/@aurochs-renderer/pdf/src/react/index.d.ts +3 -0
- package/dist/@aurochs-renderer/pdf/src/svg/color-to-svg.d.ts +6 -0
- package/dist/@aurochs-renderer/pdf/src/svg/image-data-url.d.ts +3 -0
- package/dist/@aurochs-renderer/pdf/src/svg/index.d.ts +2 -0
- package/dist/@aurochs-renderer/pdf/src/svg/number-format.d.ts +2 -0
- package/dist/@aurochs-renderer/pdf/src/svg/path-data.d.ts +2 -0
- package/dist/@aurochs-renderer/pdf/src/svg/render-page-svg.d.ts +6 -0
- package/dist/@aurochs-renderer/pdf/src/svg/xml-escape.d.ts +2 -0
- package/dist/@aurochs-ui/pptx-editor/src/viewer/PresentationSlideshow.d.ts +2 -1
- package/dist/_shared/ast-DfQbpmBT.js +142 -0
- package/dist/_shared/ast-DfQbpmBT.js.map +1 -0
- package/dist/_shared/base64-URC2Sqos.js +59 -0
- package/dist/_shared/base64-URC2Sqos.js.map +1 -0
- package/dist/_shared/{zip-package-DLd0tWWj.js → browser-qN8oXU2Q.js} +53 -122
- package/dist/_shared/browser-qN8oXU2Q.js.map +1 -0
- package/dist/_shared/{chevron-right-BJHipt_f.js → chevron-right-B-4z964l.js} +2 -2
- package/dist/_shared/{chevron-right-BJHipt_f.js.map → chevron-right-B-4z964l.js.map} +1 -1
- package/dist/_shared/{convert-DJMXAtAJ.js → convert-uykpWnhR.js} +6 -6
- package/dist/_shared/{convert-DJMXAtAJ.js.map → convert-uykpWnhR.js.map} +1 -1
- package/dist/_shared/{createLucideIcon-xRsRdX2P.js → createLucideIcon-B08fYeNP.js} +3 -3
- package/dist/_shared/{createLucideIcon-xRsRdX2P.js.map → createLucideIcon-B08fYeNP.js.map} +1 -1
- package/dist/_shared/data-url-DdLBARsU.js +9 -0
- package/dist/_shared/data-url-DdLBARsU.js.map +1 -0
- package/dist/_shared/{ecma376-defaults-BaiwD4Mi.js → ecma376-defaults-B_EPt6r3.js} +19 -19
- package/dist/_shared/{ecma376-defaults-BaiwD4Mi.js.map → ecma376-defaults-B_EPt6r3.js.map} +1 -1
- package/dist/_shared/{font-metrics-DSzIt0sY.js → font-metrics-Dh7YMBW3.js} +4 -4
- package/dist/_shared/{font-metrics-DSzIt0sY.js.map → font-metrics-Dh7YMBW3.js.map} +1 -1
- package/dist/_shared/{format-value-BY_IxerR.js → format-value-BLMLaYwD.js} +11 -5
- package/dist/_shared/format-value-BLMLaYwD.js.map +1 -0
- package/dist/_shared/ooxml-relationship-types-DQiZ2OP5.js +56 -0
- package/dist/_shared/ooxml-relationship-types-DQiZ2OP5.js.map +1 -0
- package/dist/_shared/pdf-parser-CKdfZw6N.js +22026 -0
- package/dist/_shared/pdf-parser-CKdfZw6N.js.map +1 -0
- package/dist/_shared/pixel-converter-CZA35Cbw.js +296 -0
- package/dist/_shared/pixel-converter-CZA35Cbw.js.map +1 -0
- package/dist/_shared/{primitive-Celk0G8F.js → primitive-DYuL9EYz.js} +22 -22
- package/dist/_shared/{primitive-Celk0G8F.js.map → primitive-DYuL9EYz.js.map} +1 -1
- package/dist/_shared/{parser-D_MBToTH.js → relationships-DC6KdkEG.js} +64 -140
- package/dist/_shared/relationships-DC6KdkEG.js.map +1 -0
- package/dist/_shared/render-options-BTlnraZC.js +186 -0
- package/dist/_shared/render-options-BTlnraZC.js.map +1 -0
- package/dist/_shared/{slide-parser-D5oTU9ve.js → slide-parser-C2Y9L7A2.js} +31 -242
- package/dist/_shared/slide-parser-C2Y9L7A2.js.map +1 -0
- package/dist/_shared/{svg-renderer-DBcdqxSA.js → svg-renderer-CyKiUdhI.js} +2 -2
- package/dist/_shared/{svg-renderer-DBcdqxSA.js.map → svg-renderer-CyKiUdhI.js.map} +1 -1
- package/dist/_shared/{table-renderer-D7PeipiI.js → table-renderer-CLaF2bKq.js} +4 -4
- package/dist/_shared/{table-renderer-D7PeipiI.js.map → table-renderer-CLaF2bKq.js.map} +1 -1
- package/dist/_shared/text-utils-692dk1b9.js +56 -0
- package/dist/_shared/text-utils-692dk1b9.js.map +1 -0
- package/dist/_shared/text-utils-BI7wkMv4.js +32 -0
- package/dist/_shared/text-utils-BI7wkMv4.js.map +1 -0
- package/dist/_shared/text-utils-BfgYeV22.js +36 -0
- package/dist/_shared/text-utils-BfgYeV22.js.map +1 -0
- package/dist/_shared/{units-DznQ-uY-.js → units-BFfIi3jE.js} +3 -3
- package/dist/_shared/{units-DznQ-uY-.js.map → units-BFfIi3jE.js.map} +1 -1
- package/dist/_shared/{useViewerKeyboard-ccPtrGiy.js → useViewerKeyboard-Cp1JLn4C.js} +2 -2
- package/dist/_shared/{useViewerKeyboard-ccPtrGiy.js.map → useViewerKeyboard-Cp1JLn4C.js.map} +1 -1
- package/dist/_shared/zip-package-BukTqa9g.js +125 -0
- package/dist/_shared/zip-package-BukTqa9g.js.map +1 -0
- package/dist/cli.js +99770 -72137
- package/dist/docx/extract/index.js +70 -0
- package/dist/docx/extract/index.js.map +1 -0
- package/dist/docx/parser/index.js +133 -96
- package/dist/docx/parser/index.js.map +1 -1
- package/dist/docx/renderer/ascii/index.js +1 -1
- package/dist/docx/renderer/svg/index.js +7 -25021
- package/dist/docx/renderer/svg/index.js.map +1 -1
- package/dist/docx/viewer/index.js +5 -5
- package/dist/pdf/builder/index.js +1232 -0
- package/dist/pdf/builder/index.js.map +1 -0
- package/dist/pdf/parser/index.js +44 -0
- package/dist/pdf/parser/index.js.map +1 -0
- package/dist/pdf/renderer/react/index.js +44 -0
- package/dist/pdf/renderer/react/index.js.map +1 -0
- package/dist/pdf/renderer/svg/index.js +591 -0
- package/dist/pdf/renderer/svg/index.js.map +1 -0
- package/dist/pdf/writer/index.js +1175 -0
- package/dist/pdf/writer/index.js.map +1 -0
- package/dist/pptx/extract/index.js +83 -0
- package/dist/pptx/extract/index.js.map +1 -0
- package/dist/pptx/parser/index.js +13 -6
- package/dist/pptx/parser/index.js.map +1 -1
- package/dist/pptx/renderer/ascii/index.js +1 -1
- package/dist/pptx/renderer/svg/index.js +10 -43
- package/dist/pptx/renderer/svg/index.js.map +1 -1
- package/dist/pptx/viewer/index.js +4 -3
- package/dist/pptx/viewer/index.js.map +1 -1
- package/dist/xlsx/extract/index.js +45 -0
- package/dist/xlsx/extract/index.js.map +1 -0
- package/dist/xlsx/parser/index.js +46 -25
- package/dist/xlsx/parser/index.js.map +1 -1
- package/dist/xlsx/renderer/svg/index.js +2 -2
- package/dist/xlsx/viewer/index.js +3 -3
- package/package.json +33 -1
- package/dist/_shared/format-value-BY_IxerR.js.map +0 -1
- package/dist/_shared/parser-D_MBToTH.js.map +0 -1
- package/dist/_shared/slide-parser-D5oTU9ve.js.map +0 -1
- package/dist/_shared/zip-package-DLd0tWWj.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PdfColorSpace, PdfAlternateColorSpace } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Get number of components for a color space
|
|
4
|
+
*
|
|
5
|
+
* PDF Reference 8.6:
|
|
6
|
+
* - DeviceGray: 1 component
|
|
7
|
+
* - DeviceRGB: 3 components
|
|
8
|
+
* - DeviceCMYK: 4 components
|
|
9
|
+
* - ICCBased: Determined by N value (or alternateColorSpace)
|
|
10
|
+
* - Pattern: 0 components
|
|
11
|
+
*/
|
|
12
|
+
export declare function getColorSpaceComponents(colorSpace: PdfColorSpace, alternateColorSpace?: PdfAlternateColorSpace): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file PDF color domain
|
|
3
|
+
*
|
|
4
|
+
* Exports types and utilities for PDF color handling.
|
|
5
|
+
*/
|
|
6
|
+
export type { PdfColorSpace, PdfAlternateColorSpace, PdfColor } from './types';
|
|
7
|
+
export { getColorSpaceComponents } from './color-space';
|
|
8
|
+
export type { RgbColor } from './primitives';
|
|
9
|
+
export { grayToRgb, rgbToRgbBytes, cmykToRgb, rgbToHex, clamp01, clampByte, toByte, } from './primitives';
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Color conversion primitives
|
|
3
|
+
*
|
|
4
|
+
* Basic color conversion algorithms for PDF color spaces.
|
|
5
|
+
* These are pure functions operating on normalized values (0-1 range).
|
|
6
|
+
*
|
|
7
|
+
* Note: These are naive conversions without ICC profile support.
|
|
8
|
+
* For accurate color reproduction, ICC profile parsing would be required.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* RGB color tuple (0-255 range)
|
|
12
|
+
*/
|
|
13
|
+
export type RgbColor = readonly [r: number, g: number, b: number];
|
|
14
|
+
/**
|
|
15
|
+
* Convert grayscale to RGB
|
|
16
|
+
*
|
|
17
|
+
* PDF Reference 8.6.4.2: DeviceGray uses 1 component (0=black, 1=white)
|
|
18
|
+
*
|
|
19
|
+
* @param gray - Grayscale value (0-1)
|
|
20
|
+
* @returns RGB tuple (0-255)
|
|
21
|
+
*/
|
|
22
|
+
export declare function grayToRgb(gray: number): RgbColor;
|
|
23
|
+
/**
|
|
24
|
+
* Convert RGB components to RGB bytes
|
|
25
|
+
*
|
|
26
|
+
* PDF Reference 8.6.4.3: DeviceRGB uses 3 components (R, G, B in 0-1 range)
|
|
27
|
+
*
|
|
28
|
+
* @param r - Red (0-1)
|
|
29
|
+
* @param g - Green (0-1)
|
|
30
|
+
* @param b - Blue (0-1)
|
|
31
|
+
* @returns RGB tuple (0-255)
|
|
32
|
+
*/
|
|
33
|
+
export declare function rgbToRgbBytes(r: number, g: number, b: number): RgbColor;
|
|
34
|
+
/**
|
|
35
|
+
* Convert CMYK to RGB using naive linear conversion.
|
|
36
|
+
*
|
|
37
|
+
* ## Formula
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
* R = 255 × (1 - C) × (1 - K)
|
|
41
|
+
* G = 255 × (1 - M) × (1 - K)
|
|
42
|
+
* B = 255 × (1 - Y) × (1 - K)
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* ## Limitations
|
|
46
|
+
*
|
|
47
|
+
* This is a **naive conversion** that does NOT account for:
|
|
48
|
+
*
|
|
49
|
+
* 1. **ICC Profiles**: Professional print PDFs use calibrated CMYK
|
|
50
|
+
* (e.g., FOGRA39, US Web Coated SWOP) which have non-linear
|
|
51
|
+
* relationships with sRGB.
|
|
52
|
+
*
|
|
53
|
+
* 2. **Color Gamut**: CMYK and sRGB have different color gamuts.
|
|
54
|
+
* Some CMYK colors cannot be accurately represented in sRGB.
|
|
55
|
+
*
|
|
56
|
+
* 3. **Black Generation**: The relationship between CMY and K
|
|
57
|
+
* varies by printing process (GCR, UCR).
|
|
58
|
+
*
|
|
59
|
+
* ## When Accuracy Matters
|
|
60
|
+
*
|
|
61
|
+
* For accurate CMYK→RGB conversion, use:
|
|
62
|
+
* - A color management library (e.g., lcms2, ColorSync)
|
|
63
|
+
* - The PDF's embedded ICC profile
|
|
64
|
+
* - A standard print profile (FOGRA39, SWOP, etc.)
|
|
65
|
+
*
|
|
66
|
+
* ## Typical Inaccuracies
|
|
67
|
+
*
|
|
68
|
+
* | CMYK Input | This Function | Accurate sRGB |
|
|
69
|
+
* |-----------------|---------------|---------------|
|
|
70
|
+
* | C=100 M=0 Y=0 | (0, 255, 255) | ~(0, 174, 239)|
|
|
71
|
+
* | C=0 M=100 Y=0 | (255, 0, 255) | ~(236, 0, 140)|
|
|
72
|
+
* | C=0 M=0 Y=100 | (255, 255, 0) | ~(255, 242, 0)|
|
|
73
|
+
*
|
|
74
|
+
* @see PDF Reference 1.7, Section 8.6.4.4 (DeviceCMYK Color Space)
|
|
75
|
+
* @see ISO 12647-2 (Offset printing)
|
|
76
|
+
*
|
|
77
|
+
* @param c - Cyan (0-1)
|
|
78
|
+
* @param m - Magenta (0-1)
|
|
79
|
+
* @param y - Yellow (0-1)
|
|
80
|
+
* @param k - Key/Black (0-1)
|
|
81
|
+
* @returns RGB tuple (0-255)
|
|
82
|
+
*/
|
|
83
|
+
export declare function cmykToRgb({ c, m, y, k, }: {
|
|
84
|
+
readonly c: number;
|
|
85
|
+
readonly m: number;
|
|
86
|
+
readonly y: number;
|
|
87
|
+
readonly k: number;
|
|
88
|
+
}): RgbColor;
|
|
89
|
+
/**
|
|
90
|
+
* Convert RGB to hex string
|
|
91
|
+
*
|
|
92
|
+
* @param r - Red (0-255)
|
|
93
|
+
* @param g - Green (0-255)
|
|
94
|
+
* @param b - Blue (0-255)
|
|
95
|
+
* @returns Hex string (e.g., "FF00FF")
|
|
96
|
+
*/
|
|
97
|
+
export declare function rgbToHex(r: number, g: number, b: number): string;
|
|
98
|
+
/**
|
|
99
|
+
* Clamp value to 0-1 range
|
|
100
|
+
*/
|
|
101
|
+
export declare function clamp01(value: number): number;
|
|
102
|
+
/**
|
|
103
|
+
* Clamp value to 0-255 range
|
|
104
|
+
*/
|
|
105
|
+
export declare function clampByte(value: number): number;
|
|
106
|
+
/**
|
|
107
|
+
* Convert 0-1 component to 0-255 byte
|
|
108
|
+
*/
|
|
109
|
+
export declare function toByte(component01: number): number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file PDF-related constants
|
|
3
|
+
*
|
|
4
|
+
* Contains constants used in PDF parsing and conversion.
|
|
5
|
+
* All values are derived from official specifications.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Conversion factor from PDF points to CSS pixels.
|
|
9
|
+
*
|
|
10
|
+
* Derivation:
|
|
11
|
+
* - PDF Reference 1.7, Appendix C.2: 1 point = 1/72 inch
|
|
12
|
+
* - CSS Values and Units Module Level 3: 1px = 1/96 inch (reference pixel)
|
|
13
|
+
* - Therefore: 1pt = (1/72) inch × (96 px/inch) = 96/72 px ≈ 1.333px
|
|
14
|
+
*
|
|
15
|
+
* Note: This is the standard CSS reference pixel at 96 DPI.
|
|
16
|
+
* The actual physical size depends on the device's pixel density.
|
|
17
|
+
*/
|
|
18
|
+
export declare const PT_TO_PX: number;
|
|
19
|
+
/**
|
|
20
|
+
* Conversion factor from CSS pixels to PDF points.
|
|
21
|
+
*
|
|
22
|
+
* Inverse of PT_TO_PX.
|
|
23
|
+
*/
|
|
24
|
+
export declare const PX_TO_PT: number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file PDF content stream tokenizer
|
|
3
|
+
*
|
|
4
|
+
* Parses PDF content stream into tokens for further processing.
|
|
5
|
+
* PDF Reference Chapter 7 - Content Stream Syntax
|
|
6
|
+
*
|
|
7
|
+
* Content stream elements:
|
|
8
|
+
* - Numbers: 123, -45.67, .5
|
|
9
|
+
* - Strings: (Hello), <48656C6C6F>
|
|
10
|
+
* - Names: /Name
|
|
11
|
+
* - Operators: m, l, c, S, f, BT, ET, etc.
|
|
12
|
+
* - Arrays: [...]
|
|
13
|
+
* - Dictionaries: <<...>>
|
|
14
|
+
*/
|
|
15
|
+
export type PdfTokenType = "number" | "string" | "name" | "operator" | "array_start" | "array_end" | "dict_start" | "dict_end";
|
|
16
|
+
export type PdfToken = {
|
|
17
|
+
readonly type: PdfTokenType;
|
|
18
|
+
readonly value: string | number;
|
|
19
|
+
readonly raw: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Tokenize a PDF content stream
|
|
23
|
+
*/
|
|
24
|
+
export declare function tokenizeContentStream(content: string): PdfToken[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file PDF coordinate domain
|
|
3
|
+
*
|
|
4
|
+
* Exports types and utilities for PDF coordinate system handling.
|
|
5
|
+
*/
|
|
6
|
+
export type { PdfPoint, PdfBBox, PdfMatrix } from './types';
|
|
7
|
+
export { IDENTITY_MATRIX, multiplyMatrices, transformPoint, invertMatrix, translationMatrix, scalingMatrix, rotationMatrix, isIdentityMatrix, isSimpleTransform, getMatrixScale, getMatrixRotation, decomposeMatrix, hasShear, } from './matrix';
|
|
8
|
+
export type { MatrixDecomposition } from './matrix';
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { PdfMatrix, PdfPoint } from './types';
|
|
2
|
+
export declare const IDENTITY_MATRIX: PdfMatrix;
|
|
3
|
+
/**
|
|
4
|
+
* Multiply two transformation matrices
|
|
5
|
+
* Result = a * b
|
|
6
|
+
*/
|
|
7
|
+
export declare function multiplyMatrices(a: PdfMatrix, b: PdfMatrix): PdfMatrix;
|
|
8
|
+
/**
|
|
9
|
+
* Transform a point by a matrix
|
|
10
|
+
*/
|
|
11
|
+
export declare function transformPoint(point: PdfPoint, matrix: PdfMatrix): PdfPoint;
|
|
12
|
+
/**
|
|
13
|
+
* Calculate the inverse of a matrix
|
|
14
|
+
* Returns null if matrix is singular
|
|
15
|
+
*/
|
|
16
|
+
export declare function invertMatrix(matrix: PdfMatrix): PdfMatrix | null;
|
|
17
|
+
/**
|
|
18
|
+
* Create a translation matrix
|
|
19
|
+
*/
|
|
20
|
+
export declare function translationMatrix(tx: number, ty: number): PdfMatrix;
|
|
21
|
+
/**
|
|
22
|
+
* Create a scaling matrix
|
|
23
|
+
*/
|
|
24
|
+
export declare function scalingMatrix(sx: number, sy: number): PdfMatrix;
|
|
25
|
+
/**
|
|
26
|
+
* Create a rotation matrix (angle in radians)
|
|
27
|
+
*/
|
|
28
|
+
export declare function rotationMatrix(angle: number): PdfMatrix;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a matrix is (approximately) the identity matrix
|
|
31
|
+
*/
|
|
32
|
+
export declare function isIdentityMatrix(matrix: PdfMatrix): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a matrix contains only scale and translation (no rotation/skew)
|
|
35
|
+
*/
|
|
36
|
+
export declare function isSimpleTransform(matrix: PdfMatrix): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Extract scale factors from a matrix
|
|
39
|
+
*/
|
|
40
|
+
export declare function getMatrixScale(matrix: PdfMatrix): {
|
|
41
|
+
scaleX: number;
|
|
42
|
+
scaleY: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Extract rotation angle from a matrix (in radians)
|
|
46
|
+
*/
|
|
47
|
+
export declare function getMatrixRotation(matrix: PdfMatrix): number;
|
|
48
|
+
/**
|
|
49
|
+
* Complete matrix decomposition result
|
|
50
|
+
*/
|
|
51
|
+
export type MatrixDecomposition = {
|
|
52
|
+
readonly scaleX: number;
|
|
53
|
+
readonly scaleY: number;
|
|
54
|
+
readonly rotation: number;
|
|
55
|
+
readonly shearX: number;
|
|
56
|
+
readonly shearY: number;
|
|
57
|
+
readonly translateX: number;
|
|
58
|
+
readonly translateY: number;
|
|
59
|
+
readonly isSimple: boolean;
|
|
60
|
+
readonly hasRotation: boolean;
|
|
61
|
+
readonly hasScale: boolean;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Decompose a transformation matrix into its components
|
|
65
|
+
*
|
|
66
|
+
* A 2D affine transformation matrix [a, b, c, d, e, f] can be decomposed as:
|
|
67
|
+
* - Translation: (e, f)
|
|
68
|
+
* - Rotation: atan2(b, a)
|
|
69
|
+
* - Scale: (scaleX, scaleY)
|
|
70
|
+
* - Shear: shearX, shearY
|
|
71
|
+
*
|
|
72
|
+
* The matrix represents: [scaleX*cos(r) + shearY*sin(r), scaleX*sin(r) - shearY*cos(r),
|
|
73
|
+
* shearX*cos(r) + scaleY*sin(r), shearX*sin(r) - scaleY*cos(r), e, f]
|
|
74
|
+
*
|
|
75
|
+
* For shear detection, we check if the matrix can be represented as pure scale + rotation
|
|
76
|
+
*/
|
|
77
|
+
export declare function decomposeMatrix(matrix: PdfMatrix): MatrixDecomposition;
|
|
78
|
+
/**
|
|
79
|
+
* Check if a matrix has shear (skew) transformation
|
|
80
|
+
*/
|
|
81
|
+
export declare function hasShear(matrix: PdfMatrix): boolean;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { PdfImage } from '../image';
|
|
2
|
+
import { PdfPath } from '../path';
|
|
3
|
+
import { PdfText } from '../text';
|
|
4
|
+
export type PdfElement = PdfPath | PdfText | PdfImage;
|
|
5
|
+
/**
|
|
6
|
+
* Represents a parsed PDF page.
|
|
7
|
+
*
|
|
8
|
+
* ## Coordinate System
|
|
9
|
+
*
|
|
10
|
+
* PDF uses a coordinate system where:
|
|
11
|
+
* - Origin is at the bottom-left corner
|
|
12
|
+
* - X increases to the right
|
|
13
|
+
* - Y increases upward
|
|
14
|
+
* - Default unit is the "point" (1 point = 1/72 inch)
|
|
15
|
+
*
|
|
16
|
+
* @see PDF Reference 1.7, Section 4.2 (Coordinate Systems)
|
|
17
|
+
*/
|
|
18
|
+
export type PdfPage = {
|
|
19
|
+
/**
|
|
20
|
+
* 1-indexed page number.
|
|
21
|
+
*/
|
|
22
|
+
readonly pageNumber: number;
|
|
23
|
+
/**
|
|
24
|
+
* Page width in PDF points (1 point = 1/72 inch).
|
|
25
|
+
*
|
|
26
|
+
* Common values:
|
|
27
|
+
* - A4 portrait: 595.28 points (210mm)
|
|
28
|
+
* - A4 landscape: 841.89 points (297mm)
|
|
29
|
+
* - US Letter portrait: 612 points (8.5 inches)
|
|
30
|
+
* - US Letter landscape: 792 points (11 inches)
|
|
31
|
+
*/
|
|
32
|
+
readonly width: number;
|
|
33
|
+
/**
|
|
34
|
+
* Page height in PDF points (1 point = 1/72 inch).
|
|
35
|
+
*
|
|
36
|
+
* Common values:
|
|
37
|
+
* - A4 portrait: 841.89 points (297mm)
|
|
38
|
+
* - A4 landscape: 595.28 points (210mm)
|
|
39
|
+
* - US Letter portrait: 792 points (11 inches)
|
|
40
|
+
* - US Letter landscape: 612 points (8.5 inches)
|
|
41
|
+
*/
|
|
42
|
+
readonly height: number;
|
|
43
|
+
/**
|
|
44
|
+
* Visual elements on this page (text, paths, images).
|
|
45
|
+
*/
|
|
46
|
+
readonly elements: readonly PdfElement[];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Embedded font data extracted from PDF.
|
|
50
|
+
*
|
|
51
|
+
* @see ISO 32000-1:2008 Section 9.9 (Embedded Font Programs)
|
|
52
|
+
*/
|
|
53
|
+
export type PdfEmbeddedFont = {
|
|
54
|
+
/** Font family name (e.g., "Hiragino Sans") */
|
|
55
|
+
readonly fontFamily: string;
|
|
56
|
+
/** Font format */
|
|
57
|
+
readonly format: "opentype" | "truetype" | "type1" | "cff";
|
|
58
|
+
/** Raw font data */
|
|
59
|
+
readonly data: Uint8Array;
|
|
60
|
+
/** MIME type */
|
|
61
|
+
readonly mimeType: string;
|
|
62
|
+
};
|
|
63
|
+
export type PdfDocument = {
|
|
64
|
+
readonly pages: readonly PdfPage[];
|
|
65
|
+
readonly metadata?: {
|
|
66
|
+
readonly title?: string;
|
|
67
|
+
readonly author?: string;
|
|
68
|
+
readonly subject?: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Embedded fonts extracted from PDF.
|
|
72
|
+
* Only present if PDF contains embedded font programs.
|
|
73
|
+
*/
|
|
74
|
+
readonly embeddedFonts?: readonly PdfEmbeddedFont[];
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* PDF coordinate system unit conversions.
|
|
78
|
+
*
|
|
79
|
+
* PDF "user space" default unit is the point: 1 point = 1/72 inch.
|
|
80
|
+
*/
|
|
81
|
+
export declare const PDF_UNITS: {
|
|
82
|
+
/**
|
|
83
|
+
* Points per inch (PDF default unit).
|
|
84
|
+
* 1 inch = 72 points.
|
|
85
|
+
*/
|
|
86
|
+
readonly POINTS_PER_INCH: 72;
|
|
87
|
+
/**
|
|
88
|
+
* Points per millimeter.
|
|
89
|
+
* 1mm ≈ 2.8346 points.
|
|
90
|
+
*/
|
|
91
|
+
readonly POINTS_PER_MM: number;
|
|
92
|
+
/**
|
|
93
|
+
* Convert PDF points to inches.
|
|
94
|
+
*/
|
|
95
|
+
readonly pointsToInches: (points: number) => number;
|
|
96
|
+
/**
|
|
97
|
+
* Convert PDF points to millimeters.
|
|
98
|
+
*/
|
|
99
|
+
readonly pointsToMm: (points: number) => number;
|
|
100
|
+
/**
|
|
101
|
+
* Convert inches to PDF points.
|
|
102
|
+
*/
|
|
103
|
+
readonly inchesToPoints: (inches: number) => number;
|
|
104
|
+
/**
|
|
105
|
+
* Convert millimeters to PDF points.
|
|
106
|
+
*/
|
|
107
|
+
readonly mmToPoints: (mm: number) => number;
|
|
108
|
+
};
|
|
109
|
+
/** Type guard for `PdfPath` elements. */
|
|
110
|
+
export declare function isPdfPath(element: PdfElement): element is PdfPath;
|
|
111
|
+
/** Type guard for `PdfText` elements. */
|
|
112
|
+
export declare function isPdfText(element: PdfElement): element is PdfText;
|
|
113
|
+
/** Type guard for `PdfImage` elements. */
|
|
114
|
+
export declare function isPdfImage(element: PdfElement): element is PdfImage;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Minimal CFF CID-keyed charset parser.
|
|
3
|
+
*/
|
|
4
|
+
type CffCidCharsetParseResult = Readonly<{
|
|
5
|
+
gidToCid: ReadonlyMap<number, number>;
|
|
6
|
+
glyphCount: number;
|
|
7
|
+
ros?: Readonly<{
|
|
8
|
+
registrySid: number;
|
|
9
|
+
orderingSid: number;
|
|
10
|
+
supplement: number;
|
|
11
|
+
registry?: string;
|
|
12
|
+
ordering?: string;
|
|
13
|
+
}>;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Parse CID-keyed CFF bytes and extract GID->CID map from charset.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseCffCidCharset(fontData: Uint8Array): CffCidCharsetParseResult | null;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Adobe-Japan1 CID → Unicode mapping (embedded)
|
|
3
|
+
*
|
|
4
|
+
* This table is generated from Poppler's "cidToUnicode/Adobe-Japan1" data file
|
|
5
|
+
* (Adobe-Japan1-7 character collection).
|
|
6
|
+
*
|
|
7
|
+
* License (from the upstream CMap resources / Poppler data):
|
|
8
|
+
* - Copyright 1990-2022 Adobe. All rights reserved.
|
|
9
|
+
* - Redistribution and use in source and binary forms, with or without modification,
|
|
10
|
+
* are permitted subject to the license terms included in Adobe's CMap resources.
|
|
11
|
+
*/
|
|
12
|
+
/** Decode an Adobe-Japan1 CID to its corresponding Unicode string. */
|
|
13
|
+
export declare function decodeAdobeJapan1CidToUnicode(cid: number): string | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CIDOrdering } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* CID-to-Unicode fallback mapping
|
|
4
|
+
*/
|
|
5
|
+
export type CIDFallbackMapping = ReadonlyMap<number, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Get fallback mapping for a given CID ordering
|
|
8
|
+
*
|
|
9
|
+
* Returns a combined mapping of ASCII range plus ordering-specific mappings.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getCIDFallbackMapping(ordering: CIDOrdering): CIDFallbackMapping;
|
|
12
|
+
/**
|
|
13
|
+
* Detect CID ordering from font ordering string
|
|
14
|
+
*
|
|
15
|
+
* The Ordering string in CIDSystemInfo typically contains the ordering name.
|
|
16
|
+
*
|
|
17
|
+
* - Adobe character collections: Japan1, GB1, CNS1, Korea1 (provide script type)
|
|
18
|
+
* - Identity: Modern generic encoding (no script type info, ISO 32000-1 Section 9.7.5)
|
|
19
|
+
*/
|
|
20
|
+
export declare function detectCIDOrdering(ordering: string): CIDOrdering | null;
|
|
21
|
+
/**
|
|
22
|
+
* Try to decode a CID using fallback mapping
|
|
23
|
+
*
|
|
24
|
+
* Returns the Unicode character if found, or null if no mapping exists.
|
|
25
|
+
*/
|
|
26
|
+
export declare function decodeCIDFallback(cid: number, ordering: CIDOrdering | null): string | null;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { FontMapping } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Diagnostics captured while parsing ToUnicode CMaps.
|
|
4
|
+
*/
|
|
5
|
+
export type CMapParseDiagnostics = {
|
|
6
|
+
/** Number of malformed entries ignored during parsing. */
|
|
7
|
+
readonly invalidEntryCount: number;
|
|
8
|
+
/** Number of `bfrange` entries truncated by configured limits. */
|
|
9
|
+
readonly truncatedRangeCount: number;
|
|
10
|
+
/** Number of mappings whose source-byte length is outside declared codespace lengths. */
|
|
11
|
+
readonly sourceLengthOutsideCodeSpaceCount: number;
|
|
12
|
+
/** Number of final mappings whose destination contains U+FFFD. */
|
|
13
|
+
readonly replacementCharMapCount: number;
|
|
14
|
+
/** Number of final mappings whose destination contains private-use characters. */
|
|
15
|
+
readonly privateUseCharMapCount: number;
|
|
16
|
+
/** Final mapping counts grouped by source code byte length. */
|
|
17
|
+
readonly sourceCodeLengthHistogram: ReadonlyMap<number, number>;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* CMap parse result containing mapping, source code metadata, and diagnostics.
|
|
21
|
+
*/
|
|
22
|
+
export type CMapParseResult = {
|
|
23
|
+
/** Legacy numeric mapping used by existing single-byte / two-byte decoders. */
|
|
24
|
+
readonly mapping: FontMapping;
|
|
25
|
+
/** Exact source-byte mapping. Key is uppercase hex without separators (e.g. `8140`). */
|
|
26
|
+
readonly byteMapping: ReadonlyMap<string, string>;
|
|
27
|
+
/** Source code byte lengths observed from mappings and codespace ranges (descending). */
|
|
28
|
+
readonly sourceCodeByteLengths: readonly number[];
|
|
29
|
+
/**
|
|
30
|
+
* Legacy byte-width hint used by existing layout code.
|
|
31
|
+
* Kept as 1|2 for backward compatibility.
|
|
32
|
+
*/
|
|
33
|
+
readonly codeByteWidth: 1 | 2;
|
|
34
|
+
readonly diagnostics: CMapParseDiagnostics;
|
|
35
|
+
};
|
|
36
|
+
export type CMapParserOptions = {
|
|
37
|
+
/**
|
|
38
|
+
* Maximum entries generated from one `bfrange` statement.
|
|
39
|
+
*
|
|
40
|
+
* Default: 65536 (full 2-byte CID space).
|
|
41
|
+
*/
|
|
42
|
+
readonly maxRangeEntries?: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Parse ToUnicode CMap data and detect source code lengths.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseToUnicodeCMap(data: string, options?: CMapParserOptions): CMapParseResult;
|
|
48
|
+
/**
|
|
49
|
+
* Parse beginbfchar sections.
|
|
50
|
+
* Format: `<source> <destination>`
|
|
51
|
+
* Returns maximum source hex length found.
|
|
52
|
+
*/
|
|
53
|
+
export declare function parseBfChar(data: string, mapping: FontMapping): number;
|
|
54
|
+
/**
|
|
55
|
+
* Parse beginbfrange sections.
|
|
56
|
+
* Format: `<start> <end> <destStart>` or `<start> <end> [<dest1> <dest2> ...]`
|
|
57
|
+
* Returns maximum source hex length found.
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseBfRange(data: string, mapping: FontMapping, options?: CMapParserOptions): number;
|
|
60
|
+
/**
|
|
61
|
+
* Convert destination hex string to Unicode string.
|
|
62
|
+
* Destination is interpreted as UTF-16BE code units.
|
|
63
|
+
*/
|
|
64
|
+
export declare function hexToString(hex: string): string | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file CID -> Unicode supplemental fallback mapping helpers.
|
|
3
|
+
*/
|
|
4
|
+
export type CidToGidMapping = {
|
|
5
|
+
readonly kind: "identity";
|
|
6
|
+
} | {
|
|
7
|
+
readonly kind: "table";
|
|
8
|
+
readonly bytes: Uint8Array;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Extract glyphId -> Unicode map from raw cmap table bytes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractGlyphIdToUnicodeFromCmapTable(cmapTable: Uint8Array): ReadonlyMap<number, string>;
|
|
14
|
+
/**
|
|
15
|
+
* Extract glyphId -> Unicode map from a TrueType/OpenType font program.
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractGlyphIdToUnicodeFromTrueTypeLikeFont(fontData: Uint8Array): ReadonlyMap<number, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Build CID code -> Unicode fallback map from CIDToGID mapping and glyph cmap.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildCidCodeToUnicodeFallbackMap(args: {
|
|
22
|
+
readonly cidToGid: CidToGidMapping;
|
|
23
|
+
readonly glyphIdToUnicode: ReadonlyMap<number, string>;
|
|
24
|
+
}): ReadonlyMap<number, string>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FontInfo, FontMappings } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Decode text using font mapping
|
|
4
|
+
*/
|
|
5
|
+
export declare function decodeText(rawText: string, fontName: string, mappings: FontMappings): string;
|
|
6
|
+
/** Decode raw PDF text string using font encoding and mapping information. */
|
|
7
|
+
export declare function decodeTextWithFontInfo(rawText: string, fontInfo: FontInfo): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FontMetrics } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Default font metrics when no font information is available
|
|
4
|
+
*
|
|
5
|
+
* PDF Reference 5.2.3, 5.7.1:
|
|
6
|
+
* Font metrics are expressed in units of 1/1000 of the em-square.
|
|
7
|
+
* The em-square is traditionally 1000 units for most fonts.
|
|
8
|
+
*
|
|
9
|
+
* Default values are based on common Latin font metrics:
|
|
10
|
+
* - PDF standard 14 fonts (Helvetica, Times, Courier) have:
|
|
11
|
+
* - Helvetica: ascender ~718, descender ~-207
|
|
12
|
+
* - Times-Roman: ascender ~683, descender ~-217
|
|
13
|
+
* - Courier: ascender ~629, descender ~-157
|
|
14
|
+
*
|
|
15
|
+
* - We use slightly larger defaults (800/-200) to accommodate:
|
|
16
|
+
* - Fonts with taller ascenders (many display fonts)
|
|
17
|
+
* - CJK fonts which often extend higher
|
|
18
|
+
* - Conservative estimates that avoid clipping
|
|
19
|
+
*
|
|
20
|
+
* Total glyph height = ascender - descender = 800 - (-200) = 1000 units
|
|
21
|
+
* This matches the standard em-square size.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DEFAULT_FONT_METRICS: FontMetrics;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file PDF Font Encoding Maps
|
|
3
|
+
*
|
|
4
|
+
* Standard character encodings used in PDF fonts (ISO 32000-1, Annex D).
|
|
5
|
+
* These mappings convert single-byte character codes to Unicode strings.
|
|
6
|
+
*
|
|
7
|
+
* PDF supports several predefined encodings:
|
|
8
|
+
* - WinAnsiEncoding: Windows code page 1252 (most common for Western PDFs)
|
|
9
|
+
* - MacRomanEncoding: Mac OS Roman character set
|
|
10
|
+
* - StandardEncoding: Adobe Standard Encoding (PostScript Type 1 default)
|
|
11
|
+
*
|
|
12
|
+
* When a font has an /Encoding entry with one of these names, the corresponding
|
|
13
|
+
* mapping is used instead of ToUnicode CMap for character decoding.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* WinAnsiEncoding (Windows Code Page 1252)
|
|
17
|
+
*
|
|
18
|
+
* Most commonly used encoding for Western PDFs created on Windows.
|
|
19
|
+
* ISO 32000-1, Annex D, Table D.1
|
|
20
|
+
*
|
|
21
|
+
* Character codes 0x00-0x1F and 0x7F are control characters (pass through).
|
|
22
|
+
* Character codes 0x80-0x9F contain special characters (Euro, quotes, etc.).
|
|
23
|
+
*/
|
|
24
|
+
export declare const WINANSI_ENCODING: ReadonlyMap<number, string>;
|
|
25
|
+
/**
|
|
26
|
+
* MacRomanEncoding (Mac OS Roman)
|
|
27
|
+
*
|
|
28
|
+
* Character encoding used on classic Mac OS systems.
|
|
29
|
+
* ISO 32000-1, Annex D, Table D.2
|
|
30
|
+
*/
|
|
31
|
+
export declare const MACROMAN_ENCODING: ReadonlyMap<number, string>;
|
|
32
|
+
/**
|
|
33
|
+
* StandardEncoding (Adobe Standard Encoding)
|
|
34
|
+
*
|
|
35
|
+
* Default encoding for Type 1 fonts without explicit encoding.
|
|
36
|
+
* ISO 32000-1, Annex D, Table D.3
|
|
37
|
+
*/
|
|
38
|
+
export declare const STANDARD_ENCODING: ReadonlyMap<number, string>;
|
|
39
|
+
/**
|
|
40
|
+
* PDF Encoding type identifier
|
|
41
|
+
*/
|
|
42
|
+
export type PdfEncodingName = "WinAnsiEncoding" | "MacRomanEncoding" | "StandardEncoding";
|
|
43
|
+
/**
|
|
44
|
+
* Get an encoding map by name.
|
|
45
|
+
*
|
|
46
|
+
* @param name - The encoding name (with or without leading slash)
|
|
47
|
+
* @returns The encoding map, or undefined if not recognized
|
|
48
|
+
*/
|
|
49
|
+
export declare function getEncodingByName(name: string): ReadonlyMap<number, string> | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Apply Differences array to a base encoding map.
|
|
52
|
+
*
|
|
53
|
+
* The Differences array in PDF encoding dictionaries allows customization
|
|
54
|
+
* of character mappings. Format: [code name1 name2 ... code name ...]
|
|
55
|
+
*
|
|
56
|
+
* @param baseEncoding - The base encoding map to modify
|
|
57
|
+
* @param differences - The Differences array entries
|
|
58
|
+
* @returns A new map with the differences applied
|
|
59
|
+
*/
|
|
60
|
+
export declare function applyEncodingDifferences(baseEncoding: ReadonlyMap<number, string>, differences: readonly (number | string)[]): Map<number, string>;
|
|
61
|
+
/**
|
|
62
|
+
* Convert Adobe glyph name to Unicode string.
|
|
63
|
+
*
|
|
64
|
+
* Supports common glyph names used in PDF fonts.
|
|
65
|
+
* This is a subset of the Adobe Glyph List.
|
|
66
|
+
*
|
|
67
|
+
* @param name - The glyph name (with or without leading slash)
|
|
68
|
+
* @returns The Unicode string, or undefined if not recognized
|
|
69
|
+
*/
|
|
70
|
+
export declare function glyphNameToUnicode(name: string): string | undefined;
|