@cj-tech-master/excelts 9.4.2 → 9.5.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/browser/index.browser.d.ts +8 -5
- package/dist/browser/index.browser.js +19 -1
- package/dist/browser/index.d.ts +4 -2
- package/dist/browser/index.js +9 -1
- package/dist/browser/modules/excel/chart/cache-populator.d.ts +49 -0
- package/dist/browser/modules/excel/chart/cache-populator.js +1171 -0
- package/dist/browser/modules/excel/chart/chart-api.d.ts +92 -0
- package/dist/browser/modules/excel/chart/chart-api.js +364 -0
- package/dist/browser/modules/excel/chart/chart-builder.d.ts +48 -0
- package/dist/browser/modules/excel/chart/chart-builder.js +2432 -0
- package/dist/browser/modules/excel/chart/chart-ex-builder.d.ts +36 -0
- package/dist/browser/modules/excel/chart/chart-ex-builder.js +903 -0
- package/dist/browser/modules/excel/chart/chart-ex-parser.d.ts +8 -0
- package/dist/browser/modules/excel/chart/chart-ex-parser.js +1205 -0
- package/dist/browser/modules/excel/chart/chart-ex-renderer.d.ts +187 -0
- package/dist/browser/modules/excel/chart/chart-ex-renderer.js +5352 -0
- package/dist/browser/modules/excel/chart/chart-ex-types.d.ts +531 -0
- package/dist/browser/modules/excel/chart/chart-ex-types.js +11 -0
- package/dist/browser/modules/excel/chart/chart-images.d.ts +78 -0
- package/dist/browser/modules/excel/chart/chart-images.js +363 -0
- package/dist/browser/modules/excel/chart/chart-presets.d.ts +392 -0
- package/dist/browser/modules/excel/chart/chart-presets.js +179 -0
- package/dist/browser/modules/excel/chart/chart-renderer.d.ts +550 -0
- package/dist/browser/modules/excel/chart/chart-renderer.js +6440 -0
- package/dist/browser/modules/excel/chart/chart-sidecar.d.ts +21 -0
- package/dist/browser/modules/excel/chart/chart-sidecar.js +427 -0
- package/dist/browser/modules/excel/chart/chart-utils.d.ts +306 -0
- package/dist/browser/modules/excel/chart/chart-utils.js +821 -0
- package/dist/browser/modules/excel/chart/chart.d.ts +504 -0
- package/dist/browser/modules/excel/chart/chart.js +1320 -0
- package/dist/browser/modules/excel/chart/glyph-rasterizer.d.ts +62 -0
- package/dist/browser/modules/excel/chart/glyph-rasterizer.js +658 -0
- package/dist/browser/modules/excel/chart/index.d.ts +54 -0
- package/dist/browser/modules/excel/chart/index.js +46 -0
- package/dist/browser/modules/excel/chart/install.d.ts +44 -0
- package/dist/browser/modules/excel/chart/install.js +91 -0
- package/dist/browser/modules/excel/chart/shape-properties.d.ts +156 -0
- package/dist/browser/modules/excel/chart/shape-properties.js +1557 -0
- package/dist/browser/modules/excel/chart/stroke-font.d.ts +36 -0
- package/dist/browser/modules/excel/chart/stroke-font.js +1556 -0
- package/dist/browser/modules/excel/chart/topojson.d.ts +98 -0
- package/dist/browser/modules/excel/chart/topojson.js +236 -0
- package/dist/browser/modules/excel/chart/types.d.ts +2559 -0
- package/dist/browser/modules/excel/chart/types.js +8 -0
- package/dist/browser/modules/excel/chart-host-registry.d.ts +157 -0
- package/dist/browser/modules/excel/chart-host-registry.js +90 -0
- package/dist/browser/modules/excel/chartsheet.d.ts +102 -0
- package/dist/browser/modules/excel/chartsheet.js +196 -0
- package/dist/browser/modules/excel/defined-names.d.ts +35 -0
- package/dist/browser/modules/excel/defined-names.js +44 -4
- package/dist/browser/modules/excel/errors.d.ts +6 -0
- package/dist/browser/modules/excel/errors.js +9 -0
- package/dist/browser/modules/excel/form-control.d.ts +6 -0
- package/dist/browser/modules/excel/form-control.js +17 -0
- package/dist/browser/modules/excel/image.js +12 -2
- package/dist/browser/modules/excel/pivot-chart.d.ts +7 -0
- package/dist/browser/modules/excel/pivot-chart.js +53 -0
- package/dist/browser/modules/excel/pivot-table.d.ts +55 -0
- package/dist/browser/modules/excel/pivot-table.js +35 -0
- package/dist/browser/modules/excel/range.js +5 -1
- package/dist/browser/modules/excel/sparkline/index.d.ts +7 -0
- package/dist/browser/modules/excel/sparkline/index.js +7 -0
- package/dist/browser/modules/excel/sparkline/sparkline.d.ts +206 -0
- package/dist/browser/modules/excel/sparkline/sparkline.js +750 -0
- package/dist/browser/modules/excel/stream/worksheet-writer.js +3 -2
- package/dist/browser/modules/excel/table.js +42 -6
- package/dist/browser/modules/excel/types.d.ts +72 -0
- package/dist/browser/modules/excel/utils/address.d.ts +18 -0
- package/dist/browser/modules/excel/utils/address.js +28 -0
- package/dist/browser/modules/excel/utils/drawing-utils.js +11 -6
- package/dist/browser/modules/excel/utils/guid.d.ts +15 -0
- package/dist/browser/modules/excel/utils/guid.js +35 -0
- package/dist/browser/modules/excel/utils/ooxml-paths.d.ts +74 -0
- package/dist/browser/modules/excel/utils/ooxml-paths.js +206 -9
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chart-sidecar.d.ts +35 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +101 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chart.d.ts +32 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chart.js +2125 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chartsheet.d.ts +9 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-chartsheet.js +26 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-content-types.d.ts +16 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-content-types.js +181 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-drawing.d.ts +34 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-drawing.js +267 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-pivot.d.ts +14 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-pivot.js +104 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-relationships.d.ts +18 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-relationships.js +184 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-structure.d.ts +21 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-structure.js +56 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-styles.d.ts +15 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-styles.js +89 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-table.d.ts +31 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-table.js +177 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-workbook.d.ts +19 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-workbook.js +163 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-worksheet.d.ts +25 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/check-worksheet.js +569 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/context.d.ts +85 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/context.js +191 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/index.d.ts +31 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/index.js +102 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/path-utils.d.ts +67 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/path-utils.js +156 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/reporter.d.ts +41 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/reporter.js +61 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/types.d.ts +109 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/types.js +12 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/xml-utils.d.ts +38 -0
- package/dist/browser/modules/excel/utils/ooxml-validator/xml-utils.js +100 -0
- package/dist/browser/modules/excel/workbook.browser.d.ts +248 -30
- package/dist/browser/modules/excel/workbook.browser.js +966 -31
- package/dist/browser/modules/excel/workbook.d.ts +43 -0
- package/dist/browser/modules/excel/workbook.js +48 -0
- package/dist/browser/modules/excel/worksheet.d.ts +157 -3
- package/dist/browser/modules/excel/worksheet.js +394 -35
- package/dist/browser/modules/excel/xlsx/rel-type.d.ts +40 -0
- package/dist/browser/modules/excel/xlsx/rel-type.js +41 -1
- package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
- package/dist/browser/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
- package/dist/browser/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
- package/dist/browser/modules/excel/xlsx/xform/chart/chart-space-xform.d.ts +353 -0
- package/dist/browser/modules/excel/xlsx/xform/chart/chart-space-xform.js +6000 -0
- package/dist/browser/modules/excel/xlsx/xform/comment/threaded-comments-xform.d.ts +60 -0
- package/dist/browser/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +213 -0
- package/dist/browser/modules/excel/xlsx/xform/core/content-types-xform.js +150 -11
- package/dist/browser/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +30 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
- package/dist/browser/modules/excel/xlsx/xform/drawing/graphic-frame-xform.d.ts +54 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +225 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +3 -1
- package/dist/browser/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
- package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +46 -0
- package/dist/browser/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +13 -2
- package/dist/browser/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
- package/dist/browser/modules/excel/xlsx/xform/sheet/chartsheet-xform.d.ts +185 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +441 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/ext-lst-xform.d.ts +1 -0
- package/dist/browser/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
- package/dist/browser/modules/excel/xlsx/xform/sheet/worksheet-xform.js +196 -20
- package/dist/browser/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
- package/dist/browser/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
- package/dist/browser/modules/excel/xlsx/xform/xsd-values.d.ts +63 -0
- package/dist/browser/modules/excel/xlsx/xform/xsd-values.js +101 -0
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +115 -21
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +4422 -78
- package/dist/browser/modules/pdf/builder/document-builder.d.ts +74 -0
- package/dist/browser/modules/pdf/builder/document-builder.js +507 -2
- package/dist/browser/modules/pdf/builder/pdf-editor.js +48 -3
- package/dist/browser/modules/pdf/excel-bridge.d.ts +69 -0
- package/dist/browser/modules/pdf/excel-bridge.js +683 -12
- package/dist/browser/modules/pdf/font/font-manager.d.ts +25 -0
- package/dist/browser/modules/pdf/font/font-manager.js +39 -0
- package/dist/browser/modules/pdf/index.d.ts +5 -2
- package/dist/browser/modules/pdf/index.js +3 -1
- package/dist/browser/modules/pdf/render/chart-surface.d.ts +33 -0
- package/dist/browser/modules/pdf/render/chart-surface.js +200 -0
- package/dist/browser/modules/pdf/render/layout-engine.d.ts +22 -1
- package/dist/browser/modules/pdf/render/layout-engine.js +436 -56
- package/dist/browser/modules/pdf/render/page-renderer.js +169 -28
- package/dist/browser/modules/pdf/render/pdf-exporter.js +117 -7
- package/dist/browser/modules/pdf/types.d.ts +227 -23
- package/dist/browser/modules/pdf/types.js +4 -0
- package/dist/browser/modules/pdf/word-bridge.d.ts +47 -0
- package/dist/browser/modules/pdf/word-bridge.js +304 -0
- package/dist/browser/modules/word/constants.d.ts +179 -0
- package/dist/browser/modules/word/constants.js +231 -0
- package/dist/browser/modules/word/content-types.d.ts +27 -0
- package/dist/browser/modules/word/content-types.js +53 -0
- package/dist/browser/modules/word/digital-signatures.d.ts +87 -0
- package/dist/browser/modules/word/digital-signatures.js +134 -0
- package/dist/browser/modules/word/document.d.ts +728 -0
- package/dist/browser/modules/word/document.js +1795 -0
- package/dist/browser/modules/word/docx-packager.d.ts +14 -0
- package/dist/browser/modules/word/docx-packager.js +822 -0
- package/dist/browser/modules/word/docx-reader.d.ts +11 -0
- package/dist/browser/modules/word/docx-reader.js +4929 -0
- package/dist/browser/modules/word/encryption.d.ts +102 -0
- package/dist/browser/modules/word/encryption.js +274 -0
- package/dist/browser/modules/word/errors.d.ts +49 -0
- package/dist/browser/modules/word/errors.js +68 -0
- package/dist/browser/modules/word/font-obfuscation.d.ts +31 -0
- package/dist/browser/modules/word/font-obfuscation.js +83 -0
- package/dist/browser/modules/word/html-renderer.d.ts +38 -0
- package/dist/browser/modules/word/html-renderer.js +782 -0
- package/dist/browser/modules/word/index.base.d.ts +19 -0
- package/dist/browser/modules/word/index.base.js +51 -0
- package/dist/browser/modules/word/index.browser.d.ts +4 -0
- package/dist/browser/modules/word/index.browser.js +4 -0
- package/dist/browser/modules/word/index.d.ts +4 -0
- package/dist/browser/modules/word/index.js +4 -0
- package/dist/browser/modules/word/internal-utils.d.ts +23 -0
- package/dist/browser/modules/word/internal-utils.js +54 -0
- package/dist/browser/modules/word/relationships.d.ts +31 -0
- package/dist/browser/modules/word/relationships.js +56 -0
- package/dist/browser/modules/word/types.d.ts +2325 -0
- package/dist/browser/modules/word/types.js +10 -0
- package/dist/browser/modules/word/units.d.ts +49 -0
- package/dist/browser/modules/word/units.js +111 -0
- package/dist/browser/modules/word/writers/chart-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/chart-writer.js +385 -0
- package/dist/browser/modules/word/writers/checkbox-writer.d.ts +9 -0
- package/dist/browser/modules/word/writers/checkbox-writer.js +42 -0
- package/dist/browser/modules/word/writers/comment-writer.d.ts +15 -0
- package/dist/browser/modules/word/writers/comment-writer.js +70 -0
- package/dist/browser/modules/word/writers/document-writer.d.ts +16 -0
- package/dist/browser/modules/word/writers/document-writer.js +461 -0
- package/dist/browser/modules/word/writers/footnote-writer.d.ts +11 -0
- package/dist/browser/modules/word/writers/footnote-writer.js +72 -0
- package/dist/browser/modules/word/writers/header-footer-writer.d.ts +13 -0
- package/dist/browser/modules/word/writers/header-footer-writer.js +129 -0
- package/dist/browser/modules/word/writers/image-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/image-writer.js +185 -0
- package/dist/browser/modules/word/writers/math-writer.d.ts +9 -0
- package/dist/browser/modules/word/writers/math-writer.js +428 -0
- package/dist/browser/modules/word/writers/numbering-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/numbering-writer.js +125 -0
- package/dist/browser/modules/word/writers/paragraph-writer.d.ts +13 -0
- package/dist/browser/modules/word/writers/paragraph-writer.js +516 -0
- package/dist/browser/modules/word/writers/parts-writer.d.ts +26 -0
- package/dist/browser/modules/word/writers/parts-writer.js +660 -0
- package/dist/browser/modules/word/writers/run-writer.d.ts +15 -0
- package/dist/browser/modules/word/writers/run-writer.js +649 -0
- package/dist/browser/modules/word/writers/section-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/section-writer.js +238 -0
- package/dist/browser/modules/word/writers/styles-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/styles-writer.js +242 -0
- package/dist/browser/modules/word/writers/table-writer.d.ts +10 -0
- package/dist/browser/modules/word/writers/table-writer.js +503 -0
- package/dist/browser/modules/word/writers/textbox-writer.d.ts +9 -0
- package/dist/browser/modules/word/writers/textbox-writer.js +53 -0
- package/dist/browser/modules/word/writers/toc-writer.d.ts +9 -0
- package/dist/browser/modules/word/writers/toc-writer.js +79 -0
- package/dist/browser/modules/xml/encode.d.ts +56 -7
- package/dist/browser/modules/xml/encode.js +157 -11
- package/dist/cjs/index.js +13 -2
- package/dist/cjs/modules/excel/chart/cache-populator.js +1178 -0
- package/dist/cjs/modules/excel/chart/chart-api.js +371 -0
- package/dist/cjs/modules/excel/chart/chart-builder.js +2440 -0
- package/dist/cjs/modules/excel/chart/chart-ex-builder.js +907 -0
- package/dist/cjs/modules/excel/chart/chart-ex-parser.js +1208 -0
- package/dist/cjs/modules/excel/chart/chart-ex-renderer.js +5364 -0
- package/dist/cjs/modules/excel/chart/chart-ex-types.js +12 -0
- package/dist/cjs/modules/excel/chart/chart-images.js +366 -0
- package/dist/cjs/modules/excel/chart/chart-presets.js +184 -0
- package/dist/cjs/modules/excel/chart/chart-renderer.js +6450 -0
- package/dist/cjs/modules/excel/chart/chart-sidecar.js +433 -0
- package/dist/cjs/modules/excel/chart/chart-utils.js +845 -0
- package/dist/cjs/modules/excel/chart/chart.js +1324 -0
- package/dist/cjs/modules/excel/chart/glyph-rasterizer.js +664 -0
- package/dist/cjs/modules/excel/chart/index.js +101 -0
- package/dist/cjs/modules/excel/chart/install.js +95 -0
- package/dist/cjs/modules/excel/chart/shape-properties.js +1577 -0
- package/dist/cjs/modules/excel/chart/stroke-font.js +1559 -0
- package/dist/cjs/modules/excel/chart/topojson.js +239 -0
- package/dist/cjs/modules/excel/chart/types.js +9 -0
- package/dist/cjs/modules/excel/chart-host-registry.js +96 -0
- package/dist/cjs/modules/excel/chartsheet.js +199 -0
- package/dist/cjs/modules/excel/defined-names.js +44 -4
- package/dist/cjs/modules/excel/errors.js +11 -1
- package/dist/cjs/modules/excel/form-control.js +17 -0
- package/dist/cjs/modules/excel/image.js +12 -2
- package/dist/cjs/modules/excel/pivot-chart.js +56 -0
- package/dist/cjs/modules/excel/pivot-table.js +35 -0
- package/dist/cjs/modules/excel/range.js +5 -1
- package/dist/cjs/modules/excel/sparkline/index.js +23 -0
- package/dist/cjs/modules/excel/sparkline/sparkline.js +756 -0
- package/dist/cjs/modules/excel/stream/worksheet-writer.js +3 -2
- package/dist/cjs/modules/excel/table.js +42 -6
- package/dist/cjs/modules/excel/utils/address.js +29 -0
- package/dist/cjs/modules/excel/utils/drawing-utils.js +11 -6
- package/dist/cjs/modules/excel/utils/guid.js +38 -0
- package/dist/cjs/modules/excel/utils/ooxml-paths.js +246 -9
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +103 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-chart.js +2128 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-chartsheet.js +29 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-content-types.js +184 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-drawing.js +270 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-pivot.js +107 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-relationships.js +188 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-structure.js +60 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-styles.js +92 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-table.js +180 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-workbook.js +166 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/check-worksheet.js +572 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/context.js +196 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/index.js +105 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/path-utils.js +168 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/reporter.js +66 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/types.js +13 -0
- package/dist/cjs/modules/excel/utils/ooxml-validator/xml-utils.js +110 -0
- package/dist/cjs/modules/excel/workbook.browser.js +973 -38
- package/dist/cjs/modules/excel/workbook.js +48 -0
- package/dist/cjs/modules/excel/worksheet.js +393 -34
- package/dist/cjs/modules/excel/xlsx/rel-type.js +41 -1
- package/dist/cjs/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
- package/dist/cjs/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
- package/dist/cjs/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
- package/dist/cjs/modules/excel/xlsx/xform/chart/chart-space-xform.js +6003 -0
- package/dist/cjs/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +219 -0
- package/dist/cjs/modules/excel/xlsx/xform/core/content-types-xform.js +149 -10
- package/dist/cjs/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
- package/dist/cjs/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
- package/dist/cjs/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +228 -0
- package/dist/cjs/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
- package/dist/cjs/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
- package/dist/cjs/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
- package/dist/cjs/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +444 -0
- package/dist/cjs/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
- package/dist/cjs/modules/excel/xlsx/xform/sheet/worksheet-xform.js +195 -19
- package/dist/cjs/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
- package/dist/cjs/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
- package/dist/cjs/modules/excel/xlsx/xform/xsd-values.js +106 -0
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +4420 -76
- package/dist/cjs/modules/pdf/builder/document-builder.js +506 -1
- package/dist/cjs/modules/pdf/builder/pdf-editor.js +48 -3
- package/dist/cjs/modules/pdf/excel-bridge.js +684 -12
- package/dist/cjs/modules/pdf/font/font-manager.js +39 -0
- package/dist/cjs/modules/pdf/index.js +5 -1
- package/dist/cjs/modules/pdf/render/chart-surface.js +203 -0
- package/dist/cjs/modules/pdf/render/layout-engine.js +437 -56
- package/dist/cjs/modules/pdf/render/page-renderer.js +169 -28
- package/dist/cjs/modules/pdf/render/pdf-exporter.js +115 -5
- package/dist/cjs/modules/pdf/types.js +5 -0
- package/dist/cjs/modules/pdf/word-bridge.js +307 -0
- package/dist/cjs/modules/word/constants.js +234 -0
- package/dist/cjs/modules/word/content-types.js +57 -0
- package/dist/cjs/modules/word/digital-signatures.js +140 -0
- package/dist/cjs/modules/word/document.js +1909 -0
- package/dist/cjs/modules/word/docx-packager.js +825 -0
- package/dist/cjs/modules/word/docx-reader.js +4932 -0
- package/dist/cjs/modules/word/encryption.js +282 -0
- package/dist/cjs/modules/word/errors.js +88 -0
- package/dist/cjs/modules/word/font-obfuscation.js +88 -0
- package/dist/cjs/modules/word/html-renderer.js +785 -0
- package/dist/cjs/modules/word/index.base.js +199 -0
- package/dist/cjs/modules/word/index.browser.js +20 -0
- package/dist/cjs/modules/word/index.js +20 -0
- package/dist/cjs/modules/word/internal-utils.js +59 -0
- package/dist/cjs/modules/word/relationships.js +60 -0
- package/dist/cjs/modules/word/types.js +11 -0
- package/dist/cjs/modules/word/units.js +135 -0
- package/dist/cjs/modules/word/writers/chart-writer.js +388 -0
- package/dist/cjs/modules/word/writers/checkbox-writer.js +45 -0
- package/dist/cjs/modules/word/writers/comment-writer.js +74 -0
- package/dist/cjs/modules/word/writers/document-writer.js +465 -0
- package/dist/cjs/modules/word/writers/footnote-writer.js +76 -0
- package/dist/cjs/modules/word/writers/header-footer-writer.js +134 -0
- package/dist/cjs/modules/word/writers/image-writer.js +188 -0
- package/dist/cjs/modules/word/writers/math-writer.js +431 -0
- package/dist/cjs/modules/word/writers/numbering-writer.js +128 -0
- package/dist/cjs/modules/word/writers/paragraph-writer.js +521 -0
- package/dist/cjs/modules/word/writers/parts-writer.js +671 -0
- package/dist/cjs/modules/word/writers/run-writer.js +655 -0
- package/dist/cjs/modules/word/writers/section-writer.js +241 -0
- package/dist/cjs/modules/word/writers/styles-writer.js +245 -0
- package/dist/cjs/modules/word/writers/table-writer.js +506 -0
- package/dist/cjs/modules/word/writers/textbox-writer.js +56 -0
- package/dist/cjs/modules/word/writers/toc-writer.js +82 -0
- package/dist/cjs/modules/xml/encode.js +158 -11
- package/dist/esm/index.browser.js +20 -2
- package/dist/esm/index.js +9 -1
- package/dist/esm/modules/excel/chart/cache-populator.js +1171 -0
- package/dist/esm/modules/excel/chart/chart-api.js +364 -0
- package/dist/esm/modules/excel/chart/chart-builder.js +2432 -0
- package/dist/esm/modules/excel/chart/chart-ex-builder.js +903 -0
- package/dist/esm/modules/excel/chart/chart-ex-parser.js +1205 -0
- package/dist/esm/modules/excel/chart/chart-ex-renderer.js +5352 -0
- package/dist/esm/modules/excel/chart/chart-ex-types.js +11 -0
- package/dist/esm/modules/excel/chart/chart-images.js +363 -0
- package/dist/esm/modules/excel/chart/chart-presets.js +179 -0
- package/dist/esm/modules/excel/chart/chart-renderer.js +6440 -0
- package/dist/esm/modules/excel/chart/chart-sidecar.js +427 -0
- package/dist/esm/modules/excel/chart/chart-utils.js +821 -0
- package/dist/esm/modules/excel/chart/chart.js +1320 -0
- package/dist/esm/modules/excel/chart/glyph-rasterizer.js +658 -0
- package/dist/esm/modules/excel/chart/index.js +46 -0
- package/dist/esm/modules/excel/chart/install.js +91 -0
- package/dist/esm/modules/excel/chart/shape-properties.js +1557 -0
- package/dist/esm/modules/excel/chart/stroke-font.js +1556 -0
- package/dist/esm/modules/excel/chart/topojson.js +236 -0
- package/dist/esm/modules/excel/chart/types.js +8 -0
- package/dist/esm/modules/excel/chart-host-registry.js +90 -0
- package/dist/esm/modules/excel/chartsheet.js +196 -0
- package/dist/esm/modules/excel/defined-names.js +44 -4
- package/dist/esm/modules/excel/errors.js +9 -0
- package/dist/esm/modules/excel/form-control.js +17 -0
- package/dist/esm/modules/excel/image.js +12 -2
- package/dist/esm/modules/excel/pivot-chart.js +53 -0
- package/dist/esm/modules/excel/pivot-table.js +35 -0
- package/dist/esm/modules/excel/range.js +5 -1
- package/dist/esm/modules/excel/sparkline/index.js +7 -0
- package/dist/esm/modules/excel/sparkline/sparkline.js +750 -0
- package/dist/esm/modules/excel/stream/worksheet-writer.js +3 -2
- package/dist/esm/modules/excel/table.js +42 -6
- package/dist/esm/modules/excel/utils/address.js +28 -0
- package/dist/esm/modules/excel/utils/drawing-utils.js +11 -6
- package/dist/esm/modules/excel/utils/guid.js +35 -0
- package/dist/esm/modules/excel/utils/ooxml-paths.js +206 -9
- package/dist/esm/modules/excel/utils/ooxml-validator/check-chart-sidecar.js +101 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-chart.js +2125 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-chartsheet.js +26 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-content-types.js +181 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-drawing.js +267 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-pivot.js +104 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-relationships.js +184 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-structure.js +56 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-styles.js +89 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-table.js +177 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-workbook.js +163 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/check-worksheet.js +569 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/context.js +191 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/index.js +102 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/path-utils.js +156 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/reporter.js +61 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/types.js +12 -0
- package/dist/esm/modules/excel/utils/ooxml-validator/xml-utils.js +100 -0
- package/dist/esm/modules/excel/workbook.browser.js +969 -34
- package/dist/esm/modules/excel/workbook.js +48 -0
- package/dist/esm/modules/excel/worksheet.js +394 -35
- package/dist/esm/modules/excel/xlsx/rel-type.js +41 -1
- package/dist/esm/modules/excel/xlsx/xform/book/defined-name-xform.js +11 -2
- package/dist/esm/modules/excel/xlsx/xform/book/external-link-xform.js +12 -10
- package/dist/esm/modules/excel/xlsx/xform/book/workbook-xform.js +96 -22
- package/dist/esm/modules/excel/xlsx/xform/chart/chart-space-xform.js +6000 -0
- package/dist/esm/modules/excel/xlsx/xform/comment/threaded-comments-xform.js +213 -0
- package/dist/esm/modules/excel/xlsx/xform/core/content-types-xform.js +150 -11
- package/dist/esm/modules/excel/xlsx/xform/drawing/absolute-anchor-xform.js +20 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/base-cell-anchor-xform.js +1 -1
- package/dist/esm/modules/excel/xlsx/xform/drawing/drawing-xform.js +109 -5
- package/dist/esm/modules/excel/xlsx/xform/drawing/graphic-frame-xform.js +225 -0
- package/dist/esm/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.js +18 -3
- package/dist/esm/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.js +294 -12
- package/dist/esm/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.js +32 -6
- package/dist/esm/modules/excel/xlsx/xform/sheet/chartsheet-xform.js +441 -0
- package/dist/esm/modules/excel/xlsx/xform/sheet/ext-lst-xform.js +51 -2
- package/dist/esm/modules/excel/xlsx/xform/sheet/worksheet-xform.js +196 -20
- package/dist/esm/modules/excel/xlsx/xform/table/auto-filter-xform.js +16 -1
- package/dist/esm/modules/excel/xlsx/xform/table/table-column-xform.js +17 -2
- package/dist/esm/modules/excel/xlsx/xform/xsd-values.js +101 -0
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +4422 -78
- package/dist/esm/modules/pdf/builder/document-builder.js +507 -2
- package/dist/esm/modules/pdf/builder/pdf-editor.js +48 -3
- package/dist/esm/modules/pdf/excel-bridge.js +683 -12
- package/dist/esm/modules/pdf/font/font-manager.js +39 -0
- package/dist/esm/modules/pdf/index.js +3 -1
- package/dist/esm/modules/pdf/render/chart-surface.js +200 -0
- package/dist/esm/modules/pdf/render/layout-engine.js +436 -56
- package/dist/esm/modules/pdf/render/page-renderer.js +169 -28
- package/dist/esm/modules/pdf/render/pdf-exporter.js +117 -7
- package/dist/esm/modules/pdf/types.js +4 -0
- package/dist/esm/modules/pdf/word-bridge.js +304 -0
- package/dist/esm/modules/word/constants.js +231 -0
- package/dist/esm/modules/word/content-types.js +53 -0
- package/dist/esm/modules/word/digital-signatures.js +134 -0
- package/dist/esm/modules/word/document.js +1795 -0
- package/dist/esm/modules/word/docx-packager.js +822 -0
- package/dist/esm/modules/word/docx-reader.js +4929 -0
- package/dist/esm/modules/word/encryption.js +274 -0
- package/dist/esm/modules/word/errors.js +68 -0
- package/dist/esm/modules/word/font-obfuscation.js +83 -0
- package/dist/esm/modules/word/html-renderer.js +782 -0
- package/dist/esm/modules/word/index.base.js +51 -0
- package/dist/esm/modules/word/index.browser.js +4 -0
- package/dist/esm/modules/word/index.js +4 -0
- package/dist/esm/modules/word/internal-utils.js +54 -0
- package/dist/esm/modules/word/relationships.js +56 -0
- package/dist/esm/modules/word/types.js +10 -0
- package/dist/esm/modules/word/units.js +111 -0
- package/dist/esm/modules/word/writers/chart-writer.js +385 -0
- package/dist/esm/modules/word/writers/checkbox-writer.js +42 -0
- package/dist/esm/modules/word/writers/comment-writer.js +70 -0
- package/dist/esm/modules/word/writers/document-writer.js +461 -0
- package/dist/esm/modules/word/writers/footnote-writer.js +72 -0
- package/dist/esm/modules/word/writers/header-footer-writer.js +129 -0
- package/dist/esm/modules/word/writers/image-writer.js +185 -0
- package/dist/esm/modules/word/writers/math-writer.js +428 -0
- package/dist/esm/modules/word/writers/numbering-writer.js +125 -0
- package/dist/esm/modules/word/writers/paragraph-writer.js +516 -0
- package/dist/esm/modules/word/writers/parts-writer.js +660 -0
- package/dist/esm/modules/word/writers/run-writer.js +649 -0
- package/dist/esm/modules/word/writers/section-writer.js +238 -0
- package/dist/esm/modules/word/writers/styles-writer.js +242 -0
- package/dist/esm/modules/word/writers/table-writer.js +503 -0
- package/dist/esm/modules/word/writers/textbox-writer.js +53 -0
- package/dist/esm/modules/word/writers/toc-writer.js +79 -0
- package/dist/esm/modules/xml/encode.js +157 -11
- package/dist/iife/excelts.iife.js +11789 -687
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +52 -44
- package/dist/types/index.browser.d.ts +8 -5
- package/dist/types/index.d.ts +4 -2
- package/dist/types/modules/excel/chart/cache-populator.d.ts +49 -0
- package/dist/types/modules/excel/chart/chart-api.d.ts +92 -0
- package/dist/types/modules/excel/chart/chart-builder.d.ts +48 -0
- package/dist/types/modules/excel/chart/chart-ex-builder.d.ts +36 -0
- package/dist/types/modules/excel/chart/chart-ex-parser.d.ts +8 -0
- package/dist/types/modules/excel/chart/chart-ex-renderer.d.ts +187 -0
- package/dist/types/modules/excel/chart/chart-ex-types.d.ts +531 -0
- package/dist/types/modules/excel/chart/chart-images.d.ts +78 -0
- package/dist/types/modules/excel/chart/chart-presets.d.ts +392 -0
- package/dist/types/modules/excel/chart/chart-renderer.d.ts +550 -0
- package/dist/types/modules/excel/chart/chart-sidecar.d.ts +21 -0
- package/dist/types/modules/excel/chart/chart-utils.d.ts +306 -0
- package/dist/types/modules/excel/chart/chart.d.ts +504 -0
- package/dist/types/modules/excel/chart/glyph-rasterizer.d.ts +62 -0
- package/dist/types/modules/excel/chart/index.d.ts +54 -0
- package/dist/types/modules/excel/chart/install.d.ts +44 -0
- package/dist/types/modules/excel/chart/shape-properties.d.ts +156 -0
- package/dist/types/modules/excel/chart/stroke-font.d.ts +36 -0
- package/dist/types/modules/excel/chart/topojson.d.ts +98 -0
- package/dist/types/modules/excel/chart/types.d.ts +2559 -0
- package/dist/types/modules/excel/chart-host-registry.d.ts +157 -0
- package/dist/types/modules/excel/chartsheet.d.ts +102 -0
- package/dist/types/modules/excel/defined-names.d.ts +35 -0
- package/dist/types/modules/excel/errors.d.ts +6 -0
- package/dist/types/modules/excel/form-control.d.ts +6 -0
- package/dist/types/modules/excel/pivot-chart.d.ts +7 -0
- package/dist/types/modules/excel/pivot-table.d.ts +55 -0
- package/dist/types/modules/excel/sparkline/index.d.ts +7 -0
- package/dist/types/modules/excel/sparkline/sparkline.d.ts +206 -0
- package/dist/types/modules/excel/types.d.ts +72 -0
- package/dist/types/modules/excel/utils/address.d.ts +18 -0
- package/dist/types/modules/excel/utils/guid.d.ts +15 -0
- package/dist/types/modules/excel/utils/ooxml-paths.d.ts +74 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-chart-sidecar.d.ts +35 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-chart.d.ts +32 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-chartsheet.d.ts +9 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-content-types.d.ts +16 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-drawing.d.ts +34 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-pivot.d.ts +14 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-relationships.d.ts +18 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-structure.d.ts +21 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-styles.d.ts +15 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-table.d.ts +31 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-workbook.d.ts +19 -0
- package/dist/types/modules/excel/utils/ooxml-validator/check-worksheet.d.ts +25 -0
- package/dist/types/modules/excel/utils/ooxml-validator/context.d.ts +85 -0
- package/dist/types/modules/excel/utils/ooxml-validator/index.d.ts +31 -0
- package/dist/types/modules/excel/utils/ooxml-validator/path-utils.d.ts +67 -0
- package/dist/types/modules/excel/utils/ooxml-validator/reporter.d.ts +41 -0
- package/dist/types/modules/excel/utils/ooxml-validator/types.d.ts +109 -0
- package/dist/types/modules/excel/utils/ooxml-validator/xml-utils.d.ts +38 -0
- package/dist/types/modules/excel/workbook.browser.d.ts +248 -30
- package/dist/types/modules/excel/workbook.d.ts +43 -0
- package/dist/types/modules/excel/worksheet.d.ts +157 -3
- package/dist/types/modules/excel/xlsx/rel-type.d.ts +40 -0
- package/dist/types/modules/excel/xlsx/xform/book/defined-name-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/chart/chart-space-xform.d.ts +353 -0
- package/dist/types/modules/excel/xlsx/xform/comment/threaded-comments-xform.d.ts +60 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/drawing-xform.d.ts +30 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/graphic-frame-xform.d.ts +54 -0
- package/dist/types/modules/excel/xlsx/xform/drawing/one-cell-anchor-xform.d.ts +3 -1
- package/dist/types/modules/excel/xlsx/xform/drawing/two-cell-anchor-xform.d.ts +46 -0
- package/dist/types/modules/excel/xlsx/xform/pivot-table/pivot-table-xform.d.ts +13 -2
- package/dist/types/modules/excel/xlsx/xform/sheet/chartsheet-xform.d.ts +185 -0
- package/dist/types/modules/excel/xlsx/xform/sheet/ext-lst-xform.d.ts +1 -0
- package/dist/types/modules/excel/xlsx/xform/xsd-values.d.ts +63 -0
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +115 -21
- package/dist/types/modules/pdf/builder/document-builder.d.ts +74 -0
- package/dist/types/modules/pdf/excel-bridge.d.ts +69 -0
- package/dist/types/modules/pdf/font/font-manager.d.ts +25 -0
- package/dist/types/modules/pdf/index.d.ts +5 -2
- package/dist/types/modules/pdf/render/chart-surface.d.ts +33 -0
- package/dist/types/modules/pdf/render/layout-engine.d.ts +22 -1
- package/dist/types/modules/pdf/types.d.ts +227 -23
- package/dist/types/modules/pdf/word-bridge.d.ts +47 -0
- package/dist/types/modules/word/constants.d.ts +179 -0
- package/dist/types/modules/word/content-types.d.ts +27 -0
- package/dist/types/modules/word/digital-signatures.d.ts +87 -0
- package/dist/types/modules/word/document.d.ts +728 -0
- package/dist/types/modules/word/docx-packager.d.ts +14 -0
- package/dist/types/modules/word/docx-reader.d.ts +11 -0
- package/dist/types/modules/word/encryption.d.ts +102 -0
- package/dist/types/modules/word/errors.d.ts +49 -0
- package/dist/types/modules/word/font-obfuscation.d.ts +31 -0
- package/dist/types/modules/word/html-renderer.d.ts +38 -0
- package/dist/types/modules/word/index.base.d.ts +19 -0
- package/dist/types/modules/word/index.browser.d.ts +4 -0
- package/dist/types/modules/word/index.d.ts +4 -0
- package/dist/types/modules/word/internal-utils.d.ts +23 -0
- package/dist/types/modules/word/relationships.d.ts +31 -0
- package/dist/types/modules/word/types.d.ts +2325 -0
- package/dist/types/modules/word/units.d.ts +49 -0
- package/dist/types/modules/word/writers/chart-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/checkbox-writer.d.ts +9 -0
- package/dist/types/modules/word/writers/comment-writer.d.ts +15 -0
- package/dist/types/modules/word/writers/document-writer.d.ts +16 -0
- package/dist/types/modules/word/writers/footnote-writer.d.ts +11 -0
- package/dist/types/modules/word/writers/header-footer-writer.d.ts +13 -0
- package/dist/types/modules/word/writers/image-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/math-writer.d.ts +9 -0
- package/dist/types/modules/word/writers/numbering-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/paragraph-writer.d.ts +13 -0
- package/dist/types/modules/word/writers/parts-writer.d.ts +26 -0
- package/dist/types/modules/word/writers/run-writer.d.ts +15 -0
- package/dist/types/modules/word/writers/section-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/styles-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/table-writer.d.ts +10 -0
- package/dist/types/modules/word/writers/textbox-writer.d.ts +9 -0
- package/dist/types/modules/word/writers/toc-writer.d.ts +9 -0
- package/dist/types/modules/xml/encode.d.ts +56 -7
- package/package.json +29 -11
- package/dist/browser/modules/excel/utils/ooxml-validator.d.ts +0 -48
- package/dist/browser/modules/excel/utils/ooxml-validator.js +0 -493
- package/dist/browser/modules/excel/utils/passthrough-manager.d.ts +0 -77
- package/dist/browser/modules/excel/utils/passthrough-manager.js +0 -129
- package/dist/cjs/modules/excel/utils/ooxml-validator.js +0 -499
- package/dist/cjs/modules/excel/utils/passthrough-manager.js +0 -133
- package/dist/esm/modules/excel/utils/ooxml-validator.js +0 -493
- package/dist/esm/modules/excel/utils/passthrough-manager.js +0 -129
- package/dist/types/modules/excel/utils/ooxml-validator.d.ts +0 -48
- package/dist/types/modules/excel/utils/passthrough-manager.d.ts +0 -77
|
@@ -24,8 +24,9 @@ import { PdfContentStream } from "../core/pdf-stream.js";
|
|
|
24
24
|
import { PdfWriter } from "../core/pdf-writer.js";
|
|
25
25
|
import { writePdfAMetadata, writePdfAOutputIntent } from "../core/pdfa.js";
|
|
26
26
|
import { FontManager } from "../font/font-manager.js";
|
|
27
|
+
import { discoverSystemFontCandidates } from "../font/system-fonts.js";
|
|
27
28
|
import { parseTtf } from "../font/ttf-parser.js";
|
|
28
|
-
import { wrapTextLines, emitTextWithMatrix } from "../render/page-renderer.js";
|
|
29
|
+
import { wrapTextLines, emitTextWithMatrix, alphaGsName } from "../render/page-renderer.js";
|
|
29
30
|
import { writeImageXObject } from "./image-utils.js";
|
|
30
31
|
// =============================================================================
|
|
31
32
|
// Constants
|
|
@@ -57,6 +58,15 @@ export class PdfPageBuilder {
|
|
|
57
58
|
this._builderAnnotations = [];
|
|
58
59
|
/** @internal */
|
|
59
60
|
this._formFields = [];
|
|
61
|
+
/**
|
|
62
|
+
* Alpha values < 1 encountered during painting; each is materialised as
|
|
63
|
+
* one `/ExtGState` object in the page resource dictionary and applied
|
|
64
|
+
* via `setGraphicsState` before the corresponding colour draw. Empty
|
|
65
|
+
* set = no ExtGState entry needed in Resources (keeps the common
|
|
66
|
+
* opacity-1 case byte-identical with the pre-alpha implementation).
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
this._alphaValues = new Set();
|
|
60
70
|
this._width = width;
|
|
61
71
|
this._height = height;
|
|
62
72
|
this._fontManager = fontManager;
|
|
@@ -89,12 +99,24 @@ export class PdfPageBuilder {
|
|
|
89
99
|
const resourceName = this._fontManager.resolveFont(fontFamily, bold, italic);
|
|
90
100
|
this._fontManager.trackText(text);
|
|
91
101
|
const useType3 = this._fontManager.hasType3Fonts() && !this._fontManager.hasEmbeddedFont();
|
|
102
|
+
// Resolve anchor into an adjusted x before any matrix math. We use the
|
|
103
|
+
// same font/size combination the stream will render with, so the
|
|
104
|
+
// alignment is correct for the actual glyphs (not a fallback
|
|
105
|
+
// estimate). Single-line drawing only — wrapped text ignores anchor
|
|
106
|
+
// because the wrapper re-splits by the caller's supplied x.
|
|
107
|
+
const anchor = options.anchor ?? "start";
|
|
108
|
+
const resolvedX = anchor === "start" || options.maxWidth
|
|
109
|
+
? options.x
|
|
110
|
+
: options.x -
|
|
111
|
+
this._fontManager.measureText(text, resourceName, fontSize) *
|
|
112
|
+
(anchor === "middle" ? 0.5 : 1);
|
|
92
113
|
if (options.maxWidth) {
|
|
93
114
|
// Word-wrap (reuses the shared wrapTextLines from page-renderer)
|
|
94
115
|
const measure = (s) => this._fontManager.measureText(s, resourceName, fontSize);
|
|
95
116
|
const lines = wrapTextLines(text, measure, options.maxWidth);
|
|
96
117
|
const leading = fontSize * lineHeightFactor;
|
|
97
118
|
this._stream.save();
|
|
119
|
+
this._applyAlpha(color.a);
|
|
98
120
|
this._stream.setFillColor(color);
|
|
99
121
|
for (let i = 0; i < lines.length; i++) {
|
|
100
122
|
const lineY = options.y - i * leading;
|
|
@@ -105,8 +127,22 @@ export class PdfPageBuilder {
|
|
|
105
127
|
else {
|
|
106
128
|
// Single line
|
|
107
129
|
this._stream.save();
|
|
130
|
+
this._applyAlpha(color.a);
|
|
108
131
|
this._stream.setFillColor(color);
|
|
109
|
-
|
|
132
|
+
const rotation = options.rotation ?? 0;
|
|
133
|
+
if (rotation === 0) {
|
|
134
|
+
emitTextWithMatrix(this._stream, text, 1, 0, 0, 1, resolvedX, options.y, resourceName, fontSize, this._fontManager, useType3);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// Build the rotation matrix around (x, y). `emitTextWithMatrix`
|
|
138
|
+
// accepts the full 2×3 text matrix, so we pre-multiply the
|
|
139
|
+
// rotation with the translation so one call positions and
|
|
140
|
+
// rotates the glyph sequence in a single Tm op.
|
|
141
|
+
const theta = (rotation * Math.PI) / 180;
|
|
142
|
+
const cos = Math.cos(theta);
|
|
143
|
+
const sin = Math.sin(theta);
|
|
144
|
+
emitTextWithMatrix(this._stream, text, cos, sin, -sin, cos, resolvedX, options.y, resourceName, fontSize, this._fontManager, useType3);
|
|
145
|
+
}
|
|
110
146
|
this._stream.restore();
|
|
111
147
|
}
|
|
112
148
|
return this;
|
|
@@ -167,6 +203,7 @@ export class PdfPageBuilder {
|
|
|
167
203
|
const color = options.color ?? BLACK;
|
|
168
204
|
const lineWidth = options.lineWidth ?? 1;
|
|
169
205
|
this._stream.save();
|
|
206
|
+
this._applyAlpha(color.a);
|
|
170
207
|
this._stream.setStrokeColor(color);
|
|
171
208
|
this._stream.setLineWidth(lineWidth);
|
|
172
209
|
if (options.dashPattern && options.dashPattern.length > 0) {
|
|
@@ -341,6 +378,93 @@ export class PdfPageBuilder {
|
|
|
341
378
|
const ops = parseSvgPath(d);
|
|
342
379
|
return this.drawPath(ops, options);
|
|
343
380
|
}
|
|
381
|
+
/**
|
|
382
|
+
* Draw a simple SVG document onto this page.
|
|
383
|
+
*
|
|
384
|
+
* Supports the SVG primitives emitted by ExcelTS chart rendering:
|
|
385
|
+
* `rect`, `line`, `circle`, `polyline`, `polygon`, `path`, and `text`.
|
|
386
|
+
*/
|
|
387
|
+
drawSvg(options) {
|
|
388
|
+
const parsed = parseSimpleSvg(options.svg);
|
|
389
|
+
const scaleX = (options.width ?? parsed.width) / parsed.width;
|
|
390
|
+
const scaleY = (options.height ?? parsed.height) / parsed.height;
|
|
391
|
+
const mapX = (x) => options.x + x * scaleX;
|
|
392
|
+
const mapY = (y) => options.y + (options.height ?? parsed.height) - y * scaleY;
|
|
393
|
+
// `opacity` applies to both fill and stroke per SVG spec; multiply it
|
|
394
|
+
// in alongside the channel-specific `fill-opacity` / `stroke-opacity`
|
|
395
|
+
// so every SVG form authors emit (inline rgba, channel opacity, or
|
|
396
|
+
// element-wide opacity) ends up driving `/ExtGState` consistently.
|
|
397
|
+
const fillColor = (attrs) => {
|
|
398
|
+
const base = attrs.fill ? svgColorToPdf(attrs.fill) : undefined;
|
|
399
|
+
return withSvgOpacity(withSvgOpacity(base, attrs["fill-opacity"]), attrs.opacity);
|
|
400
|
+
};
|
|
401
|
+
const strokeColor = (attrs) => {
|
|
402
|
+
const base = attrs.stroke ? svgColorToPdf(attrs.stroke) : undefined;
|
|
403
|
+
return withSvgOpacity(withSvgOpacity(base, attrs["stroke-opacity"]), attrs.opacity);
|
|
404
|
+
};
|
|
405
|
+
for (const element of parsed.elements) {
|
|
406
|
+
if (element.name === "rect") {
|
|
407
|
+
const rectWidth = lengthAttr(element, "width", parsed.width, 0);
|
|
408
|
+
const rectHeight = lengthAttr(element, "height", parsed.height, 0);
|
|
409
|
+
this.drawRect({
|
|
410
|
+
x: mapX(lengthAttr(element, "x", parsed.width, 0)),
|
|
411
|
+
y: mapY(lengthAttr(element, "y", parsed.height, 0) + rectHeight),
|
|
412
|
+
width: rectWidth * scaleX,
|
|
413
|
+
height: rectHeight * scaleY,
|
|
414
|
+
fill: fillColor(element.attrs),
|
|
415
|
+
stroke: strokeColor(element.attrs)
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
else if (element.name === "line") {
|
|
419
|
+
this.drawLine({
|
|
420
|
+
x1: mapX(numAttr(element, "x1", 0)),
|
|
421
|
+
y1: mapY(numAttr(element, "y1", 0)),
|
|
422
|
+
x2: mapX(numAttr(element, "x2", 0)),
|
|
423
|
+
y2: mapY(numAttr(element, "y2", 0)),
|
|
424
|
+
color: strokeColor(element.attrs)
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
else if (element.name === "circle") {
|
|
428
|
+
this.drawCircle({
|
|
429
|
+
cx: mapX(numAttr(element, "cx", 0)),
|
|
430
|
+
cy: mapY(numAttr(element, "cy", 0)),
|
|
431
|
+
r: numAttr(element, "r", 0) * Math.max(scaleX, scaleY),
|
|
432
|
+
fill: fillColor(element.attrs),
|
|
433
|
+
stroke: strokeColor(element.attrs)
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
else if (element.name === "polyline" || element.name === "polygon") {
|
|
437
|
+
const ops = svgPointsToPath(element.attrs.points ?? "", element.name === "polygon").map(op => transformPathOp(op, mapX, mapY));
|
|
438
|
+
const stroke = strokeColor(element.attrs) ?? (element.name === "polyline" ? BLACK : undefined);
|
|
439
|
+
this.drawPath(ops, {
|
|
440
|
+
fill: element.name === "polygon" ? fillColor(element.attrs) : undefined,
|
|
441
|
+
stroke,
|
|
442
|
+
closePath: element.name === "polygon"
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
else if (element.name === "path" && element.attrs.d) {
|
|
446
|
+
const ops = parseSvgPath(element.attrs.d).map(op => transformPathOp(op, mapX, mapY));
|
|
447
|
+
const fill = fillColor(element.attrs);
|
|
448
|
+
const stroke = strokeColor(element.attrs);
|
|
449
|
+
if (!fill && !stroke) {
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
this.drawPath(ops, {
|
|
453
|
+
fill,
|
|
454
|
+
stroke
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
else if (element.name === "text") {
|
|
458
|
+
this.drawText(xmlDecodeBasic(element.text), {
|
|
459
|
+
x: mapX(numAttr(element, "x", 0)),
|
|
460
|
+
y: mapY(numAttr(element, "y", 0)),
|
|
461
|
+
fontSize: numAttr(element, "font-size", 12) * Math.max(scaleX, scaleY),
|
|
462
|
+
color: fillColor(element.attrs)
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return this;
|
|
467
|
+
}
|
|
344
468
|
// ===========================================================================
|
|
345
469
|
// Raw content stream access
|
|
346
470
|
// ===========================================================================
|
|
@@ -358,6 +482,18 @@ export class PdfPageBuilder {
|
|
|
358
482
|
_paintPath(fill, stroke, lineWidth) {
|
|
359
483
|
const hasFill = fill !== undefined;
|
|
360
484
|
const hasStroke = stroke !== undefined;
|
|
485
|
+
// Apply alpha ExtGState before setting colours. `_paintPath` callers
|
|
486
|
+
// all wrap this in save()/restore(), so the graphics state mutation is
|
|
487
|
+
// local to this path. When fill and stroke carry different alphas,
|
|
488
|
+
// the second `setGraphicsState` overrides the first — this matches
|
|
489
|
+
// pdf-exporter's behaviour and real-world use (alpha parity across
|
|
490
|
+
// fill/stroke for the same object is overwhelmingly common).
|
|
491
|
+
if (hasFill) {
|
|
492
|
+
this._applyAlpha(fill.a);
|
|
493
|
+
}
|
|
494
|
+
if (hasStroke) {
|
|
495
|
+
this._applyAlpha(stroke.a);
|
|
496
|
+
}
|
|
361
497
|
if (hasFill) {
|
|
362
498
|
this._stream.setFillColor(fill);
|
|
363
499
|
}
|
|
@@ -381,6 +517,27 @@ export class PdfPageBuilder {
|
|
|
381
517
|
this._stream.stroke();
|
|
382
518
|
}
|
|
383
519
|
}
|
|
520
|
+
/**
|
|
521
|
+
* Register a colour alpha on this page so `build()` can emit the
|
|
522
|
+
* matching `<< /Type /ExtGState /ca n /CA n >>` resource, and issue
|
|
523
|
+
* the content-stream `gs` operator pointing at that resource. `alpha
|
|
524
|
+
* === undefined` or `alpha >= 1` is a no-op, so opaque draws produce
|
|
525
|
+
* byte-identical output to the pre-alpha implementation.
|
|
526
|
+
*
|
|
527
|
+
* Callers must already have issued `save()` so `restore()` scopes the
|
|
528
|
+
* ExtGState change to the current draw — mirroring the pattern used by
|
|
529
|
+
* `page-renderer.drawCellFill` (see `render/page-renderer.ts:178-194`).
|
|
530
|
+
*
|
|
531
|
+
* @internal
|
|
532
|
+
*/
|
|
533
|
+
_applyAlpha(alpha) {
|
|
534
|
+
if (alpha === undefined || alpha >= 1) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const clamped = Math.max(0, Math.min(1, alpha));
|
|
538
|
+
this._alphaValues.add(clamped);
|
|
539
|
+
this._stream.setGraphicsState(alphaGsName(clamped));
|
|
540
|
+
}
|
|
384
541
|
}
|
|
385
542
|
// =============================================================================
|
|
386
543
|
// PdfDocumentBuilder
|
|
@@ -400,6 +557,14 @@ export class PdfDocumentBuilder {
|
|
|
400
557
|
this._embeddedFont = null;
|
|
401
558
|
this._pdfA = false;
|
|
402
559
|
this._signatureOptions = null;
|
|
560
|
+
/**
|
|
561
|
+
* Set via {@link disableFontAutoDiscovery} — opts out of the system-font
|
|
562
|
+
* auto-embed path in `build()`. Authors who need byte-stable output
|
|
563
|
+
* across machines (golden tests, reproducible build pipelines) should
|
|
564
|
+
* enable this so a host-only CJK font doesn't sneak into one run but
|
|
565
|
+
* not another.
|
|
566
|
+
*/
|
|
567
|
+
this._disableFontAutoDiscovery = false;
|
|
403
568
|
}
|
|
404
569
|
/**
|
|
405
570
|
* Add a new blank page to the document.
|
|
@@ -437,6 +602,35 @@ export class PdfDocumentBuilder {
|
|
|
437
602
|
this._embeddedFont = fontBytes;
|
|
438
603
|
return this;
|
|
439
604
|
}
|
|
605
|
+
/**
|
|
606
|
+
* Register a callback invoked once per non-fatal diagnostic during
|
|
607
|
+
* `build()`. Currently raised for:
|
|
608
|
+
*
|
|
609
|
+
* - auto-embedded system fonts (`'Auto-embedded system font ...'`)
|
|
610
|
+
* - non-WinAnsi characters with no covering font (`'...non-WinAnsi character(s) present...'`)
|
|
611
|
+
*
|
|
612
|
+
* The callback is synchronous and runs inside `build()`; throwing
|
|
613
|
+
* from it will abort the build. Return value is ignored.
|
|
614
|
+
*/
|
|
615
|
+
onWarning(handler) {
|
|
616
|
+
this._onWarning = handler;
|
|
617
|
+
return this;
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Opt out of the best-effort system-font auto-discovery that `build()`
|
|
621
|
+
* performs when the document contains non-WinAnsi characters and no
|
|
622
|
+
* font was explicitly embedded. Use this to keep output byte-stable
|
|
623
|
+
* across hosts: one machine may have SimSun installed while another
|
|
624
|
+
* does not.
|
|
625
|
+
*/
|
|
626
|
+
disableFontAutoDiscovery() {
|
|
627
|
+
this._disableFontAutoDiscovery = true;
|
|
628
|
+
return this;
|
|
629
|
+
}
|
|
630
|
+
/** @internal */
|
|
631
|
+
_warn(message) {
|
|
632
|
+
this._onWarning?.(message);
|
|
633
|
+
}
|
|
440
634
|
/**
|
|
441
635
|
* Enable PDF/A compliance output.
|
|
442
636
|
*
|
|
@@ -631,6 +825,65 @@ export class PdfDocumentBuilder {
|
|
|
631
825
|
const ttfFont = parseTtf(this._embeddedFont);
|
|
632
826
|
this._fontManager.registerEmbeddedFont(ttfFont);
|
|
633
827
|
}
|
|
828
|
+
else {
|
|
829
|
+
// Auto-discover a system font when the document contains non-WinAnsi
|
|
830
|
+
// characters (CJK, accented code points beyond WinAnsi, etc.) and
|
|
831
|
+
// the caller did not supply one via `embedFont`. Mirrors the
|
|
832
|
+
// `pdf-exporter` pipeline so `drawChartPdf`-style overlays, ad-hoc
|
|
833
|
+
// `drawText` usage, and the spreadsheet exporter all reach for the
|
|
834
|
+
// same system fonts before falling back to Type3 NOTDEF glyphs.
|
|
835
|
+
// Failures are non-fatal: discovery is best-effort and users who
|
|
836
|
+
// need guaranteed rendering should still call `embedFont` with a
|
|
837
|
+
// font they control.
|
|
838
|
+
const nonWinAnsi = this._fontManager.getType3CodePoints();
|
|
839
|
+
if (nonWinAnsi.size > 0) {
|
|
840
|
+
// Try auto-discovery unless the caller opted out.
|
|
841
|
+
if (!this._disableFontAutoDiscovery) {
|
|
842
|
+
for (const candidate of discoverSystemFontCandidates()) {
|
|
843
|
+
try {
|
|
844
|
+
const testTtf = parseTtf(candidate);
|
|
845
|
+
const allCovered = [...nonWinAnsi].every(cp => testTtf.cmap.has(cp));
|
|
846
|
+
if (allCovered) {
|
|
847
|
+
this._fontManager.registerEmbeddedFont(testTtf);
|
|
848
|
+
this._warn(`Auto-embedded system font '${testTtf.familyName}' to render ${nonWinAnsi.size} non-WinAnsi character(s). ` +
|
|
849
|
+
`Call embedFont(bytes) explicitly for deterministic output.`);
|
|
850
|
+
break;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
catch {
|
|
854
|
+
// Parse failed — try next candidate
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
if (!this._fontManager.hasEmbeddedFont()) {
|
|
859
|
+
// Either discovery was disabled, every candidate failed to
|
|
860
|
+
// parse, or no candidate covered these code points. Type3
|
|
861
|
+
// NOTDEF glyphs (tofu boxes) will appear for any cp
|
|
862
|
+
// `type3-glyphs.ts` does not map. Surface a warning so the
|
|
863
|
+
// author knows rendering will degrade, and list up to 5
|
|
864
|
+
// sample code points to help them debug.
|
|
865
|
+
const sample = [...nonWinAnsi]
|
|
866
|
+
.slice(0, 5)
|
|
867
|
+
.map(cp => `U+${cp.toString(16).toUpperCase().padStart(4, "0")}`)
|
|
868
|
+
.join(", ");
|
|
869
|
+
this._warn(`${nonWinAnsi.size} non-WinAnsi character(s) present but no TrueType font is embedded and no system font candidate covered them ` +
|
|
870
|
+
`(e.g. ${sample}). Call embedFont(bytes) with a font that covers these code points; otherwise Type3 NOTDEF boxes will render.`);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
// Surface any unknown font families the FontManager saw during
|
|
875
|
+
// resolveFont (one diagnostic per distinct family, independent of
|
|
876
|
+
// how many text runs used it). An embedded font shadows everything
|
|
877
|
+
// anyway, so skip the warning in that case to avoid noise.
|
|
878
|
+
if (!this._fontManager.hasEmbeddedFont()) {
|
|
879
|
+
const unknown = this._fontManager.getUnknownFontFamilies();
|
|
880
|
+
if (unknown.size > 0) {
|
|
881
|
+
const list = [...unknown].slice(0, 5).join(", ");
|
|
882
|
+
const more = unknown.size > 5 ? ` (and ${unknown.size - 5} more)` : "";
|
|
883
|
+
this._warn(`Font family ${unknown.size > 1 ? "names" : "name"} '${list}'${more} not recognised; ` +
|
|
884
|
+
`falling back to Helvetica metrics. Add the typeface to the font-family map or call embedFont(bytes).`);
|
|
885
|
+
}
|
|
886
|
+
}
|
|
634
887
|
// Write font resources
|
|
635
888
|
const fontObjectMap = this._fontManager.writeFontResources(writer);
|
|
636
889
|
const fontDictStr = this._fontManager.buildFontDictString(fontObjectMap);
|
|
@@ -678,6 +931,25 @@ export class PdfDocumentBuilder {
|
|
|
678
931
|
if (xobjDictStr) {
|
|
679
932
|
resourcesStr += `/XObject ${xobjDictStr} `;
|
|
680
933
|
}
|
|
934
|
+
// Emit an /ExtGState entry for every distinct page-level alpha. Mirrors
|
|
935
|
+
// the scheme used by `pdf-exporter.ts:377-390` so viewers see the
|
|
936
|
+
// same construct regardless of which rendering path produced the
|
|
937
|
+
// PDF. Empty set → no entry (and byte-identical with the old
|
|
938
|
+
// implementation for fully-opaque documents).
|
|
939
|
+
if (page._alphaValues.size > 0) {
|
|
940
|
+
const gsParts = ["<<"];
|
|
941
|
+
for (const alpha of page._alphaValues) {
|
|
942
|
+
const gsObjNum = writer.allocObject();
|
|
943
|
+
const gsDict = new PdfDict()
|
|
944
|
+
.set("Type", "/ExtGState")
|
|
945
|
+
.set("ca", pdfNumber(alpha))
|
|
946
|
+
.set("CA", pdfNumber(alpha));
|
|
947
|
+
writer.addObject(gsObjNum, gsDict);
|
|
948
|
+
gsParts.push(`/${alphaGsName(alpha)} ${pdfRef(gsObjNum)}`);
|
|
949
|
+
}
|
|
950
|
+
gsParts.push(">>");
|
|
951
|
+
resourcesStr += `/ExtGState ${gsParts.join("\n")} `;
|
|
952
|
+
}
|
|
681
953
|
resourcesStr += ">>";
|
|
682
954
|
writer.addObject(resourcesObjNum, resourcesStr);
|
|
683
955
|
pageResourceRefs.push(resourcesObjNum);
|
|
@@ -1388,6 +1660,239 @@ export function parseSvgPath(d) {
|
|
|
1388
1660
|
}
|
|
1389
1661
|
return ops;
|
|
1390
1662
|
}
|
|
1663
|
+
function parseSimpleSvg(svg) {
|
|
1664
|
+
const svgTag = /<svg\b([^>]*)>/i.exec(svg);
|
|
1665
|
+
const svgAttrs = parseSvgAttrs(svgTag?.[1] ?? "");
|
|
1666
|
+
const viewBox = svgAttrs.viewBox?.split(/[\s,]+/).map(Number) ?? [];
|
|
1667
|
+
const width = svgRootLength(svgAttrs.width, viewBox[2], 300);
|
|
1668
|
+
const height = svgRootLength(svgAttrs.height, viewBox[3], 150);
|
|
1669
|
+
const elements = [];
|
|
1670
|
+
const elementRe = /<(rect|line|circle|polyline|polygon|path)\b([^>]*)\/?>|<text\b([^>]*)>([\s\S]*?)<\/text>/gi;
|
|
1671
|
+
let match;
|
|
1672
|
+
while ((match = elementRe.exec(svg)) !== null) {
|
|
1673
|
+
if (match[1]) {
|
|
1674
|
+
elements.push({ name: match[1], attrs: parseSvgAttrs(match[2] ?? ""), text: "" });
|
|
1675
|
+
}
|
|
1676
|
+
else {
|
|
1677
|
+
elements.push({ name: "text", attrs: parseSvgAttrs(match[3] ?? ""), text: match[4] ?? "" });
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
return { width, height, elements };
|
|
1681
|
+
}
|
|
1682
|
+
function parseSvgAttrs(raw) {
|
|
1683
|
+
const attrs = {};
|
|
1684
|
+
// Manual parser avoids regex backtracking on uncontrolled input.
|
|
1685
|
+
let i = 0;
|
|
1686
|
+
const len = raw.length;
|
|
1687
|
+
while (i < len) {
|
|
1688
|
+
// Skip non-name characters
|
|
1689
|
+
while (i < len && !isSvgNameChar(raw.charCodeAt(i))) {
|
|
1690
|
+
i++;
|
|
1691
|
+
}
|
|
1692
|
+
if (i >= len) {
|
|
1693
|
+
break;
|
|
1694
|
+
}
|
|
1695
|
+
// Read attribute name
|
|
1696
|
+
const nameStart = i;
|
|
1697
|
+
while (i < len && isSvgNameChar(raw.charCodeAt(i))) {
|
|
1698
|
+
i++;
|
|
1699
|
+
}
|
|
1700
|
+
const name = raw.slice(nameStart, i);
|
|
1701
|
+
// Expect `="`
|
|
1702
|
+
if (i >= len || raw.charCodeAt(i) !== 61 /* = */) {
|
|
1703
|
+
continue;
|
|
1704
|
+
}
|
|
1705
|
+
i++;
|
|
1706
|
+
if (i >= len || raw.charCodeAt(i) !== 34 /* " */) {
|
|
1707
|
+
continue;
|
|
1708
|
+
}
|
|
1709
|
+
i++;
|
|
1710
|
+
// Read attribute value until closing quote
|
|
1711
|
+
const valStart = i;
|
|
1712
|
+
while (i < len && raw.charCodeAt(i) !== 34) {
|
|
1713
|
+
i++;
|
|
1714
|
+
}
|
|
1715
|
+
attrs[name] = raw.slice(valStart, i);
|
|
1716
|
+
if (i < len) {
|
|
1717
|
+
i++; // skip closing quote
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
return attrs;
|
|
1721
|
+
}
|
|
1722
|
+
/** Check if a char code is valid in an SVG/XML attribute name (word chars, colon, hyphen). */
|
|
1723
|
+
function isSvgNameChar(c) {
|
|
1724
|
+
return ((c >= 65 && c <= 90) || // A-Z
|
|
1725
|
+
(c >= 97 && c <= 122) || // a-z
|
|
1726
|
+
(c >= 48 && c <= 57) || // 0-9
|
|
1727
|
+
c === 95 || // _
|
|
1728
|
+
c === 58 || // :
|
|
1729
|
+
c === 45 // -
|
|
1730
|
+
);
|
|
1731
|
+
}
|
|
1732
|
+
function numAttr(element, name, fallback) {
|
|
1733
|
+
const value = parseFloat(element.attrs[name] ?? "");
|
|
1734
|
+
return Number.isFinite(value) ? value : fallback;
|
|
1735
|
+
}
|
|
1736
|
+
function lengthAttr(element, name, axisLength, fallback) {
|
|
1737
|
+
const raw = element.attrs[name];
|
|
1738
|
+
if (!raw) {
|
|
1739
|
+
return fallback;
|
|
1740
|
+
}
|
|
1741
|
+
if (raw.trim().endsWith("%")) {
|
|
1742
|
+
const pct = parseFloat(raw);
|
|
1743
|
+
return Number.isFinite(pct) ? (axisLength * pct) / 100 : fallback;
|
|
1744
|
+
}
|
|
1745
|
+
const value = parseFloat(raw);
|
|
1746
|
+
return Number.isFinite(value) ? value : fallback;
|
|
1747
|
+
}
|
|
1748
|
+
function svgRootLength(raw, viewBoxLength, fallback) {
|
|
1749
|
+
if (!raw || raw.trim().endsWith("%")) {
|
|
1750
|
+
return viewBoxLength || fallback;
|
|
1751
|
+
}
|
|
1752
|
+
const value = parseFloat(raw);
|
|
1753
|
+
return Number.isFinite(value) && value > 0 ? value : viewBoxLength || fallback;
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Parse an SVG color token (`#rgb` / `#rrggbb` / `rgb(...)` / `rgba(...)`)
|
|
1757
|
+
* into a {@link PdfColor}. Named colours and functional forms beyond
|
|
1758
|
+
* `rgb`/`rgba` are deliberately out of scope — chart SVG output sticks
|
|
1759
|
+
* to these forms, and the `drawSvg` consumer should pass-through
|
|
1760
|
+
* `undefined` (i.e. "no fill") rather than silently guess.
|
|
1761
|
+
*
|
|
1762
|
+
* `rgba(r, g, b, a)` populates `.a` so the caller can thread the alpha
|
|
1763
|
+
* through `PdfPageBuilder._applyAlpha` → `/ExtGState`. Percentage values
|
|
1764
|
+
* are accepted (e.g. `rgb(100%, 0%, 0%)` ≡ red).
|
|
1765
|
+
*/
|
|
1766
|
+
function svgColorToPdf(value) {
|
|
1767
|
+
if (!value || value === "none") {
|
|
1768
|
+
return undefined;
|
|
1769
|
+
}
|
|
1770
|
+
const trimmed = value.trim();
|
|
1771
|
+
// rgb(r,g,b) / rgba(r,g,b,a) — whitespace tolerant, supports 0..255 and 0..100%
|
|
1772
|
+
const fnMatch = /^rgba?\(([^)]+)\)$/i.exec(trimmed);
|
|
1773
|
+
if (fnMatch) {
|
|
1774
|
+
const parts = fnMatch[1]
|
|
1775
|
+
.split(/[\s,]+/)
|
|
1776
|
+
.filter(Boolean)
|
|
1777
|
+
.map(part => {
|
|
1778
|
+
if (part.endsWith("%")) {
|
|
1779
|
+
const pct = Number.parseFloat(part);
|
|
1780
|
+
return Number.isFinite(pct) ? pct / 100 : undefined;
|
|
1781
|
+
}
|
|
1782
|
+
const num = Number.parseFloat(part);
|
|
1783
|
+
return Number.isFinite(num) ? num : undefined;
|
|
1784
|
+
});
|
|
1785
|
+
if (parts.length < 3 || parts.slice(0, 3).some(p => p === undefined)) {
|
|
1786
|
+
return undefined;
|
|
1787
|
+
}
|
|
1788
|
+
// The first three values are RGB in 0..255 when integer, already-0..1
|
|
1789
|
+
// when expressed as percentages above. Detect by the original token
|
|
1790
|
+
// to avoid mis-normalising `rgb(0.5, 0.5, 0.5)` as 0..255.
|
|
1791
|
+
const rawTokens = fnMatch[1].split(/[\s,]+/).filter(Boolean);
|
|
1792
|
+
const normaliseChannel = (v, idx) => {
|
|
1793
|
+
if (rawTokens[idx]?.endsWith("%")) {
|
|
1794
|
+
return Math.max(0, Math.min(1, v));
|
|
1795
|
+
}
|
|
1796
|
+
return Math.max(0, Math.min(1, v / 255));
|
|
1797
|
+
};
|
|
1798
|
+
const color = {
|
|
1799
|
+
r: normaliseChannel(parts[0], 0),
|
|
1800
|
+
g: normaliseChannel(parts[1], 1),
|
|
1801
|
+
b: normaliseChannel(parts[2], 2)
|
|
1802
|
+
};
|
|
1803
|
+
if (parts.length >= 4 && parts[3] !== undefined) {
|
|
1804
|
+
// rgba's alpha is 0..1 by spec regardless of whether RGB used %.
|
|
1805
|
+
color.a = Math.max(0, Math.min(1, parts[3]));
|
|
1806
|
+
}
|
|
1807
|
+
return color;
|
|
1808
|
+
}
|
|
1809
|
+
const hex = trimmed.startsWith("#") ? trimmed.slice(1) : trimmed;
|
|
1810
|
+
if (/^[0-9a-fA-F]{3}$/.test(hex)) {
|
|
1811
|
+
return {
|
|
1812
|
+
r: parseInt(hex[0] + hex[0], 16) / 255,
|
|
1813
|
+
g: parseInt(hex[1] + hex[1], 16) / 255,
|
|
1814
|
+
b: parseInt(hex[2] + hex[2], 16) / 255
|
|
1815
|
+
};
|
|
1816
|
+
}
|
|
1817
|
+
if (!/^[0-9a-fA-F]{6}$/.test(hex)) {
|
|
1818
|
+
return undefined;
|
|
1819
|
+
}
|
|
1820
|
+
return {
|
|
1821
|
+
r: parseInt(hex.slice(0, 2), 16) / 255,
|
|
1822
|
+
g: parseInt(hex.slice(2, 4), 16) / 255,
|
|
1823
|
+
b: parseInt(hex.slice(4, 6), 16) / 255
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Apply an `*-opacity` attribute to an already-parsed {@link PdfColor}.
|
|
1828
|
+
*
|
|
1829
|
+
* SVG lets authors specify opacity either inline on the colour (`rgba`)
|
|
1830
|
+
* or as a separate `fill-opacity`/`stroke-opacity` attribute. When both
|
|
1831
|
+
* are present the W3C spec multiplies them — `rgba(…,0.5)` with
|
|
1832
|
+
* `fill-opacity="0.4"` yields effective alpha 0.2. We preserve that
|
|
1833
|
+
* here so chart SVG output whose authors use either form surfaces the
|
|
1834
|
+
* same alpha through to `/ExtGState`.
|
|
1835
|
+
*/
|
|
1836
|
+
function withSvgOpacity(color, opacityAttr) {
|
|
1837
|
+
if (!color) {
|
|
1838
|
+
return color;
|
|
1839
|
+
}
|
|
1840
|
+
if (!opacityAttr) {
|
|
1841
|
+
return color;
|
|
1842
|
+
}
|
|
1843
|
+
const parsed = Number.parseFloat(opacityAttr);
|
|
1844
|
+
if (!Number.isFinite(parsed)) {
|
|
1845
|
+
return color;
|
|
1846
|
+
}
|
|
1847
|
+
const clamped = Math.max(0, Math.min(1, parsed));
|
|
1848
|
+
const combined = (color.a ?? 1) * clamped;
|
|
1849
|
+
if (combined >= 1) {
|
|
1850
|
+
return color;
|
|
1851
|
+
}
|
|
1852
|
+
return { ...color, a: combined };
|
|
1853
|
+
}
|
|
1854
|
+
function svgPointsToPath(points, close) {
|
|
1855
|
+
const nums = points
|
|
1856
|
+
.trim()
|
|
1857
|
+
.split(/[\s,]+/)
|
|
1858
|
+
.map(Number)
|
|
1859
|
+
.filter(Number.isFinite);
|
|
1860
|
+
const ops = [];
|
|
1861
|
+
for (let i = 0; i + 1 < nums.length; i += 2) {
|
|
1862
|
+
ops.push(i === 0
|
|
1863
|
+
? { op: "move", x: nums[i], y: nums[i + 1] }
|
|
1864
|
+
: { op: "line", x: nums[i], y: nums[i + 1] });
|
|
1865
|
+
}
|
|
1866
|
+
if (close && ops.length > 0) {
|
|
1867
|
+
ops.push({ op: "close" });
|
|
1868
|
+
}
|
|
1869
|
+
return ops;
|
|
1870
|
+
}
|
|
1871
|
+
function transformPathOp(op, mapX, mapY) {
|
|
1872
|
+
if (op.op === "move" || op.op === "line") {
|
|
1873
|
+
return { ...op, x: mapX(op.x), y: mapY(op.y) };
|
|
1874
|
+
}
|
|
1875
|
+
if (op.op === "curve") {
|
|
1876
|
+
return {
|
|
1877
|
+
op: "curve",
|
|
1878
|
+
x1: mapX(op.x1),
|
|
1879
|
+
y1: mapY(op.y1),
|
|
1880
|
+
x2: mapX(op.x2),
|
|
1881
|
+
y2: mapY(op.y2),
|
|
1882
|
+
x3: mapX(op.x3),
|
|
1883
|
+
y3: mapY(op.y3)
|
|
1884
|
+
};
|
|
1885
|
+
}
|
|
1886
|
+
return op;
|
|
1887
|
+
}
|
|
1888
|
+
function xmlDecodeBasic(value) {
|
|
1889
|
+
return value
|
|
1890
|
+
.replace(/</g, "<")
|
|
1891
|
+
.replace(/>/g, ">")
|
|
1892
|
+
.replace(/"/g, '"')
|
|
1893
|
+
.replace(/'/g, "'")
|
|
1894
|
+
.replace(/&/g, "&");
|
|
1895
|
+
}
|
|
1391
1896
|
/**
|
|
1392
1897
|
* Convert an SVG elliptical arc to cubic Bézier curves.
|
|
1393
1898
|
* Follows the SVG spec's endpoint-to-center arc parameterization.
|