aurochs 0.10.0 → 0.12.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/@aurochs/pdf/src/domain/document/element-transform.d.ts +18 -0
- package/dist/@aurochs/pdf/src/domain/document/index.d.ts +2 -2
- package/dist/@aurochs/pdf/src/domain/document/types.d.ts +4 -2
- package/dist/@aurochs/pdf/src/domain/font/cmap/cmap-parser.d.ts +23 -0
- package/dist/@aurochs/pdf/src/domain/font/font-name-map.d.ts +9 -0
- package/dist/@aurochs/pdf/src/domain/font/font-provider.d.ts +170 -0
- package/dist/@aurochs/pdf/src/domain/font/font-style.d.ts +20 -2
- package/dist/@aurochs/pdf/src/domain/font/index.d.ts +8 -3
- package/dist/@aurochs/pdf/src/domain/font/text-encoder.d.ts +61 -0
- package/dist/@aurochs/pdf/src/domain/font/unicode-classification.d.ts +27 -0
- package/dist/@aurochs/pdf/src/domain/graphics-state/defaults.d.ts +17 -0
- package/dist/@aurochs/pdf/src/domain/graphics-state/index.d.ts +1 -1
- package/dist/@aurochs/pdf/src/domain/index.d.ts +5 -4
- package/dist/@aurochs/pdf/src/domain/text/index.d.ts +7 -0
- package/dist/@aurochs/pdf/src/domain/text/operations.d.ts +29 -0
- package/dist/@aurochs/pdf/src/image/pixel-converter.d.ts +9 -2
- package/dist/@aurochs/pdf/src/index.d.ts +3 -2
- package/dist/@aurochs/pdf/src/native/document/document.d.ts +4 -1
- package/dist/@aurochs/pdf/src/parser/color/color-space.native.d.ts +35 -2
- package/dist/@aurochs/pdf/src/parser/core/pdf-load-error.d.ts +4 -2
- package/dist/@aurochs/pdf/src/parser/core/pdf-parser.d.ts +2 -1
- package/dist/@aurochs/pdf/src/parser/core/pdf-parser.native.d.ts +45 -0
- package/dist/@aurochs/pdf/src/parser/function/evaluate.d.ts +39 -0
- package/dist/@aurochs/pdf/src/parser/function/parse.d.ts +29 -0
- package/dist/@aurochs/pdf/src/parser/operator/index.d.ts +1 -0
- package/dist/@aurochs/pdf/src/parser/operator/text-handlers.d.ts +24 -2
- package/dist/@aurochs/pdf/src/writer/content-stream/text-operators.d.ts +6 -0
- package/dist/@aurochs/pdf/src/writer/document/index.d.ts +1 -1
- package/dist/@aurochs/pdf/src/writer/document/object-tracker.d.ts +13 -32
- package/dist/@aurochs/pdf/src/writer/document/page-builder.d.ts +3 -0
- package/dist/@aurochs/pdf/src/writer/document-writer.d.ts +7 -0
- package/dist/@aurochs/pdf/src/writer/index.d.ts +1 -1
- package/dist/@aurochs-office/drawing-ml/src/domain/color-resolution.d.ts +17 -0
- package/dist/@aurochs-office/drawing-ml/src/domain/index.d.ts +1 -1
- package/dist/@aurochs-office/pptx/src/domain/defaults.d.ts +54 -0
- package/dist/@aurochs-office/pptx/src/domain/index.d.ts +1 -1
- package/dist/@aurochs-office/pptx/src/parser/slide/diagram-drawing-parser.d.ts +1 -7
- package/dist/@aurochs-office/pptx/src/parser/slide/layout-parser.d.ts +1 -0
- package/dist/@aurochs-office/xlsx/src/parser/image-resolver.d.ts +36 -0
- package/dist/@aurochs-office/xlsx/src/parser/index.d.ts +30 -0
- package/dist/@aurochs-renderer/pdf/src/react/index.d.ts +1 -0
- package/dist/@aurochs-renderer/pdf/src/react/usePdfImageCache.d.ts +27 -0
- package/dist/@aurochs-renderer/pdf/src/svg/document-query.d.ts +6 -1
- package/dist/@aurochs-renderer/pdf/src/svg/index.d.ts +4 -0
- package/dist/@aurochs-renderer/pdf/src/svg/render-page-svg.d.ts +23 -3
- package/dist/@aurochs-renderer/pdf/src/svg/svg-children-to-jsx.d.ts +9 -0
- package/dist/@aurochs-renderer/pdf/src/svg/svg-node.d.ts +57 -0
- package/dist/@aurochs-renderer/pdf/src/svg/svg-serializer.d.ts +14 -0
- package/dist/@aurochs-renderer/pdf/src/svg/table.d.ts +6 -1
- package/dist/@aurochs-renderer/pptx/src/react/SvgContentRenderer.d.ts +5 -6
- package/dist/@aurochs-renderer/pptx/src/react/shapes/graphic-frame/chart/ChartContent.d.ts +0 -3
- package/dist/@aurochs-renderer/pptx/src/react/shapes/graphic-frame/chart/index.d.ts +1 -1
- package/dist/@aurochs-renderer/pptx/src/react/shapes/graphic-frame/chart/useChartSvg.d.ts +18 -6
- package/dist/@aurochs-renderer/pptx/src/react/shapes/graphic-frame/index.d.ts +3 -3
- package/dist/@aurochs-renderer/pptx/src/react/shapes/graphic-frame/shared/index.d.ts +0 -1
- package/dist/@aurochs-renderer/pptx/src/react/shapes/graphic-frame/table/TableContent.d.ts +0 -3
- package/dist/@aurochs-renderer/pptx/src/react/shapes/graphic-frame/table/index.d.ts +1 -1
- package/dist/@aurochs-renderer/pptx/src/react/shapes/graphic-frame/table/useTableSvg.d.ts +18 -7
- package/dist/@aurochs-renderer/pptx/src/svg/index.d.ts +2 -2
- package/dist/@aurochs-renderer/pptx/src/svg/renderer.d.ts +31 -0
- package/dist/@aurochs-renderer/xlsx/src/svg/context.d.ts +5 -1
- package/dist/@aurochs-renderer/xlsx/src/svg/drawing/shape-renderer.d.ts +3 -0
- package/dist/@aurochs-renderer/xlsx/src/svg/index.d.ts +1 -1
- package/dist/@aurochs-renderer/xlsx/src/svg/style-resolver.d.ts +11 -1
- package/dist/@aurochs-ui/xlsx-editor/src/viewer/components/ReadonlySheetGrid.d.ts +5 -17
- package/dist/@aurochs-ui/xlsx-editor/src/viewer/components/SheetTabViewer.d.ts +3 -22
- package/dist/@aurochs-ui/xlsx-editor/src/viewer/components/index.d.ts +1 -1
- package/dist/@aurochs-ui/xlsx-editor/src/viewer/index.d.ts +1 -1
- package/dist/_shared/{FillEditor-DYGWS75m.js → FillEditor-tMpg9XZc.js} +2 -2
- package/dist/_shared/{FillEditor-DYGWS75m.js.map → FillEditor-tMpg9XZc.js.map} +1 -1
- package/dist/_shared/{SearchableSelect-CnmpyIjn.js → SearchableSelect-GEzfQibv.js} +177 -233
- package/dist/_shared/SearchableSelect-GEzfQibv.js.map +1 -0
- package/dist/_shared/{SlideList-BuJGfcEe.js → SlideList-DUpxzeb5.js} +5 -2
- package/dist/_shared/SlideList-DUpxzeb5.js.map +1 -0
- package/dist/_shared/{SlideRenderer-B1hXsmza.js → SlideRenderer-DHjDbWZk.js} +35 -36
- package/dist/_shared/SlideRenderer-DHjDbWZk.js.map +1 -0
- package/dist/_shared/{SvgContentRenderer-C2Smosls.js → SvgContentRenderer-B3wl0Eo2.js} +14 -27
- package/dist/_shared/{SvgContentRenderer-C2Smosls.js.map → SvgContentRenderer-B3wl0Eo2.js.map} +1 -1
- package/dist/_shared/{color-resolution-vdjH6IMH.js → color-resolution-610A768F.js} +13 -2
- package/dist/_shared/{color-resolution-vdjH6IMH.js.map → color-resolution-610A768F.js.map} +1 -1
- package/dist/_shared/{content-types-DYuzqVbu.js → content-types-Dvnc0zg_.js} +2 -2
- package/dist/_shared/{content-types-DYuzqVbu.js.map → content-types-Dvnc0zg_.js.map} +1 -1
- package/dist/_shared/{content-types-wFLLfEUS.js → content-types-cWoGLHFT.js} +16 -11
- package/dist/_shared/content-types-cWoGLHFT.js.map +1 -0
- package/dist/_shared/{defaults-B0FlaLrT.js → defaults-Cx9lAUnw.js} +61 -24
- package/dist/_shared/defaults-Cx9lAUnw.js.map +1 -0
- package/dist/_shared/{docx-section-adapter-BQdd6pOH.js → docx-section-adapter-ofBUsxb2.js} +15 -12
- package/dist/_shared/{docx-section-adapter-BQdd6pOH.js.map → docx-section-adapter-ofBUsxb2.js.map} +1 -1
- package/dist/_shared/element-id-Cs-yS5sI.js +12 -0
- package/dist/_shared/element-id-Cs-yS5sI.js.map +1 -0
- package/dist/_shared/element-transform-D0ebBQGN.js +189 -0
- package/dist/_shared/element-transform-D0ebBQGN.js.map +1 -0
- package/dist/_shared/encoding-maps-BBIx_zsp.js +1210 -0
- package/dist/_shared/encoding-maps-BBIx_zsp.js.map +1 -0
- package/dist/_shared/export-BGmrQEO_.js +63 -0
- package/dist/_shared/export-BGmrQEO_.js.map +1 -0
- package/dist/_shared/{exporter-CQWUIOTW.js → exporter-CqWL_dSh.js} +13 -9
- package/dist/_shared/exporter-CqWL_dSh.js.map +1 -0
- package/dist/_shared/{external-content-loader-Cco5j8Vl.js → external-content-loader-CRJzxg3w.js} +23 -57
- package/dist/_shared/external-content-loader-CRJzxg3w.js.map +1 -0
- package/dist/_shared/font-name-map-ApkggBCx.js +80 -0
- package/dist/_shared/font-name-map-ApkggBCx.js.map +1 -0
- package/dist/_shared/font-provider-C44lBE_Y.js +230 -0
- package/dist/_shared/font-provider-C44lBE_Y.js.map +1 -0
- package/dist/_shared/{format-value-CH_aCd2i.js → format-value-CDSHMD3h.js} +80 -12
- package/dist/_shared/format-value-CDSHMD3h.js.map +1 -0
- package/dist/_shared/{parse-chart-Cysii5e9.js → parse-chart-CQIWhPR9.js} +44 -1
- package/dist/_shared/parse-chart-CQIWhPR9.js.map +1 -0
- package/dist/_shared/{relationships-D4WRryJj.js → parser-BqX8sdix.js} +1 -67
- package/dist/_shared/parser-BqX8sdix.js.map +1 -0
- package/dist/_shared/path-D69nMoL8.js.map +1 -1
- package/dist/_shared/{pdf-parser-CPLetldo.js → pdf-parser-CslvODPa.js} +1560 -2066
- package/dist/_shared/pdf-parser-CslvODPa.js.map +1 -0
- package/dist/_shared/{pixel-converter-DzprJXkB.js → pixel-converter-DkRN1BWq.js} +125 -51
- package/dist/_shared/pixel-converter-DkRN1BWq.js.map +1 -0
- package/dist/_shared/{pptx-loader-BTTgDzhm.js → pptx-loader-Dt2zo0OU.js} +10 -6
- package/dist/_shared/pptx-loader-Dt2zo0OU.js.map +1 -0
- package/dist/_shared/relationships-D-jbUYMg.js +66 -0
- package/dist/_shared/relationships-D-jbUYMg.js.map +1 -0
- package/dist/_shared/{render-page-svg-Cefra4Y2.js → render-page-svg-C4kc6Pls.js} +349 -194
- package/dist/_shared/render-page-svg-C4kc6Pls.js.map +1 -0
- package/dist/_shared/{export-27VzpZvQ.js → serializer-vYQVZRRx.js} +4 -61
- package/dist/_shared/serializer-vYQVZRRx.js.map +1 -0
- package/dist/_shared/{parser-DOerpXZ9.js → shift-C1A-3U_N.js} +279 -4
- package/dist/_shared/shift-C1A-3U_N.js.map +1 -0
- package/dist/_shared/{slide-parser-CpvtNpBQ.js → slide-parser-BT02pIR2.js} +2 -2
- package/dist/_shared/{slide-parser-CpvtNpBQ.js.map → slide-parser-BT02pIR2.js.map} +1 -1
- package/dist/_shared/svg-parse-DMfvnMIe.js +57 -0
- package/dist/_shared/svg-parse-DMfvnMIe.js.map +1 -0
- package/dist/_shared/svg-to-jsx-Bc1iqFy1.js +114 -0
- package/dist/_shared/svg-to-jsx-Bc1iqFy1.js.map +1 -0
- package/dist/_shared/{table-CCstmUe6.js → table-COmXAzPH.js} +38 -27
- package/dist/_shared/{table-CCstmUe6.js.map → table-COmXAzPH.js.map} +1 -1
- package/dist/_shared/{theme-parser-C1CdMvY2.js → theme-parser-CbNAQ21c.js} +5 -4
- package/dist/_shared/{theme-parser-C1CdMvY2.js.map → theme-parser-CbNAQ21c.js.map} +1 -1
- package/dist/_shared/{unit-conversion-DBAg4Cqb.js → unit-conversion-DI3GSFe9.js} +2 -2
- package/dist/_shared/{unit-conversion-DBAg4Cqb.js.map → unit-conversion-DI3GSFe9.js.map} +1 -1
- package/dist/_shared/{worksheet-DrVL6723.js → worksheet-DQDWQqQQ.js} +3 -278
- package/dist/_shared/worksheet-DQDWQqQQ.js.map +1 -0
- package/dist/cli.js +119076 -9263
- package/dist/docx/builder/index.js +18 -11
- package/dist/docx/builder/index.js.map +1 -1
- package/dist/docx/parser/index.js +2 -1
- package/dist/docx/parser/index.js.map +1 -1
- package/dist/docx/renderer/ascii/index.js +7 -5
- package/dist/docx/renderer/ascii/index.js.map +1 -1
- package/dist/docx/renderer/mermaid/index.js +13 -8
- package/dist/docx/renderer/mermaid/index.js.map +1 -1
- package/dist/docx/renderer/react/index.js +12 -13
- package/dist/docx/renderer/react/index.js.map +1 -1
- package/dist/docx/renderer/svg/index.js +1 -1
- package/dist/drawing-ml/domain/index.js +7 -6
- package/dist/drawing-ml/editors/index.js +18 -14
- package/dist/drawing-ml/editors/index.js.map +1 -1
- package/dist/pdf/builder/index.js +2491 -193
- package/dist/pdf/builder/index.js.map +1 -1
- package/dist/pdf/parser/index.js +83 -43
- package/dist/pdf/parser/index.js.map +1 -1
- package/dist/pdf/renderer/react/index.js +146 -6
- package/dist/pdf/renderer/react/index.js.map +1 -1
- package/dist/pdf/renderer/svg/index.js +44 -17
- package/dist/pdf/renderer/svg/index.js.map +1 -1
- package/dist/pdf/writer/index.js +397 -331
- package/dist/pdf/writer/index.js.map +1 -1
- package/dist/pptx/builder/index.js +9 -8
- package/dist/pptx/builder/index.js.map +1 -1
- package/dist/pptx/domain/index.js +26 -21
- package/dist/pptx/domain/index.js.map +1 -1
- package/dist/pptx/extract/index.js +1 -1
- package/dist/pptx/parser/index.js +7 -5
- package/dist/pptx/parser/index.js.map +1 -1
- package/dist/pptx/renderer/mermaid/index.js.map +1 -1
- package/dist/pptx/renderer/react/index.js +6 -6
- package/dist/pptx/renderer/svg/index.js +29 -4
- package/dist/pptx/renderer/svg/index.js.map +1 -1
- package/dist/pptx/slide-canvas/index.js +16 -11
- package/dist/pptx/slide-canvas/index.js.map +1 -1
- package/dist/pptx/slide-editors/index.js +1 -1
- package/dist/pptx/viewer/index.js +2 -2
- package/dist/pptx/viewer/slide-list/index.js +1 -1
- package/dist/resvgjs.linux-x64-gnu-7zy3zqas.node +0 -0
- package/dist/resvgjs.linux-x64-musl-80m5e4kx.node +0 -0
- package/dist/xlsx/builder/index.js +9 -7
- package/dist/xlsx/builder/index.js.map +1 -1
- package/dist/xlsx/parser/full/index.js +145 -15
- package/dist/xlsx/parser/full/index.js.map +1 -1
- package/dist/xlsx/parser/index.js +2 -2
- package/dist/xlsx/renderer/svg/index.js +49 -27
- package/dist/xlsx/renderer/svg/index.js.map +1 -1
- package/dist/xlsx/viewer/index.js +2062 -630
- package/dist/xlsx/viewer/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/@aurochs-renderer/pdf/src/svg/xml-escape.d.ts +0 -5
- package/dist/@aurochs-renderer/pptx/src/react/shapes/graphic-frame/shared/SvgInnerHtml.d.ts +0 -20
- package/dist/@aurochs-renderer/xlsx/src/svg/color-resolver.d.ts +0 -10
- package/dist/_shared/SearchableSelect-CnmpyIjn.js.map +0 -1
- package/dist/_shared/SlideList-BuJGfcEe.js.map +0 -1
- package/dist/_shared/SlideRenderer-B1hXsmza.js.map +0 -1
- package/dist/_shared/content-types-wFLLfEUS.js.map +0 -1
- package/dist/_shared/defaults-B0FlaLrT.js.map +0 -1
- package/dist/_shared/element-transform-DPFdOOrT.js +0 -109
- package/dist/_shared/element-transform-DPFdOOrT.js.map +0 -1
- package/dist/_shared/export-27VzpZvQ.js.map +0 -1
- package/dist/_shared/exporter-CQWUIOTW.js.map +0 -1
- package/dist/_shared/external-content-loader-Cco5j8Vl.js.map +0 -1
- package/dist/_shared/format-value-CH_aCd2i.js.map +0 -1
- package/dist/_shared/matrix-Ca4HvRxo.js +0 -118
- package/dist/_shared/matrix-Ca4HvRxo.js.map +0 -1
- package/dist/_shared/parse-chart-Cysii5e9.js.map +0 -1
- package/dist/_shared/parser-DOerpXZ9.js.map +0 -1
- package/dist/_shared/pdf-parser-CPLetldo.js.map +0 -1
- package/dist/_shared/pixel-converter-DzprJXkB.js.map +0 -1
- package/dist/_shared/pptx-loader-BTTgDzhm.js.map +0 -1
- package/dist/_shared/relationships-D4WRryJj.js.map +0 -1
- package/dist/_shared/render-page-svg-Cefra4Y2.js.map +0 -1
- package/dist/_shared/svg-utils-x7e_VUa6.js +0 -11
- package/dist/_shared/svg-utils-x7e_VUa6.js.map +0 -1
- package/dist/_shared/worksheet-DrVL6723.js.map +0 -1
|
@@ -8,6 +8,24 @@ export declare function getElementRotationDeg(element: PdfElement): number;
|
|
|
8
8
|
* Preserves scale and translation; adds the delta to the existing rotation.
|
|
9
9
|
*/
|
|
10
10
|
export declare function rotateElement(element: PdfElement, angleDeltaRad: number): PdfElement;
|
|
11
|
+
/**
|
|
12
|
+
* Scale a PDF element to fit new bounds.
|
|
13
|
+
*
|
|
14
|
+
* @param element - The element to scale (immutable — returns a new instance).
|
|
15
|
+
* @param oldBounds - The element's current bounding box in PDF coordinate space (bottom-left origin).
|
|
16
|
+
* @param newBounds - The desired bounding box in PDF coordinate space (bottom-left origin).
|
|
17
|
+
*/
|
|
18
|
+
export declare function scaleElement(element: PdfElement, oldBounds: {
|
|
19
|
+
readonly x: number;
|
|
20
|
+
readonly y: number;
|
|
21
|
+
readonly width: number;
|
|
22
|
+
readonly height: number;
|
|
23
|
+
}, newBounds: {
|
|
24
|
+
readonly x: number;
|
|
25
|
+
readonly y: number;
|
|
26
|
+
readonly width: number;
|
|
27
|
+
readonly height: number;
|
|
28
|
+
}): PdfElement;
|
|
11
29
|
/**
|
|
12
30
|
* Apply a position delta to a PDF element.
|
|
13
31
|
*
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Exports types and operations for PDF document structure.
|
|
5
5
|
*/
|
|
6
6
|
export type { PdfElement, PdfPage, PdfDocument, PdfEmbeddedFont, PdfFontToUnicode, PdfFontMetrics, PdfTable, PdfTableRow, PdfTableCell } from './types';
|
|
7
|
-
export { PDF_UNITS, PDF_PAGE_SIZES, isPdfPath, isPdfText, isPdfImage, isPdfTable } from './types';
|
|
7
|
+
export { PDF_UNITS, PDF_PAGE_SIZES, isPdfPath, isPdfText, isPdfTextBlock, isPdfImage, isPdfTable } from './types';
|
|
8
8
|
export type { PdfElementId } from './element-id';
|
|
9
9
|
export { createElementId, parseElementId } from './element-id';
|
|
10
|
-
export { getElementRotationRad, getElementRotationDeg, rotateElement, moveElement } from './element-transform';
|
|
10
|
+
export { getElementRotationRad, getElementRotationDeg, rotateElement, moveElement, scaleElement } from './element-transform';
|
|
11
11
|
export { updateElementInDocument, deleteElements, addElementsToPage, addPage, deletePages, duplicatePages, reorderPages, updatePageSize, } from './document-mutation';
|
|
12
12
|
export { createTableCell, insertRow, removeRow, insertColumn, removeColumn, setColumnWidth, setRowHeight, mergeCells, splitCell, type TableCellRange, } from './table-mutation';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PdfImage } from '../image';
|
|
2
2
|
import { PdfPath } from '../path';
|
|
3
|
-
import { PdfText } from '../text';
|
|
3
|
+
import { PdfText, PdfTextBlock } from '../text';
|
|
4
4
|
import { CIDOrdering } from '../font';
|
|
5
5
|
import { PdfGraphicsState } from '../graphics-state/types';
|
|
6
|
-
export type PdfElement = PdfPath | PdfText | PdfImage | PdfTable;
|
|
6
|
+
export type PdfElement = PdfPath | PdfText | PdfTextBlock | PdfImage | PdfTable;
|
|
7
7
|
/** Table cell in a PDF table. */
|
|
8
8
|
export type PdfTableCell = {
|
|
9
9
|
readonly text: string;
|
|
@@ -191,6 +191,8 @@ export declare const PDF_UNITS: {
|
|
|
191
191
|
export declare function isPdfPath(element: PdfElement): element is PdfPath;
|
|
192
192
|
/** Type guard for `PdfText` elements. */
|
|
193
193
|
export declare function isPdfText(element: PdfElement): element is PdfText;
|
|
194
|
+
/** Type guard for `PdfTextBlock` elements. */
|
|
195
|
+
export declare function isPdfTextBlock(element: PdfElement): element is PdfTextBlock;
|
|
194
196
|
/** Type guard for `PdfImage` elements. */
|
|
195
197
|
export declare function isPdfImage(element: PdfElement): element is PdfImage;
|
|
196
198
|
/** Type guard for `PdfTable` elements. */
|
|
@@ -57,6 +57,29 @@ export declare function parseBfChar(data: string, mapping: FontMapping): number;
|
|
|
57
57
|
* Returns maximum source hex length found.
|
|
58
58
|
*/
|
|
59
59
|
export declare function parseBfRange(data: string, mapping: FontMapping, options?: CMapParserOptions): number;
|
|
60
|
+
/**
|
|
61
|
+
* Determine whether ToUnicode diagnostics indicate severe corruption.
|
|
62
|
+
*
|
|
63
|
+
* "Severe corruption" means the ToUnicode CMap is unreliable enough that
|
|
64
|
+
* callers should fall back to CID-based decoding or other alternatives.
|
|
65
|
+
*
|
|
66
|
+
* The check is: replacement-character ratio ≥ 50% **OR** private-use ratio
|
|
67
|
+
* ≥ 50% (when PUA is treated as a corruption signal).
|
|
68
|
+
*
|
|
69
|
+
* For **symbol fonts** (Wingdings, Symbol, ZapfDingbats, etc.), PUA mappings
|
|
70
|
+
* are the correct and expected behaviour — not a corruption signal. Callers
|
|
71
|
+
* should pass `treatPrivateUseAsCorruption: false` for such fonts so that
|
|
72
|
+
* only the replacement-character ratio is evaluated.
|
|
73
|
+
*
|
|
74
|
+
* @param diagnostics - Parse diagnostics from {@link parseToUnicodeCMap}.
|
|
75
|
+
* @param totalEntries - Total number of entries in the byte mapping.
|
|
76
|
+
* @param options.treatPrivateUseAsCorruption
|
|
77
|
+
* When `true` (default), a high PUA ratio counts as corruption.
|
|
78
|
+
* Set to `false` for symbol / dingbats fonts where PUA is legitimate.
|
|
79
|
+
*/
|
|
80
|
+
export declare function isToUnicodeSeverelyCorrupted(diagnostics: CMapParseDiagnostics, totalEntries: number, options?: {
|
|
81
|
+
readonly treatPrivateUseAsCorruption?: boolean;
|
|
82
|
+
}): boolean;
|
|
60
83
|
/**
|
|
61
84
|
* Convert destination hex string to Unicode string.
|
|
62
85
|
* Destination is interpreted as UTF-16BE code units.
|
|
@@ -13,6 +13,15 @@
|
|
|
13
13
|
* For embedded fonts, returns the font name as-is (after cleanup).
|
|
14
14
|
* For PDF Standard 14 fonts, maps to system font equivalents.
|
|
15
15
|
*
|
|
16
|
+
* **Usage guidance**: For rendering and writing, use `FontProvider.resolve()`
|
|
17
|
+
* instead of calling this function directly. `FontProvider.resolve()` handles
|
|
18
|
+
* embedded font matching, Standard 14 mapping, system fonts, and fallback
|
|
19
|
+
* in a unified way.
|
|
20
|
+
*
|
|
21
|
+
* Direct use of this function is appropriate only for pure font name
|
|
22
|
+
* normalization without font resolution (e.g., cross-format conversion
|
|
23
|
+
* where FontProvider context is not applicable).
|
|
24
|
+
*
|
|
16
25
|
* IMPORTANT: Do NOT modify font names beyond removing PDF syntax artifacts.
|
|
17
26
|
* Embedded fonts use their exact names for @font-face declarations.
|
|
18
27
|
* Changing the name (e.g., hyphens to spaces) would break font matching.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { CIDOrdering } from './types';
|
|
2
|
+
import { EmbeddedFontMetrics, FontFormat } from './embedded-font';
|
|
3
|
+
import { PdfFontToUnicode } from '../document/types';
|
|
4
|
+
/**
|
|
5
|
+
* Origin of a resolved font.
|
|
6
|
+
*
|
|
7
|
+
* - "embedded": font binary extracted from the PDF being edited
|
|
8
|
+
* - "standard14": one of the 14 fonts guaranteed by the PDF spec (no embedding required)
|
|
9
|
+
* - "system": font registered by the application from an external source
|
|
10
|
+
*/
|
|
11
|
+
export type FontSource = "embedded" | "standard14" | "system";
|
|
12
|
+
/**
|
|
13
|
+
* A font resolved by the FontProvider.
|
|
14
|
+
*
|
|
15
|
+
* This is the single representation used by both the renderer (cssFontFamily)
|
|
16
|
+
* and the writer (pdfBaseFont, data, toUnicode, codeByteWidth).
|
|
17
|
+
*/
|
|
18
|
+
export type ResolvedFont = {
|
|
19
|
+
readonly source: FontSource;
|
|
20
|
+
/** CSS font-family value for SVG / HTML rendering. */
|
|
21
|
+
readonly cssFontFamily: string;
|
|
22
|
+
/** PDF /BaseFont name for writing. */
|
|
23
|
+
readonly pdfBaseFont: string;
|
|
24
|
+
/** Font binary format (undefined for standard14 fonts). */
|
|
25
|
+
readonly format?: FontFormat;
|
|
26
|
+
/** Raw font binary for embedding (undefined for standard14). */
|
|
27
|
+
readonly data?: Uint8Array;
|
|
28
|
+
/** Font metrics in 1/1000 em units. */
|
|
29
|
+
readonly metrics?: EmbeddedFontMetrics;
|
|
30
|
+
/** CID ordering for CJK fonts. */
|
|
31
|
+
readonly ordering?: CIDOrdering;
|
|
32
|
+
/** Bytes per character code: 1 for single-byte, 2 for CID fonts. */
|
|
33
|
+
readonly codeByteWidth: 1 | 2;
|
|
34
|
+
/** ToUnicode mapping for round-trip preservation and re-encoding. */
|
|
35
|
+
readonly toUnicode?: PdfFontToUnicode;
|
|
36
|
+
/** Whether the font is bold. */
|
|
37
|
+
readonly isBold: boolean;
|
|
38
|
+
/** Whether the font is italic. */
|
|
39
|
+
readonly isItalic: boolean;
|
|
40
|
+
/** MIME type for @font-face data URL. */
|
|
41
|
+
readonly mimeType?: string;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Strategy for resolving a fallback font when the primary font cannot
|
|
45
|
+
* encode certain characters.
|
|
46
|
+
*
|
|
47
|
+
* The FontProvider calls this when `splitTextByEncodability()` produces
|
|
48
|
+
* non-encodable runs. The strategy returns a ResolvedFont that can handle
|
|
49
|
+
* the fallback characters, or undefined if no fallback is available.
|
|
50
|
+
*
|
|
51
|
+
* This is DI-injectable: callers can provide a custom strategy when creating
|
|
52
|
+
* the FontProvider. The default strategy falls back to Helvetica (Standard 14).
|
|
53
|
+
*
|
|
54
|
+
* @see ISO 32000-1:2008 Section 9.4.3 — Multiple Tf operators within BT...ET
|
|
55
|
+
* are used to switch fonts for different character runs.
|
|
56
|
+
*/
|
|
57
|
+
export type FontFallbackStrategy = (
|
|
58
|
+
/** Characters that the primary font cannot encode. */
|
|
59
|
+
unencodableText: string,
|
|
60
|
+
/** The primary font that failed to encode. */
|
|
61
|
+
primaryFont: ResolvedFont,
|
|
62
|
+
/** The FontProvider for looking up alternative fonts. */
|
|
63
|
+
provider: FontProvider) => ResolvedFont | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* FontProvider — the single authority for font resolution.
|
|
66
|
+
*
|
|
67
|
+
* Created once per document session. Both rendering and writing pipelines
|
|
68
|
+
* must resolve fonts exclusively through this interface.
|
|
69
|
+
*/
|
|
70
|
+
export type FontProvider = {
|
|
71
|
+
/**
|
|
72
|
+
* Resolve a font by its PDF resource name and/or BaseFont name.
|
|
73
|
+
*
|
|
74
|
+
* Always returns a result — for unknown fonts, returns a best-effort
|
|
75
|
+
* resolution using the normalized font name as CSS font-family.
|
|
76
|
+
* Use `isAvailable()` to check if a font is actually registered.
|
|
77
|
+
*
|
|
78
|
+
* @param fontName - PDF resource identifier (e.g. "F1")
|
|
79
|
+
* @param baseFont - Real font name from /BaseFont entry (e.g. "ABCDEF+Helvetica")
|
|
80
|
+
* @returns Resolved font (never undefined)
|
|
81
|
+
*/
|
|
82
|
+
resolve(fontName: string, baseFont?: string): ResolvedFont;
|
|
83
|
+
/**
|
|
84
|
+
* Register embedded fonts extracted from the PDF.
|
|
85
|
+
* Accepts both EmbeddedFont (from parser) and PdfEmbeddedFont (from document).
|
|
86
|
+
* Typically called once after parsing.
|
|
87
|
+
*/
|
|
88
|
+
registerEmbeddedFonts(fonts: readonly FontRegistrationInput[]): void;
|
|
89
|
+
/**
|
|
90
|
+
* Register a system/external font (e.g. from user file upload).
|
|
91
|
+
*/
|
|
92
|
+
registerSystemFont(options: {
|
|
93
|
+
family: string;
|
|
94
|
+
data: Uint8Array;
|
|
95
|
+
format: FontFormat;
|
|
96
|
+
mimeType: string;
|
|
97
|
+
}): void;
|
|
98
|
+
/**
|
|
99
|
+
* Generate combined @font-face CSS for all registered embedded and system fonts.
|
|
100
|
+
* This is the single source of truth for font CSS — replaces direct use of
|
|
101
|
+
* generateFontFaceStyle().
|
|
102
|
+
*/
|
|
103
|
+
getAllFontFaceCss(): string;
|
|
104
|
+
/**
|
|
105
|
+
* Check if a font family is available (embedded, standard14, or system).
|
|
106
|
+
*/
|
|
107
|
+
isAvailable(fontFamily: string): boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Resolve a fallback font for characters that the primary font cannot encode.
|
|
110
|
+
*
|
|
111
|
+
* Uses the injected FontFallbackStrategy. Returns undefined if no fallback
|
|
112
|
+
* is available — the caller must handle this (e.g. skip the characters or
|
|
113
|
+
* raise an error to the user).
|
|
114
|
+
*
|
|
115
|
+
* @param unencodableText - The characters that need a fallback font
|
|
116
|
+
* @param primaryFont - The font that could not encode these characters
|
|
117
|
+
*/
|
|
118
|
+
resolveFallback(unencodableText: string, primaryFont: ResolvedFont): ResolvedFont | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Get all registered embedded fonts.
|
|
121
|
+
* Used by the writer to embed fonts in the output PDF.
|
|
122
|
+
*/
|
|
123
|
+
getEmbeddedFonts(): readonly FontRegistrationInput[];
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Common input type for font registration.
|
|
127
|
+
* Accepts both EmbeddedFont (from parser) and PdfEmbeddedFont (from document).
|
|
128
|
+
*/
|
|
129
|
+
export type FontRegistrationInput = {
|
|
130
|
+
readonly fontFamily: string;
|
|
131
|
+
readonly baseFontName?: string;
|
|
132
|
+
readonly format: FontFormat | "opentype" | "truetype" | "type1" | "cff";
|
|
133
|
+
readonly data: Uint8Array;
|
|
134
|
+
readonly mimeType: string;
|
|
135
|
+
readonly metrics?: EmbeddedFontMetrics;
|
|
136
|
+
readonly toUnicode?: {
|
|
137
|
+
readonly byteMapping: ReadonlyMap<string, string>;
|
|
138
|
+
readonly sourceCodeByteLengths: readonly number[];
|
|
139
|
+
};
|
|
140
|
+
readonly ordering?: CIDOrdering;
|
|
141
|
+
readonly codeByteWidth?: 1 | 2;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Options for creating a FontProvider.
|
|
145
|
+
*/
|
|
146
|
+
export type CreateFontProviderOptions = {
|
|
147
|
+
/** Initial embedded fonts to register. */
|
|
148
|
+
readonly embeddedFonts?: readonly FontRegistrationInput[];
|
|
149
|
+
/**
|
|
150
|
+
* Strategy for resolving fallback fonts when encoding fails.
|
|
151
|
+
* When omitted, defaults to `defaultFallbackStrategy` which uses
|
|
152
|
+
* Helvetica (Standard 14) for WinAnsi-encodable characters.
|
|
153
|
+
*/
|
|
154
|
+
readonly fallbackStrategy?: FontFallbackStrategy;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Create a FontProvider instance.
|
|
158
|
+
*
|
|
159
|
+
* Optionally accepts embedded fonts from PDF parsing to register immediately.
|
|
160
|
+
*/
|
|
161
|
+
export declare function createFontProvider(options?: CreateFontProviderOptions): FontProvider;
|
|
162
|
+
/**
|
|
163
|
+
* Create a FontProvider from a PdfDocument.
|
|
164
|
+
*
|
|
165
|
+
* This is the canonical way to obtain a FontProvider for rendering or writing.
|
|
166
|
+
* It automatically registers the document's embedded fonts.
|
|
167
|
+
*/
|
|
168
|
+
export declare function createFontProviderForDocument(document: {
|
|
169
|
+
readonly embeddedFonts?: readonly FontRegistrationInput[];
|
|
170
|
+
}): FontProvider;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Font style detection
|
|
2
|
+
* @file Font style and classification detection
|
|
3
3
|
*
|
|
4
|
-
* Utilities for detecting font styles from PDF font names.
|
|
4
|
+
* Utilities for detecting font styles and classification from PDF font names.
|
|
5
5
|
* Based on common PDF font naming conventions.
|
|
6
|
+
*
|
|
7
|
+
* Note on "symbol font" vs. PDF Symbolic flag (FontDescriptor Flags bit 3):
|
|
8
|
+
* The Symbolic flag means "contains glyphs outside the Adobe Standard Latin
|
|
9
|
+
* character set" — CJK fonts, Cyrillic fonts, and many embedded fonts also
|
|
10
|
+
* have this flag set. It does NOT reliably indicate a symbol/dingbats font.
|
|
11
|
+
* Therefore, symbol font detection here uses font-name heuristics rather
|
|
12
|
+
* than the Symbolic flag.
|
|
6
13
|
*/
|
|
7
14
|
/**
|
|
8
15
|
* Normalize PDF font name by removing subset prefix
|
|
@@ -29,3 +36,14 @@ export declare function isBoldFont(fontName: string): boolean;
|
|
|
29
36
|
* - "-I" suffix
|
|
30
37
|
*/
|
|
31
38
|
export declare function isItalicFont(fontName: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Detect whether a PDF BaseFont name refers to a symbol / dingbats font.
|
|
41
|
+
*
|
|
42
|
+
* Symbol fonts legitimately use Private Use Area code points in their
|
|
43
|
+
* ToUnicode CMap. Callers should skip PUA-based corruption heuristics
|
|
44
|
+
* for these fonts.
|
|
45
|
+
*
|
|
46
|
+
* @param baseFont - Raw BaseFont value from the PDF font dictionary
|
|
47
|
+
* (e.g. "/CPNHAK+Wingdings-Regular", "Symbol")
|
|
48
|
+
*/
|
|
49
|
+
export declare function isSymbolFont(baseFont: string | undefined): boolean;
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export type { FontMapping, FontMetrics, FontInfo, FontMappings, CIDOrdering, } from './types';
|
|
7
7
|
export { DEFAULT_FONT_METRICS } from './defaults';
|
|
8
|
-
export { normalizeFontName, isBoldFont, isItalicFont } from './font-style';
|
|
8
|
+
export { normalizeFontName, isBoldFont, isItalicFont, isSymbolFont } from './font-style';
|
|
9
|
+
export { isPrivateUseCodePoint, containsPrivateUseCharacter } from './unicode-classification';
|
|
9
10
|
export { normalizeFontFamily } from './font-name-map';
|
|
10
|
-
export type { CMapParseResult, CMapParserOptions } from './cmap/cmap-parser';
|
|
11
|
-
export { parseToUnicodeCMap, parseBfChar, parseBfRange, hexToString, } from './cmap/cmap-parser';
|
|
11
|
+
export type { CMapParseResult, CMapParseDiagnostics, CMapParserOptions } from './cmap/cmap-parser';
|
|
12
|
+
export { parseToUnicodeCMap, parseBfChar, parseBfRange, hexToString, isToUnicodeSeverelyCorrupted, } from './cmap/cmap-parser';
|
|
12
13
|
export { decodeText, decodeTextWithFontInfo } from './decoding/text-decoder';
|
|
13
14
|
export type { CIDFallbackMapping } from './cid/cid-ordering';
|
|
14
15
|
export { getCIDFallbackMapping, detectCIDOrdering, decodeCIDFallback, } from './cid/cid-ordering';
|
|
@@ -20,3 +21,7 @@ export { hasCmapTable, injectCmapTable, repairFontForWeb } from './font-repair';
|
|
|
20
21
|
export type { TableEntry, TrueTypeFontMetrics } from './truetype-parser';
|
|
21
22
|
export { parseTrueTypeTableDirectory, hasTable, getTableTags, extractTrueTypeMetrics, normalizeMetricsTo1000, } from './truetype-parser';
|
|
22
23
|
export { fontToDataUrl, generateFontFaceCss, generateFontFaceStyle, } from './font-css-generator';
|
|
24
|
+
export type { FontSource, ResolvedFont, FontProvider, FontRegistrationInput, FontFallbackStrategy, CreateFontProviderOptions, } from './font-provider';
|
|
25
|
+
export { createFontProvider, createFontProviderForDocument } from './font-provider';
|
|
26
|
+
export type { TextEncodeResult, TextRun } from './text-encoder';
|
|
27
|
+
export { encodeTextForFont, buildReverseToUnicodeMap, hexStringToUint8Array, splitTextByEncodability, } from './text-encoder';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ResolvedFont } from './font-provider';
|
|
2
|
+
/**
|
|
3
|
+
* Build a reverse map from Unicode strings to source hex byte sequences.
|
|
4
|
+
*
|
|
5
|
+
* The ToUnicode CMap maps source bytes → Unicode. This inverts that:
|
|
6
|
+
* Unicode → source hex bytes.
|
|
7
|
+
*
|
|
8
|
+
* When multiple source byte sequences map to the same Unicode string,
|
|
9
|
+
* the first encountered mapping wins (consistent with PDF spec behavior
|
|
10
|
+
* where the first mapping in the CMap takes precedence).
|
|
11
|
+
*
|
|
12
|
+
* @param byteMapping - Forward mapping: hex bytes → Unicode string
|
|
13
|
+
* @returns Reverse mapping: Unicode string → hex bytes (uppercase)
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildReverseToUnicodeMap(byteMapping: ReadonlyMap<string, string>): Map<string, string>;
|
|
16
|
+
export type TextEncodeResult = {
|
|
17
|
+
/** Encoded byte sequence for the PDF content stream. */
|
|
18
|
+
readonly rawBytes: Uint8Array;
|
|
19
|
+
/** Bytes per character code in the encoded output. */
|
|
20
|
+
readonly codeByteWidth: 1 | 2;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Encode Unicode text to PDF byte sequences for a given resolved font.
|
|
24
|
+
*
|
|
25
|
+
* For CID fonts: uses the reverse ToUnicode mapping.
|
|
26
|
+
* For single-byte fonts: uses WinAnsiEncoding.
|
|
27
|
+
* For standard14 fonts: uses WinAnsiEncoding.
|
|
28
|
+
*
|
|
29
|
+
* @returns Encoded result, or null if any character cannot be encoded.
|
|
30
|
+
*/
|
|
31
|
+
export declare function encodeTextForFont(text: string, font: ResolvedFont): TextEncodeResult | null;
|
|
32
|
+
/**
|
|
33
|
+
* A contiguous run of text that can be encoded with a single font.
|
|
34
|
+
*
|
|
35
|
+
* When the primary font cannot encode certain characters, the text is split
|
|
36
|
+
* into runs — some using the primary font, others requiring a fallback.
|
|
37
|
+
*/
|
|
38
|
+
export type TextRun = {
|
|
39
|
+
/** The text content of this run. */
|
|
40
|
+
readonly text: string;
|
|
41
|
+
/** Whether this run can be encoded by the primary font. */
|
|
42
|
+
readonly encodable: boolean;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Split text into runs based on whether each character is encodable
|
|
46
|
+
* by the given font.
|
|
47
|
+
*
|
|
48
|
+
* Adjacent characters with the same encodability are merged into a single run.
|
|
49
|
+
* This is the foundation for font fallback: encodable runs use the primary font,
|
|
50
|
+
* non-encodable runs use a fallback font.
|
|
51
|
+
*
|
|
52
|
+
* @param text - Unicode text to split
|
|
53
|
+
* @param font - The primary font to test encodability against
|
|
54
|
+
* @returns Array of TextRun, preserving the original character order
|
|
55
|
+
*/
|
|
56
|
+
export declare function splitTextByEncodability(text: string, font: ResolvedFont): readonly TextRun[];
|
|
57
|
+
/**
|
|
58
|
+
* Convert a hex string (e.g. "8140AB") to Uint8Array.
|
|
59
|
+
* Each pair of hex digits becomes one byte.
|
|
60
|
+
*/
|
|
61
|
+
export declare function hexStringToUint8Array(hex: string): Uint8Array;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Unicode character classification utilities for PDF font handling.
|
|
3
|
+
*
|
|
4
|
+
* Provides predicates for Unicode character categories that are relevant
|
|
5
|
+
* to PDF text decoding and ToUnicode CMap diagnostics.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Test whether a code point falls in a Unicode Private Use Area.
|
|
9
|
+
*
|
|
10
|
+
* Unicode defines three PUA blocks (Unicode 15.1, Section 23.5):
|
|
11
|
+
* - BMP PUA: U+E000 – U+F8FF (6,400 code points)
|
|
12
|
+
* - Supplementary PUA-A: U+F0000 – U+FFFFD (65,534 code points)
|
|
13
|
+
* - Supplementary PUA-B: U+100000 – U+10FFFD (65,534 code points)
|
|
14
|
+
*
|
|
15
|
+
* PUA code points are used by symbol/dingbats fonts (Wingdings, Symbol,
|
|
16
|
+
* ZapfDingbats) to map glyphs that have no standard Unicode assignment.
|
|
17
|
+
* Their presence in a ToUnicode CMap is normal for such fonts.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isPrivateUseCodePoint(codePoint: number): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Test whether a string contains any Unicode Private Use Area characters.
|
|
22
|
+
*
|
|
23
|
+
* Used by CMap diagnostics to count PUA mappings, and by the text decoder
|
|
24
|
+
* to decide whether a decoded character should be treated as "missing"
|
|
25
|
+
* when the ToUnicode CMap is suspected of corruption.
|
|
26
|
+
*/
|
|
27
|
+
export declare function containsPrivateUseCharacter(text: string): boolean;
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { PdfColor } from '../color';
|
|
2
2
|
import { PdfGraphicsState } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve Pattern color space references in a graphics state to device colors.
|
|
5
|
+
*
|
|
6
|
+
* When a fill or stroke uses a Pattern color space, the `fillColor`/`strokeColor`
|
|
7
|
+
* fields contain `{ colorSpace: "Pattern", components: [] }` which carries no
|
|
8
|
+
* usable color information. The actual base color (for PaintType 2 uncolored
|
|
9
|
+
* tiling patterns) is stored in `fillPatternColor`/`strokePatternColor`.
|
|
10
|
+
*
|
|
11
|
+
* This function produces a graphics state where `fillColor`/`strokeColor` are
|
|
12
|
+
* always device-space colors that renderers and converters can use directly
|
|
13
|
+
* without additional dispatch.
|
|
14
|
+
*
|
|
15
|
+
* Pattern fills are normally rasterized to PdfImage at parse time. This
|
|
16
|
+
* resolution is for the residual case where a pattern path was not rasterized
|
|
17
|
+
* (e.g. rasterization failed or the source PDF uses a pattern only for color).
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolvePatternColors(gs: PdfGraphicsState): PdfGraphicsState;
|
|
3
20
|
export declare const DEFAULT_FILL_COLOR: PdfColor;
|
|
4
21
|
export declare const DEFAULT_STROKE_COLOR: PdfColor;
|
|
5
22
|
/**
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* Color types and utilities are in domain/color.
|
|
6
6
|
*/
|
|
7
7
|
export type { PdfLineJoin, PdfLineCap, PdfTextRenderingMode, PdfSoftMask, PdfGraphicsState, } from './types';
|
|
8
|
-
export { DEFAULT_FILL_COLOR, DEFAULT_STROKE_COLOR, createDefaultGraphicsState } from './defaults';
|
|
8
|
+
export { DEFAULT_FILL_COLOR, DEFAULT_STROKE_COLOR, createDefaultGraphicsState, resolvePatternColors } from './defaults';
|
|
9
9
|
export type { GraphicsStateStack } from './stack';
|
|
10
10
|
export { createGraphicsStateStack } from './stack';
|
|
@@ -10,16 +10,17 @@ export { DEFAULT_FONT_METRICS, normalizeFontName, isBoldFont, isItalicFont, norm
|
|
|
10
10
|
export type { PdfPoint, PdfBBox, PdfMatrix, MatrixDecomposition } from './coordinate';
|
|
11
11
|
export { IDENTITY_MATRIX, multiplyMatrices, transformPoint, invertMatrix, translationMatrix, scalingMatrix, rotationMatrix, isIdentityMatrix, isSimpleTransform, getMatrixScale, getMatrixRotation, decomposeMatrix, hasShear, } from './coordinate';
|
|
12
12
|
export type { PdfLineJoin, PdfLineCap, PdfTextRenderingMode, PdfSoftMask, PdfGraphicsState, GraphicsStateStack, } from './graphics-state';
|
|
13
|
-
export { DEFAULT_FILL_COLOR, DEFAULT_STROKE_COLOR, createDefaultGraphicsState, createGraphicsStateStack, } from './graphics-state';
|
|
13
|
+
export { DEFAULT_FILL_COLOR, DEFAULT_STROKE_COLOR, createDefaultGraphicsState, createGraphicsStateStack, resolvePatternColors, } from './graphics-state';
|
|
14
14
|
export type { PdfMoveTo, PdfLineTo, PdfCurveTo, PdfCurveToV, PdfCurveToY, PdfRect, PdfClosePath, PdfPathOp, PdfPaintOp, PdfPath, } from './path';
|
|
15
15
|
export { getPathBounds } from './path';
|
|
16
|
-
export type { PdfText, PdfTextFontMetrics } from './text';
|
|
16
|
+
export type { PdfText, PdfTextBlock, PdfTextBlockParagraph, PdfTextFontMetrics, PdfTextEditState } from './text';
|
|
17
|
+
export { withTextContent, withFontFamily, withFontSize, withCharSpacing, } from './text';
|
|
17
18
|
export type { PdfImage } from './image';
|
|
18
19
|
export type { PdfElement, PdfPage, PdfDocument, PdfEmbeddedFont, PdfTable, PdfTableRow, PdfTableCell } from './document';
|
|
19
|
-
export { PDF_UNITS, PDF_PAGE_SIZES, isPdfPath, isPdfText, isPdfImage, isPdfTable } from './document';
|
|
20
|
+
export { PDF_UNITS, PDF_PAGE_SIZES, isPdfPath, isPdfText, isPdfTextBlock, isPdfImage, isPdfTable } from './document';
|
|
20
21
|
export type { PdfElementId } from './document';
|
|
21
22
|
export { createElementId, parseElementId } from './document';
|
|
22
|
-
export { getElementRotationRad, getElementRotationDeg, rotateElement, moveElement } from './document';
|
|
23
|
+
export { getElementRotationRad, getElementRotationDeg, rotateElement, moveElement, scaleElement } from './document';
|
|
23
24
|
export { updateElementInDocument, deleteElements, addElementsToPage, addPage, deletePages, duplicatePages, reorderPages, updatePageSize, } from './document';
|
|
24
25
|
export { createTableCell, insertRow, removeRow, insertColumn, removeColumn, setColumnWidth, setRowHeight, mergeCells, splitCell, type TableCellRange, } from './document';
|
|
25
26
|
export type { PdfTokenType, PdfToken } from './content-stream';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file PDF text domain
|
|
3
|
+
*
|
|
4
|
+
* Exports types for PDF text handling.
|
|
5
|
+
*/
|
|
6
|
+
export type { PdfText, PdfTextBlock, PdfTextBlockParagraph, PdfTextFontMetrics, PdfTextEditState } from './types';
|
|
7
|
+
export { withTextContent, withFontFamily, withFontSize, withCharSpacing, } from './operations';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PdfText } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Update the text content of a PdfText element.
|
|
4
|
+
*
|
|
5
|
+
* When the text actually changes:
|
|
6
|
+
* - rawBytes and rawText are invalidated (set to undefined)
|
|
7
|
+
* - editState.textChanged is set to true
|
|
8
|
+
*
|
|
9
|
+
* When the text is identical to the current value, returns the element unchanged.
|
|
10
|
+
*/
|
|
11
|
+
export declare function withTextContent(element: PdfText, newText: string): PdfText;
|
|
12
|
+
/**
|
|
13
|
+
* Change the font family of a PdfText element.
|
|
14
|
+
*
|
|
15
|
+
* Updates baseFont to the new family and invalidates rawBytes/rawText
|
|
16
|
+
* since the encoding may differ. Sets editState.fontChanged and records
|
|
17
|
+
* the resolved font family for the writer to use during re-encoding.
|
|
18
|
+
*
|
|
19
|
+
* When the font family is identical to the current value, returns unchanged.
|
|
20
|
+
*/
|
|
21
|
+
export declare function withFontFamily(element: PdfText, fontFamily: string): PdfText;
|
|
22
|
+
/**
|
|
23
|
+
* Update the font size of a PdfText element.
|
|
24
|
+
*/
|
|
25
|
+
export declare function withFontSize(element: PdfText, fontSize: number): PdfText;
|
|
26
|
+
/**
|
|
27
|
+
* Update the character spacing (letter-spacing) of a PdfText element.
|
|
28
|
+
*/
|
|
29
|
+
export declare function withCharSpacing(element: PdfText, charSpacing: number | undefined): PdfText;
|
|
@@ -7,9 +7,16 @@ import { PdfColorSpace } from '../domain';
|
|
|
7
7
|
* - 1/2/4-bit: unpacked and scaled to 8-bit (0-255)
|
|
8
8
|
* - 16-bit: downsampled to 8-bit by taking the high byte
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type ConvertToRgbaParams = {
|
|
11
|
+
readonly data: Uint8Array;
|
|
12
|
+
readonly width: number;
|
|
13
|
+
readonly height: number;
|
|
14
|
+
readonly colorSpace: PdfColorSpace;
|
|
15
|
+
readonly bitsPerComponent: number;
|
|
11
16
|
readonly decode?: readonly number[];
|
|
12
|
-
}
|
|
17
|
+
};
|
|
18
|
+
/** Convert raw pixel data from any supported color space to RGBA. */
|
|
19
|
+
export declare function convertToRgba(p: ConvertToRgbaParams): Uint8ClampedArray;
|
|
13
20
|
/**
|
|
14
21
|
* DeviceGray → RGBA
|
|
15
22
|
* PDF Reference 8.6.4.2: 1 component (0=black, 1=white)
|
|
@@ -8,13 +8,14 @@ export { IDENTITY_MATRIX, multiplyMatrices, transformPoint, invertMatrix, transl
|
|
|
8
8
|
export type { PdfColorSpace, PdfAlternateColorSpace, PdfColor, PdfLineJoin, PdfLineCap, PdfTextRenderingMode, PdfGraphicsState, GraphicsStateStack, } from './domain';
|
|
9
9
|
export { DEFAULT_FILL_COLOR, DEFAULT_STROKE_COLOR, createDefaultGraphicsState, createGraphicsStateStack, } from './domain';
|
|
10
10
|
export type { PdfMoveTo, PdfLineTo, PdfCurveTo, PdfCurveToV, PdfCurveToY, PdfRect, PdfClosePath, PdfPathOp, PdfPaintOp, PdfPath, } from './domain';
|
|
11
|
-
export type { PdfText } from './domain';
|
|
11
|
+
export type { PdfText, PdfTextEditState } from './domain';
|
|
12
|
+
export { withTextContent, withFontFamily, withFontSize, withCharSpacing, } from './domain';
|
|
12
13
|
export type { PdfImage } from './domain';
|
|
13
14
|
export type { PdfElement, PdfPage, PdfDocument, PdfTable, PdfTableRow, PdfTableCell } from './domain';
|
|
14
15
|
export { isPdfPath, isPdfText, isPdfImage, isPdfTable } from './domain';
|
|
15
16
|
export type { PdfElementId } from './domain';
|
|
16
17
|
export { createElementId, parseElementId } from './domain';
|
|
17
|
-
export { getElementRotationRad, getElementRotationDeg, rotateElement, moveElement } from './domain';
|
|
18
|
+
export { getElementRotationRad, getElementRotationDeg, rotateElement, moveElement, scaleElement } from './domain';
|
|
18
19
|
export { updateElementInDocument, deleteElements, addElementsToPage, addPage, deletePages, duplicatePages, reorderPages, updatePageSize, } from './domain';
|
|
19
20
|
export { getPathBounds } from './domain';
|
|
20
21
|
export { createTableCell, insertRow, removeRow, insertColumn, removeColumn, setColumnWidth, setRowHeight, mergeCells, splitCell, type TableCellRange, } from './domain';
|
|
@@ -3,12 +3,15 @@ export type NativePdfEncryptionMode = {
|
|
|
3
3
|
readonly mode: "reject";
|
|
4
4
|
} | {
|
|
5
5
|
readonly mode: "ignore";
|
|
6
|
+
} | {
|
|
7
|
+
readonly mode: "auto";
|
|
6
8
|
} | {
|
|
7
9
|
readonly mode: "password";
|
|
8
10
|
readonly password: string;
|
|
9
11
|
};
|
|
10
12
|
export type NativePdfLoadOptions = Readonly<{
|
|
11
|
-
|
|
13
|
+
/** How to handle encrypted PDFs. Defaults to `"auto"` (try empty password). */
|
|
14
|
+
readonly encryption?: NativePdfEncryptionMode;
|
|
12
15
|
}>;
|
|
13
16
|
export type NativePdfMetadata = Readonly<{
|
|
14
17
|
readonly title?: string;
|
|
@@ -1,13 +1,46 @@
|
|
|
1
1
|
import { NativePdfPage, PdfDict } from '../../native';
|
|
2
2
|
import { ParsedIccProfile } from './icc-profile.native';
|
|
3
|
+
import { PdfFunction } from '../function/types';
|
|
4
|
+
type DeviceColorSpace = "DeviceGray" | "DeviceRGB" | "DeviceCMYK";
|
|
3
5
|
export type ParsedNamedColorSpace = Readonly<{
|
|
4
6
|
kind: "device";
|
|
5
|
-
colorSpace:
|
|
7
|
+
colorSpace: DeviceColorSpace;
|
|
6
8
|
}> | Readonly<{
|
|
7
9
|
kind: "iccBased";
|
|
8
10
|
n: number;
|
|
9
|
-
alternate:
|
|
11
|
+
alternate: DeviceColorSpace;
|
|
10
12
|
profile: ParsedIccProfile | null;
|
|
13
|
+
}> | Readonly<{
|
|
14
|
+
kind: "separation";
|
|
15
|
+
colorantName: string;
|
|
16
|
+
alternate: DeviceColorSpace;
|
|
17
|
+
alternateComponents: number;
|
|
18
|
+
tintTransform: PdfFunction | null;
|
|
19
|
+
}> | Readonly<{
|
|
20
|
+
kind: "deviceN";
|
|
21
|
+
colorantNames: readonly string[];
|
|
22
|
+
alternate: DeviceColorSpace;
|
|
23
|
+
alternateComponents: number;
|
|
24
|
+
tintTransform: PdfFunction | null;
|
|
25
|
+
}> | Readonly<{
|
|
26
|
+
kind: "indexed";
|
|
27
|
+
base: DeviceColorSpace;
|
|
28
|
+
hival: number;
|
|
29
|
+
lookup: Uint8Array;
|
|
30
|
+
}> | Readonly<{
|
|
31
|
+
kind: "calGray";
|
|
32
|
+
whitePoint: readonly [number, number, number];
|
|
33
|
+
gamma: number;
|
|
34
|
+
}> | Readonly<{
|
|
35
|
+
kind: "calRgb";
|
|
36
|
+
whitePoint: readonly [number, number, number];
|
|
37
|
+
gamma: readonly [number, number, number];
|
|
38
|
+
matrix: readonly number[];
|
|
39
|
+
}> | Readonly<{
|
|
40
|
+
kind: "lab";
|
|
41
|
+
whitePoint: readonly [number, number, number];
|
|
42
|
+
range: readonly [number, number, number, number];
|
|
11
43
|
}>;
|
|
12
44
|
/** Extract named color spaces from PDF page resources. */
|
|
13
45
|
export declare function extractColorSpacesFromResourcesNative(page: NativePdfPage, resources: PdfDict | null): ReadonlyMap<string, ParsedNamedColorSpace>;
|
|
46
|
+
export {};
|
|
@@ -6,6 +6,8 @@ export type PdfLoadEncryption = {
|
|
|
6
6
|
readonly mode: "reject";
|
|
7
7
|
} | {
|
|
8
8
|
readonly mode: "ignore";
|
|
9
|
+
} | {
|
|
10
|
+
readonly mode: "auto";
|
|
9
11
|
} | {
|
|
10
12
|
readonly mode: "password";
|
|
11
13
|
readonly password: string;
|
|
@@ -16,8 +18,8 @@ export type PdfLoadOptions = Readonly<{
|
|
|
16
18
|
* Used to keep call sites explicit and to preserve flexibility for future behaviors.
|
|
17
19
|
*/
|
|
18
20
|
readonly purpose: PdfLoadPurpose;
|
|
19
|
-
/** How to handle encrypted PDFs. */
|
|
20
|
-
readonly encryption
|
|
21
|
+
/** How to handle encrypted PDFs. Defaults to `"auto"` (try empty password). */
|
|
22
|
+
readonly encryption?: PdfLoadEncryption;
|
|
21
23
|
/**
|
|
22
24
|
* Historically forwarded to pdf-lib. Kept for API stability.
|
|
23
25
|
* Native loader ignores this field.
|