@cj-tech-master/excelts 9.5.4 → 9.5.5
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/modules/archive/compression/streaming-compress.browser.js +29 -0
- package/dist/browser/modules/archive/compression/streaming-compress.js +9 -0
- package/dist/browser/modules/archive/compression/worker-pool/pool.browser.js +26 -1
- package/dist/browser/modules/archive/fs/archive-file.d.ts +8 -5
- package/dist/browser/modules/archive/fs/archive-file.js +78 -16
- package/dist/browser/modules/archive/unzip/stream.browser.js +43 -2
- package/dist/browser/modules/excel/chart/chart-ex-builder.js +7 -2
- package/dist/browser/modules/excel/chart/chart-ex-renderer.js +4 -9
- package/dist/browser/modules/excel/chart/chart-ex-types.d.ts +0 -12
- package/dist/browser/modules/excel/chart/chart.d.ts +1 -5
- package/dist/browser/modules/excel/chart/chart.js +1 -7
- package/dist/browser/modules/excel/chart/types.d.ts +0 -6
- package/dist/browser/modules/excel/stream/workbook-reader.browser.js +25 -1
- package/dist/browser/modules/excel/stream/workbook-reader.js +9 -0
- package/dist/browser/modules/excel/stream/workbook-writer.browser.d.ts +40 -0
- package/dist/browser/modules/excel/stream/workbook-writer.browser.js +228 -13
- package/dist/browser/modules/excel/utils/string-buf.d.ts +5 -26
- package/dist/browser/modules/excel/utils/string-buf.js +4 -81
- package/dist/browser/modules/excel/workbook.browser.js +135 -25
- package/dist/browser/modules/excel/xlsx/xform/chart/chart-space-xform.js +6 -20
- package/dist/browser/modules/excel/xlsx/xlsx.browser.d.ts +19 -9
- package/dist/browser/modules/excel/xlsx/xlsx.browser.js +32 -8
- package/dist/browser/modules/excel/xlsx/xlsx.d.ts +10 -2
- package/dist/browser/modules/excel/xlsx/xlsx.js +9 -1
- package/dist/browser/modules/pdf/excel-bridge.d.ts +30 -1
- package/dist/browser/modules/pdf/excel-bridge.js +32 -0
- package/dist/browser/modules/pdf/font/metrics.d.ts +3 -52
- package/dist/browser/modules/pdf/font/metrics.js +3 -237
- package/dist/browser/modules/pdf/index.d.ts +1 -1
- package/dist/browser/modules/pdf/index.js +1 -1
- package/dist/browser/modules/pdf/render-layout-to-pdf.d.ts +66 -0
- package/dist/browser/modules/pdf/render-layout-to-pdf.js +647 -0
- package/dist/browser/modules/pdf/word-bridge.d.ts +80 -12
- package/dist/browser/modules/pdf/word-bridge.js +122 -274
- package/dist/browser/modules/stream/index.base.d.ts +2 -0
- package/dist/browser/modules/stream/index.base.js +2 -1
- package/dist/browser/modules/stream/internal/sink-adapter.d.ts +65 -0
- package/dist/browser/modules/stream/internal/sink-adapter.js +198 -0
- package/dist/browser/modules/stream/pull-stream.d.ts +19 -2
- package/dist/browser/modules/stream/pull-stream.js +51 -5
- package/dist/browser/modules/stream/types.d.ts +13 -1
- package/dist/browser/modules/word/advanced/diff.d.ts +61 -0
- package/dist/browser/modules/word/advanced/diff.js +167 -0
- package/dist/browser/modules/word/advanced/drawing-shapes.d.ts +269 -0
- package/dist/browser/modules/word/advanced/drawing-shapes.js +268 -0
- package/dist/browser/modules/word/advanced/field-engine.d.ts +43 -0
- package/dist/browser/modules/word/advanced/field-engine.js +1225 -0
- package/dist/browser/modules/word/advanced/glossary.d.ts +86 -0
- package/dist/browser/modules/word/advanced/glossary.js +79 -0
- package/dist/browser/modules/word/advanced/math-convert.d.ts +30 -0
- package/dist/browser/modules/word/advanced/math-convert.js +595 -0
- package/dist/browser/modules/word/advanced/ole-objects.d.ts +115 -0
- package/dist/browser/modules/word/advanced/ole-objects.js +271 -0
- package/dist/browser/modules/word/advanced/style-map.d.ts +105 -0
- package/dist/browser/modules/word/advanced/style-map.js +322 -0
- package/dist/browser/modules/word/advanced/validation.d.ts +56 -0
- package/dist/browser/modules/word/advanced/validation.js +1065 -0
- package/dist/browser/modules/word/advanced/vba-project.d.ts +91 -0
- package/dist/browser/modules/word/advanced/vba-project.js +265 -0
- package/dist/browser/modules/word/bridge/excel-bridge.d.ts +127 -0
- package/dist/browser/modules/word/bridge/excel-bridge.js +980 -0
- package/dist/browser/modules/word/builder/document-handle.d.ts +151 -0
- package/dist/browser/modules/word/builder/document-handle.js +664 -0
- package/dist/browser/modules/word/builder/paragraph-builders.d.ts +61 -0
- package/dist/browser/modules/word/builder/paragraph-builders.js +90 -0
- package/dist/browser/modules/word/builder/run-builders.d.ts +374 -0
- package/dist/browser/modules/word/builder/run-builders.js +600 -0
- package/dist/browser/modules/word/builder/table-builders.d.ts +23 -0
- package/dist/browser/modules/word/builder/table-builders.js +45 -0
- package/dist/browser/modules/word/constants.d.ts +39 -1
- package/dist/browser/modules/word/constants.js +109 -1
- package/dist/browser/modules/word/convert/conversion-ir.d.ts +210 -0
- package/dist/browser/modules/word/convert/conversion-ir.js +31 -0
- package/dist/browser/modules/word/convert/docx-to-semantic.d.ts +39 -0
- package/dist/browser/modules/word/convert/docx-to-semantic.js +499 -0
- package/dist/browser/modules/word/convert/flat-opc.d.ts +44 -0
- package/dist/browser/modules/word/convert/flat-opc.js +385 -0
- package/dist/browser/modules/word/convert/html/html-import.d.ts +50 -0
- package/dist/browser/modules/word/convert/html/html-import.js +1907 -0
- package/dist/{types/modules/word → browser/modules/word/convert/html}/html-renderer.d.ts +14 -1
- package/dist/{esm/modules/word → browser/modules/word/convert/html}/html-renderer.js +420 -69
- package/dist/browser/modules/word/convert/html/html.d.ts +15 -0
- package/dist/browser/modules/word/convert/html/html.js +15 -0
- package/dist/browser/modules/word/convert/markdown/markdown-import.d.ts +68 -0
- package/dist/browser/modules/word/convert/markdown/markdown-import.js +1325 -0
- package/dist/browser/modules/word/convert/markdown/markdown-renderer.d.ts +25 -0
- package/dist/browser/modules/word/convert/markdown/markdown-renderer.js +634 -0
- package/dist/browser/modules/word/convert/markdown/markdown.d.ts +15 -0
- package/dist/browser/modules/word/convert/markdown/markdown.js +15 -0
- package/dist/browser/modules/word/convert/odt/odt.d.ts +41 -0
- package/dist/browser/modules/word/convert/odt/odt.js +1932 -0
- package/dist/browser/modules/word/{color-utils.d.ts → core/color-utils.d.ts} +8 -1
- package/dist/browser/modules/word/core/color-utils.js +43 -0
- package/dist/browser/modules/word/core/internal-utils.d.ts +90 -0
- package/dist/browser/modules/word/core/internal-utils.js +209 -0
- package/dist/browser/modules/word/core/mapper.d.ts +44 -0
- package/dist/browser/modules/word/core/mapper.js +427 -0
- package/dist/browser/modules/word/core/opc-paths.d.ts +33 -0
- package/dist/browser/modules/word/core/opc-paths.js +48 -0
- package/dist/browser/modules/word/core/text-utils.d.ts +38 -0
- package/dist/browser/modules/word/core/text-utils.js +202 -0
- package/dist/browser/modules/word/core/walker.d.ts +119 -0
- package/dist/browser/modules/word/core/walker.js +570 -0
- package/dist/browser/modules/word/crypto.d.ts +14 -9
- package/dist/browser/modules/word/crypto.js +13 -7
- package/dist/browser/modules/word/document-io.d.ts +59 -27
- package/dist/browser/modules/word/document-io.js +80 -197
- package/dist/browser/modules/word/errors.d.ts +44 -1
- package/dist/browser/modules/word/errors.js +54 -2
- package/dist/browser/modules/word/excel.d.ts +14 -0
- package/dist/browser/modules/word/excel.js +13 -0
- package/dist/browser/modules/word/font/font-embed.d.ts +112 -0
- package/dist/browser/modules/word/font/font-embed.js +646 -0
- package/dist/{esm/modules/word → browser/modules/word/font}/font-obfuscation.js +4 -9
- package/dist/browser/modules/word/font/hyphenation.d.ts +65 -0
- package/dist/browser/modules/word/font/hyphenation.js +4210 -0
- package/dist/browser/modules/word/font/text-shaping.d.ts +58 -0
- package/dist/browser/modules/word/font/text-shaping.js +635 -0
- package/dist/browser/modules/word/html.d.ts +7 -6
- package/dist/browser/modules/word/html.js +6 -5
- package/dist/browser/modules/word/incremental-edit.d.ts +123 -0
- package/dist/browser/modules/word/incremental-edit.js +361 -0
- package/dist/browser/modules/word/index.base.d.ts +194 -10
- package/dist/browser/modules/word/index.base.js +138 -29
- package/dist/browser/modules/word/layout/layout-constants.d.ts +17 -0
- package/dist/browser/modules/word/layout/layout-constants.js +17 -0
- package/dist/browser/modules/word/layout/layout-full.d.ts +53 -0
- package/dist/browser/modules/word/layout/layout-full.js +1696 -0
- package/dist/browser/modules/word/layout/layout-model.d.ts +344 -0
- package/dist/browser/modules/word/layout/layout-model.js +16 -0
- package/dist/browser/modules/word/layout/layout.d.ts +63 -0
- package/dist/browser/modules/word/layout/layout.js +1167 -0
- package/dist/browser/modules/word/layout/render-page.d.ts +57 -0
- package/dist/browser/modules/word/layout/render-page.js +1238 -0
- package/dist/browser/modules/word/markdown.d.ts +14 -0
- package/dist/browser/modules/word/markdown.js +13 -0
- package/dist/browser/modules/word/patcher.d.ts +62 -0
- package/dist/browser/modules/word/patcher.js +537 -0
- package/dist/browser/modules/word/query/compat.d.ts +25 -0
- package/dist/browser/modules/word/query/compat.js +58 -0
- package/dist/browser/modules/word/query/data-binding.d.ts +22 -0
- package/dist/browser/modules/word/query/data-binding.js +392 -0
- package/dist/browser/modules/word/query/form-fields.d.ts +41 -0
- package/dist/browser/modules/word/query/form-fields.js +268 -0
- package/dist/browser/modules/word/query/format-search.d.ts +99 -0
- package/dist/browser/modules/word/query/format-search.js +329 -0
- package/dist/browser/modules/word/query/mail-merge.d.ts +25 -0
- package/dist/browser/modules/word/query/mail-merge.js +111 -0
- package/dist/browser/modules/word/query/merge.d.ts +50 -0
- package/dist/browser/modules/word/query/merge.js +617 -0
- package/dist/browser/modules/word/query/replace.d.ts +47 -0
- package/dist/browser/modules/word/query/replace.js +301 -0
- package/dist/browser/modules/word/query/revisions.d.ts +67 -0
- package/dist/browser/modules/word/query/revisions.js +879 -0
- package/dist/browser/modules/word/query/search.d.ts +129 -0
- package/dist/browser/modules/word/query/search.js +346 -0
- package/dist/browser/modules/word/query/split.d.ts +44 -0
- package/dist/browser/modules/word/query/split.js +135 -0
- package/dist/browser/modules/word/query/style-resolve.d.ts +104 -0
- package/dist/browser/modules/word/query/style-resolve.js +368 -0
- package/dist/browser/modules/word/reader/chart-parser.d.ts +20 -0
- package/dist/browser/modules/word/reader/chart-parser.js +810 -0
- package/dist/browser/modules/word/reader/comments-parser.d.ts +26 -0
- package/dist/browser/modules/word/reader/comments-parser.js +92 -0
- package/dist/browser/modules/word/reader/doc-props-parsers.d.ts +15 -0
- package/dist/browser/modules/word/reader/doc-props-parsers.js +190 -0
- package/dist/browser/modules/word/reader/docx-reader.d.ts +27 -0
- package/dist/browser/modules/word/reader/docx-reader.js +2557 -0
- package/dist/browser/modules/word/reader/drawing-helpers.d.ts +27 -0
- package/dist/browser/modules/word/reader/drawing-helpers.js +84 -0
- package/dist/browser/modules/word/reader/form-field-parser.d.ts +21 -0
- package/dist/browser/modules/word/reader/form-field-parser.js +82 -0
- package/dist/browser/modules/word/reader/image-parsers.d.ts +11 -0
- package/dist/browser/modules/word/reader/image-parsers.js +291 -0
- package/dist/browser/modules/word/reader/math-parser.d.ts +12 -0
- package/dist/browser/modules/word/reader/math-parser.js +422 -0
- package/dist/browser/modules/word/reader/metadata-parsers.d.ts +17 -0
- package/dist/browser/modules/word/reader/metadata-parsers.js +87 -0
- package/dist/browser/modules/word/reader/numbering-parser.d.ts +13 -0
- package/dist/browser/modules/word/reader/numbering-parser.js +166 -0
- package/dist/browser/modules/word/reader/paragraph-section-parsers.d.ts +12 -0
- package/dist/browser/modules/word/reader/paragraph-section-parsers.js +503 -0
- package/dist/browser/modules/word/reader/parse-utils.d.ts +91 -0
- package/dist/browser/modules/word/reader/parse-utils.js +249 -0
- package/dist/browser/modules/word/reader/properties-parsers.d.ts +21 -0
- package/dist/browser/modules/word/reader/properties-parsers.js +332 -0
- package/dist/browser/modules/word/reader/reader-context.d.ts +69 -0
- package/dist/browser/modules/word/reader/reader-context.js +61 -0
- package/dist/browser/modules/word/reader/sdt-helpers.d.ts +29 -0
- package/dist/browser/modules/word/reader/sdt-helpers.js +111 -0
- package/dist/browser/modules/word/reader/settings-parser.d.ts +8 -0
- package/dist/browser/modules/word/reader/settings-parser.js +263 -0
- package/dist/browser/modules/word/reader/styles-parser.d.ts +12 -0
- package/dist/browser/modules/word/reader/styles-parser.js +147 -0
- package/dist/browser/modules/word/reader/table-properties-parsers.d.ts +12 -0
- package/dist/browser/modules/word/reader/table-properties-parsers.js +234 -0
- package/dist/browser/modules/word/reader/theme-parser.d.ts +8 -0
- package/dist/browser/modules/word/reader/theme-parser.js +167 -0
- package/dist/browser/modules/word/reader/watermark-parser.d.ts +15 -0
- package/dist/browser/modules/word/reader/watermark-parser.js +110 -0
- package/dist/browser/modules/word/security/cfb-reader.d.ts +37 -0
- package/dist/browser/modules/word/security/cfb-reader.js +410 -0
- package/dist/browser/modules/word/{digital-signatures.d.ts → security/digital-signatures.d.ts} +19 -11
- package/dist/browser/modules/word/{digital-signatures.js → security/digital-signatures.js} +34 -34
- package/dist/browser/modules/word/security/document-protection.d.ts +93 -0
- package/dist/browser/modules/word/security/document-protection.js +201 -0
- package/dist/{types/modules/word → browser/modules/word/security}/encryption.d.ts +51 -4
- package/dist/browser/modules/word/security/encryption.js +602 -0
- package/dist/browser/modules/word/security/policy.d.ts +80 -0
- package/dist/browser/modules/word/security/policy.js +102 -0
- package/dist/browser/modules/word/template/template-chart.d.ts +56 -0
- package/dist/browser/modules/word/template/template-chart.js +167 -0
- package/dist/browser/modules/word/template/template-datasource.d.ts +154 -0
- package/dist/browser/modules/word/template/template-datasource.js +541 -0
- package/dist/browser/modules/word/template/template-engine.d.ts +121 -0
- package/dist/browser/modules/word/template/template-engine.js +1435 -0
- package/dist/browser/modules/word/types.d.ts +224 -25
- package/dist/browser/modules/word/units.d.ts +26 -0
- package/dist/browser/modules/word/units.js +43 -14
- package/dist/browser/modules/word/{writers → writer}/chart-writer.js +164 -23
- package/dist/browser/modules/word/writer/checkbox-writer.d.ts +17 -0
- package/dist/browser/modules/word/writer/checkbox-writer.js +79 -0
- package/dist/{types/modules/word/writers → browser/modules/word/writer}/comment-writer.d.ts +2 -1
- package/dist/browser/modules/word/{writers → writer}/comment-writer.js +8 -6
- package/dist/browser/modules/word/writer/common-parts.d.ts +57 -0
- package/dist/browser/modules/word/writer/common-parts.js +101 -0
- package/dist/{types/modules/word → browser/modules/word/writer}/content-types.d.ts +2 -2
- package/dist/{esm/modules/word → browser/modules/word/writer}/content-types.js +14 -6
- package/dist/browser/modules/word/writer/document-writer.d.ts +24 -0
- package/dist/browser/modules/word/writer/document-writer.js +473 -0
- package/dist/browser/modules/word/writer/docx-packager.d.ts +35 -0
- package/dist/browser/modules/word/writer/docx-packager.js +1515 -0
- package/dist/{types/modules/word/writers → browser/modules/word/writer}/footnote-writer.d.ts +3 -2
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/footnote-writer.js +13 -10
- package/dist/{types/modules/word/writers → browser/modules/word/writer}/header-footer-writer.d.ts +3 -2
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/header-footer-writer.js +39 -21
- package/dist/{types/modules/word/writers → browser/modules/word/writer}/image-writer.d.ts +1 -1
- package/dist/browser/modules/word/{writers → writer}/image-writer.js +11 -7
- package/dist/browser/modules/word/writer/math-writer.d.ts +20 -0
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/math-writer.js +21 -1
- package/dist/browser/modules/word/{writers → writer}/numbering-writer.d.ts +1 -1
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/numbering-writer.js +11 -4
- package/dist/browser/modules/word/{writers → writer}/paragraph-writer.d.ts +2 -1
- package/dist/browser/modules/word/{writers → writer}/paragraph-writer.js +73 -38
- package/dist/browser/modules/word/{writers → writer}/parts-writer.d.ts +3 -3
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/parts-writer.js +91 -12
- package/dist/browser/modules/word/writer/reference-scanners.d.ts +42 -0
- package/dist/browser/modules/word/writer/reference-scanners.js +111 -0
- package/dist/browser/modules/word/writer/relationships.d.ts +52 -0
- package/dist/browser/modules/word/writer/relationships.js +117 -0
- package/dist/browser/modules/word/writer/render-context.d.ts +124 -0
- package/dist/browser/modules/word/writer/render-context.js +46 -0
- package/dist/browser/modules/word/{writers → writer}/run-writer.d.ts +10 -1
- package/dist/{esm/modules/word/writers → browser/modules/word/writer}/run-writer.js +126 -24
- package/dist/browser/modules/word/writer/sdt-writer.d.ts +25 -0
- package/dist/browser/modules/word/writer/sdt-writer.js +189 -0
- package/dist/browser/modules/word/writer/stream-buf.d.ts +37 -0
- package/dist/browser/modules/word/writer/stream-buf.js +73 -0
- package/dist/browser/modules/word/writer/streaming-writer.d.ts +344 -0
- package/dist/browser/modules/word/writer/streaming-writer.js +1382 -0
- package/dist/browser/modules/word/writer/string-buf.d.ts +8 -0
- package/dist/browser/modules/word/writer/string-buf.js +7 -0
- package/dist/browser/modules/word/{writers → writer}/styles-writer.js +32 -1
- package/dist/browser/modules/word/{writers → writer}/table-writer.d.ts +2 -1
- package/dist/browser/modules/word/{writers → writer}/table-writer.js +94 -11
- package/dist/browser/modules/xml/types.d.ts +22 -0
- package/dist/browser/utils/crypto.browser.d.ts +3 -1
- package/dist/browser/utils/crypto.browser.js +3 -1
- package/dist/browser/utils/crypto.d.ts +4 -1
- package/dist/browser/utils/crypto.js +4 -1
- package/dist/browser/utils/font-metrics.d.ts +63 -0
- package/dist/browser/utils/font-metrics.js +293 -0
- package/dist/browser/utils/string-buf.d.ts +42 -0
- package/dist/browser/utils/string-buf.js +89 -0
- package/dist/browser/utils/theme-colors.d.ts +55 -0
- package/dist/browser/utils/theme-colors.js +120 -0
- package/dist/cjs/modules/archive/compression/streaming-compress.browser.js +29 -0
- package/dist/cjs/modules/archive/compression/streaming-compress.js +9 -0
- package/dist/cjs/modules/archive/compression/worker-pool/pool.browser.js +26 -1
- package/dist/cjs/modules/archive/fs/archive-file.js +78 -16
- package/dist/cjs/modules/archive/unzip/stream.browser.js +43 -2
- package/dist/cjs/modules/excel/chart/chart-ex-builder.js +7 -2
- package/dist/cjs/modules/excel/chart/chart-ex-renderer.js +4 -9
- package/dist/cjs/modules/excel/chart/chart.js +1 -7
- package/dist/cjs/modules/excel/stream/workbook-reader.browser.js +25 -1
- package/dist/cjs/modules/excel/stream/workbook-reader.js +9 -0
- package/dist/cjs/modules/excel/stream/workbook-writer.browser.js +228 -13
- package/dist/cjs/modules/excel/utils/string-buf.js +5 -81
- package/dist/cjs/modules/excel/workbook.browser.js +135 -25
- package/dist/cjs/modules/excel/xlsx/xform/chart/chart-space-xform.js +6 -20
- package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +32 -8
- package/dist/cjs/modules/excel/xlsx/xlsx.js +9 -1
- package/dist/cjs/modules/pdf/excel-bridge.js +33 -0
- package/dist/cjs/modules/pdf/font/metrics.js +11 -244
- package/dist/cjs/modules/pdf/index.js +2 -1
- package/dist/cjs/modules/pdf/render-layout-to-pdf.js +651 -0
- package/dist/cjs/modules/pdf/word-bridge.js +155 -274
- package/dist/cjs/modules/stream/index.base.js +4 -2
- package/dist/cjs/modules/stream/internal/sink-adapter.js +202 -0
- package/dist/cjs/modules/stream/pull-stream.js +51 -5
- package/dist/cjs/modules/word/advanced/diff.js +170 -0
- package/dist/cjs/modules/word/advanced/drawing-shapes.js +279 -0
- package/dist/cjs/modules/word/advanced/field-engine.js +1229 -0
- package/dist/cjs/modules/word/advanced/glossary.js +87 -0
- package/dist/cjs/modules/word/advanced/math-convert.js +599 -0
- package/dist/cjs/modules/word/advanced/ole-objects.js +277 -0
- package/dist/cjs/modules/word/advanced/style-map.js +329 -0
- package/dist/cjs/modules/word/advanced/validation.js +1068 -0
- package/dist/cjs/modules/word/advanced/vba-project.js +274 -0
- package/dist/cjs/modules/word/bridge/excel-bridge.js +1020 -0
- package/dist/cjs/modules/word/builder/document-handle.js +667 -0
- package/dist/cjs/modules/word/builder/paragraph-builders.js +109 -0
- package/dist/cjs/modules/word/builder/run-builders.js +676 -0
- package/dist/cjs/modules/word/builder/table-builders.js +53 -0
- package/dist/cjs/modules/word/constants.js +111 -2
- package/dist/cjs/modules/word/convert/conversion-ir.js +34 -0
- package/dist/cjs/modules/word/convert/docx-to-semantic.js +502 -0
- package/dist/cjs/modules/word/convert/flat-opc.js +390 -0
- package/dist/cjs/modules/word/convert/html/html-import.js +1910 -0
- package/dist/cjs/modules/word/{html-renderer.js → convert/html/html-renderer.js} +420 -69
- package/dist/cjs/modules/word/convert/html/html.js +20 -0
- package/dist/cjs/modules/word/convert/markdown/markdown-import.js +1329 -0
- package/dist/cjs/modules/word/convert/markdown/markdown-renderer.js +637 -0
- package/dist/cjs/modules/word/convert/markdown/markdown.js +21 -0
- package/dist/cjs/modules/word/convert/odt/odt.js +1936 -0
- package/dist/cjs/modules/word/core/color-utils.js +47 -0
- package/dist/cjs/modules/word/core/internal-utils.js +219 -0
- package/dist/cjs/modules/word/core/mapper.js +430 -0
- package/dist/cjs/modules/word/core/opc-paths.js +53 -0
- package/dist/cjs/modules/word/core/text-utils.js +210 -0
- package/dist/cjs/modules/word/core/walker.js +577 -0
- package/dist/cjs/modules/word/crypto.js +19 -8
- package/dist/cjs/modules/word/document-io.js +117 -197
- package/dist/cjs/modules/word/errors.js +59 -13
- package/dist/cjs/modules/word/excel.js +22 -0
- package/dist/cjs/modules/word/font/font-embed.js +652 -0
- package/dist/cjs/modules/word/{font-obfuscation.js → font/font-obfuscation.js} +4 -9
- package/dist/cjs/modules/word/font/hyphenation.js +4216 -0
- package/dist/cjs/modules/word/font/text-shaping.js +640 -0
- package/dist/cjs/modules/word/html.js +9 -7
- package/dist/cjs/modules/word/incremental-edit.js +366 -0
- package/dist/cjs/modules/word/index.base.js +370 -137
- package/dist/cjs/modules/word/layout/layout-constants.js +20 -0
- package/dist/cjs/modules/word/layout/layout-full.js +1699 -0
- package/dist/cjs/modules/word/layout/layout-model.js +17 -0
- package/dist/cjs/modules/word/layout/layout.js +1170 -0
- package/dist/cjs/modules/word/layout/render-page.js +1243 -0
- package/dist/cjs/modules/word/markdown.js +19 -0
- package/dist/cjs/modules/word/patcher.js +539 -0
- package/dist/cjs/modules/word/query/compat.js +61 -0
- package/dist/cjs/modules/word/query/data-binding.js +395 -0
- package/dist/cjs/modules/word/query/form-fields.js +272 -0
- package/dist/cjs/modules/word/query/format-search.js +334 -0
- package/dist/cjs/modules/word/query/mail-merge.js +114 -0
- package/dist/cjs/modules/word/query/merge.js +620 -0
- package/dist/cjs/modules/word/query/replace.js +304 -0
- package/dist/cjs/modules/word/query/revisions.js +885 -0
- package/dist/cjs/modules/word/query/search.js +361 -0
- package/dist/cjs/modules/word/query/split.js +138 -0
- package/dist/cjs/modules/word/query/style-resolve.js +374 -0
- package/dist/cjs/modules/word/reader/chart-parser.js +814 -0
- package/dist/cjs/modules/word/reader/comments-parser.js +96 -0
- package/dist/cjs/modules/word/reader/doc-props-parsers.js +194 -0
- package/dist/cjs/modules/word/reader/docx-reader.js +2560 -0
- package/dist/cjs/modules/word/reader/drawing-helpers.js +90 -0
- package/dist/cjs/modules/word/reader/form-field-parser.js +85 -0
- package/dist/cjs/modules/word/reader/image-parsers.js +293 -0
- package/dist/cjs/modules/word/reader/math-parser.js +424 -0
- package/dist/cjs/modules/word/reader/metadata-parsers.js +93 -0
- package/dist/cjs/modules/word/reader/numbering-parser.js +168 -0
- package/dist/cjs/modules/word/reader/paragraph-section-parsers.js +505 -0
- package/dist/cjs/modules/word/reader/parse-utils.js +271 -0
- package/dist/cjs/modules/word/reader/properties-parsers.js +338 -0
- package/dist/cjs/modules/word/reader/reader-context.js +66 -0
- package/dist/cjs/modules/word/reader/sdt-helpers.js +114 -0
- package/dist/cjs/modules/word/reader/settings-parser.js +265 -0
- package/dist/cjs/modules/word/reader/styles-parser.js +149 -0
- package/dist/cjs/modules/word/reader/table-properties-parsers.js +237 -0
- package/dist/cjs/modules/word/reader/theme-parser.js +169 -0
- package/dist/cjs/modules/word/reader/watermark-parser.js +113 -0
- package/dist/cjs/modules/word/security/cfb-reader.js +414 -0
- package/dist/cjs/modules/word/{digital-signatures.js → security/digital-signatures.js} +34 -34
- package/dist/cjs/modules/word/security/document-protection.js +208 -0
- package/dist/cjs/modules/word/security/encryption.js +612 -0
- package/dist/cjs/modules/word/security/policy.js +106 -0
- package/dist/cjs/modules/word/template/template-chart.js +170 -0
- package/dist/cjs/modules/word/template/template-datasource.js +549 -0
- package/dist/cjs/modules/word/template/template-engine.js +1430 -0
- package/dist/cjs/modules/word/units.js +44 -14
- package/dist/cjs/modules/word/{writers → writer}/chart-writer.js +163 -22
- package/dist/cjs/modules/word/writer/checkbox-writer.js +82 -0
- package/dist/cjs/modules/word/{writers → writer}/comment-writer.js +8 -6
- package/dist/cjs/modules/word/writer/common-parts.js +104 -0
- package/dist/cjs/modules/word/{content-types.js → writer/content-types.js} +14 -6
- package/dist/cjs/modules/word/writer/document-writer.js +478 -0
- package/dist/cjs/modules/word/writer/docx-packager.js +1551 -0
- package/dist/cjs/modules/word/{writers → writer}/footnote-writer.js +13 -10
- package/dist/cjs/modules/word/{writers → writer}/header-footer-writer.js +38 -20
- package/dist/cjs/modules/word/{writers → writer}/image-writer.js +11 -7
- package/dist/cjs/modules/word/{writers → writer}/math-writer.js +21 -1
- package/dist/cjs/modules/word/{writers → writer}/numbering-writer.js +11 -4
- package/dist/cjs/modules/word/{writers → writer}/paragraph-writer.js +72 -37
- package/dist/cjs/modules/word/{writers → writer}/parts-writer.js +91 -12
- package/dist/cjs/modules/word/writer/reference-scanners.js +120 -0
- package/dist/cjs/modules/word/writer/relationships.js +124 -0
- package/dist/cjs/modules/word/writer/render-context.js +51 -0
- package/dist/cjs/modules/word/{writers → writer}/run-writer.js +127 -24
- package/dist/cjs/modules/word/writer/sdt-writer.js +192 -0
- package/dist/cjs/modules/word/writer/stream-buf.js +76 -0
- package/dist/cjs/modules/word/writer/streaming-writer.js +1387 -0
- package/dist/cjs/modules/word/writer/string-buf.js +11 -0
- package/dist/cjs/modules/word/{writers → writer}/styles-writer.js +32 -1
- package/dist/cjs/modules/word/{writers → writer}/table-writer.js +94 -11
- package/dist/cjs/utils/crypto.browser.js +3 -1
- package/dist/cjs/utils/crypto.js +4 -1
- package/dist/cjs/utils/font-metrics.js +303 -0
- package/dist/cjs/utils/string-buf.js +92 -0
- package/dist/cjs/utils/theme-colors.js +126 -0
- package/dist/esm/modules/archive/compression/streaming-compress.browser.js +29 -0
- package/dist/esm/modules/archive/compression/streaming-compress.js +9 -0
- package/dist/esm/modules/archive/compression/worker-pool/pool.browser.js +26 -1
- package/dist/esm/modules/archive/fs/archive-file.js +78 -16
- package/dist/esm/modules/archive/unzip/stream.browser.js +43 -2
- package/dist/esm/modules/excel/chart/chart-ex-builder.js +7 -2
- package/dist/esm/modules/excel/chart/chart-ex-renderer.js +4 -9
- package/dist/esm/modules/excel/chart/chart.js +1 -7
- package/dist/esm/modules/excel/stream/workbook-reader.browser.js +25 -1
- package/dist/esm/modules/excel/stream/workbook-reader.js +9 -0
- package/dist/esm/modules/excel/stream/workbook-writer.browser.js +228 -13
- package/dist/esm/modules/excel/utils/string-buf.js +4 -81
- package/dist/esm/modules/excel/workbook.browser.js +135 -25
- package/dist/esm/modules/excel/xlsx/xform/chart/chart-space-xform.js +6 -20
- package/dist/esm/modules/excel/xlsx/xlsx.browser.js +32 -8
- package/dist/esm/modules/excel/xlsx/xlsx.js +9 -1
- package/dist/esm/modules/pdf/excel-bridge.js +32 -0
- package/dist/esm/modules/pdf/font/metrics.js +3 -237
- package/dist/esm/modules/pdf/index.js +1 -1
- package/dist/esm/modules/pdf/render-layout-to-pdf.js +647 -0
- package/dist/esm/modules/pdf/word-bridge.js +122 -274
- package/dist/esm/modules/stream/index.base.js +2 -1
- package/dist/esm/modules/stream/internal/sink-adapter.js +198 -0
- package/dist/esm/modules/stream/pull-stream.js +51 -5
- package/dist/esm/modules/word/advanced/diff.js +167 -0
- package/dist/esm/modules/word/advanced/drawing-shapes.js +268 -0
- package/dist/esm/modules/word/advanced/field-engine.js +1225 -0
- package/dist/esm/modules/word/advanced/glossary.js +79 -0
- package/dist/esm/modules/word/advanced/math-convert.js +595 -0
- package/dist/esm/modules/word/advanced/ole-objects.js +271 -0
- package/dist/esm/modules/word/advanced/style-map.js +322 -0
- package/dist/esm/modules/word/advanced/validation.js +1065 -0
- package/dist/esm/modules/word/advanced/vba-project.js +265 -0
- package/dist/esm/modules/word/bridge/excel-bridge.js +980 -0
- package/dist/esm/modules/word/builder/document-handle.js +664 -0
- package/dist/esm/modules/word/builder/paragraph-builders.js +90 -0
- package/dist/esm/modules/word/builder/run-builders.js +600 -0
- package/dist/esm/modules/word/builder/table-builders.js +45 -0
- package/dist/esm/modules/word/constants.js +109 -1
- package/dist/esm/modules/word/convert/conversion-ir.js +31 -0
- package/dist/esm/modules/word/convert/docx-to-semantic.js +499 -0
- package/dist/esm/modules/word/convert/flat-opc.js +385 -0
- package/dist/esm/modules/word/convert/html/html-import.js +1907 -0
- package/dist/{browser/modules/word → esm/modules/word/convert/html}/html-renderer.js +420 -69
- package/dist/esm/modules/word/convert/html/html.js +15 -0
- package/dist/esm/modules/word/convert/markdown/markdown-import.js +1325 -0
- package/dist/esm/modules/word/convert/markdown/markdown-renderer.js +634 -0
- package/dist/esm/modules/word/convert/markdown/markdown.js +15 -0
- package/dist/esm/modules/word/convert/odt/odt.js +1932 -0
- package/dist/esm/modules/word/core/color-utils.js +43 -0
- package/dist/esm/modules/word/core/internal-utils.js +209 -0
- package/dist/esm/modules/word/core/mapper.js +427 -0
- package/dist/esm/modules/word/core/opc-paths.js +48 -0
- package/dist/esm/modules/word/core/text-utils.js +202 -0
- package/dist/esm/modules/word/core/walker.js +570 -0
- package/dist/esm/modules/word/crypto.js +13 -7
- package/dist/esm/modules/word/document-io.js +80 -197
- package/dist/esm/modules/word/errors.js +54 -2
- package/dist/esm/modules/word/excel.js +13 -0
- package/dist/esm/modules/word/font/font-embed.js +646 -0
- package/dist/{browser/modules/word → esm/modules/word/font}/font-obfuscation.js +4 -9
- package/dist/esm/modules/word/font/hyphenation.js +4210 -0
- package/dist/esm/modules/word/font/text-shaping.js +635 -0
- package/dist/esm/modules/word/html.js +6 -5
- package/dist/esm/modules/word/incremental-edit.js +361 -0
- package/dist/esm/modules/word/index.base.js +138 -29
- package/dist/esm/modules/word/layout/layout-constants.js +17 -0
- package/dist/esm/modules/word/layout/layout-full.js +1696 -0
- package/dist/esm/modules/word/layout/layout-model.js +16 -0
- package/dist/esm/modules/word/layout/layout.js +1167 -0
- package/dist/esm/modules/word/layout/render-page.js +1238 -0
- package/dist/esm/modules/word/markdown.js +13 -0
- package/dist/esm/modules/word/patcher.js +537 -0
- package/dist/esm/modules/word/query/compat.js +58 -0
- package/dist/esm/modules/word/query/data-binding.js +392 -0
- package/dist/esm/modules/word/query/form-fields.js +268 -0
- package/dist/esm/modules/word/query/format-search.js +329 -0
- package/dist/esm/modules/word/query/mail-merge.js +111 -0
- package/dist/esm/modules/word/query/merge.js +617 -0
- package/dist/esm/modules/word/query/replace.js +301 -0
- package/dist/esm/modules/word/query/revisions.js +879 -0
- package/dist/esm/modules/word/query/search.js +346 -0
- package/dist/esm/modules/word/query/split.js +135 -0
- package/dist/esm/modules/word/query/style-resolve.js +368 -0
- package/dist/esm/modules/word/reader/chart-parser.js +810 -0
- package/dist/esm/modules/word/reader/comments-parser.js +92 -0
- package/dist/esm/modules/word/reader/doc-props-parsers.js +190 -0
- package/dist/esm/modules/word/reader/docx-reader.js +2557 -0
- package/dist/esm/modules/word/reader/drawing-helpers.js +84 -0
- package/dist/esm/modules/word/reader/form-field-parser.js +82 -0
- package/dist/esm/modules/word/reader/image-parsers.js +291 -0
- package/dist/esm/modules/word/reader/math-parser.js +422 -0
- package/dist/esm/modules/word/reader/metadata-parsers.js +87 -0
- package/dist/esm/modules/word/reader/numbering-parser.js +166 -0
- package/dist/esm/modules/word/reader/paragraph-section-parsers.js +503 -0
- package/dist/esm/modules/word/reader/parse-utils.js +249 -0
- package/dist/esm/modules/word/reader/properties-parsers.js +332 -0
- package/dist/esm/modules/word/reader/reader-context.js +61 -0
- package/dist/esm/modules/word/reader/sdt-helpers.js +111 -0
- package/dist/esm/modules/word/reader/settings-parser.js +263 -0
- package/dist/esm/modules/word/reader/styles-parser.js +147 -0
- package/dist/esm/modules/word/reader/table-properties-parsers.js +234 -0
- package/dist/esm/modules/word/reader/theme-parser.js +167 -0
- package/dist/esm/modules/word/reader/watermark-parser.js +110 -0
- package/dist/esm/modules/word/security/cfb-reader.js +410 -0
- package/dist/esm/modules/word/{digital-signatures.js → security/digital-signatures.js} +34 -34
- package/dist/esm/modules/word/security/document-protection.js +201 -0
- package/dist/esm/modules/word/security/encryption.js +602 -0
- package/dist/esm/modules/word/security/policy.js +102 -0
- package/dist/esm/modules/word/template/template-chart.js +167 -0
- package/dist/esm/modules/word/template/template-datasource.js +541 -0
- package/dist/esm/modules/word/template/template-engine.js +1435 -0
- package/dist/esm/modules/word/units.js +43 -14
- package/dist/esm/modules/word/{writers → writer}/chart-writer.js +164 -23
- package/dist/esm/modules/word/writer/checkbox-writer.js +79 -0
- package/dist/esm/modules/word/{writers → writer}/comment-writer.js +8 -6
- package/dist/esm/modules/word/writer/common-parts.js +101 -0
- package/dist/{browser/modules/word → esm/modules/word/writer}/content-types.js +14 -6
- package/dist/esm/modules/word/writer/document-writer.js +473 -0
- package/dist/esm/modules/word/writer/docx-packager.js +1515 -0
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/footnote-writer.js +13 -10
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/header-footer-writer.js +39 -21
- package/dist/esm/modules/word/{writers → writer}/image-writer.js +11 -7
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/math-writer.js +21 -1
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/numbering-writer.js +11 -4
- package/dist/esm/modules/word/{writers → writer}/paragraph-writer.js +73 -38
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/parts-writer.js +91 -12
- package/dist/esm/modules/word/writer/reference-scanners.js +111 -0
- package/dist/esm/modules/word/writer/relationships.js +117 -0
- package/dist/esm/modules/word/writer/render-context.js +46 -0
- package/dist/{browser/modules/word/writers → esm/modules/word/writer}/run-writer.js +126 -24
- package/dist/esm/modules/word/writer/sdt-writer.js +189 -0
- package/dist/esm/modules/word/writer/stream-buf.js +73 -0
- package/dist/esm/modules/word/writer/streaming-writer.js +1382 -0
- package/dist/esm/modules/word/writer/string-buf.js +7 -0
- package/dist/esm/modules/word/{writers → writer}/styles-writer.js +32 -1
- package/dist/esm/modules/word/{writers → writer}/table-writer.js +94 -11
- package/dist/esm/utils/crypto.browser.js +3 -1
- package/dist/esm/utils/crypto.js +4 -1
- package/dist/esm/utils/font-metrics.js +293 -0
- package/dist/esm/utils/string-buf.js +89 -0
- package/dist/esm/utils/theme-colors.js +120 -0
- package/dist/iife/excelts.iife.js +70692 -70337
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +57 -57
- package/dist/types/modules/archive/fs/archive-file.d.ts +8 -5
- package/dist/types/modules/excel/chart/chart-ex-types.d.ts +0 -12
- package/dist/types/modules/excel/chart/chart.d.ts +1 -5
- package/dist/types/modules/excel/chart/types.d.ts +0 -6
- package/dist/types/modules/excel/stream/workbook-writer.browser.d.ts +40 -0
- package/dist/types/modules/excel/utils/string-buf.d.ts +5 -26
- package/dist/types/modules/excel/xlsx/xlsx.browser.d.ts +19 -9
- package/dist/types/modules/excel/xlsx/xlsx.d.ts +10 -2
- package/dist/types/modules/pdf/excel-bridge.d.ts +30 -1
- package/dist/types/modules/pdf/font/metrics.d.ts +3 -52
- package/dist/types/modules/pdf/index.d.ts +1 -1
- package/dist/types/modules/pdf/render-layout-to-pdf.d.ts +66 -0
- package/dist/types/modules/pdf/word-bridge.d.ts +80 -12
- package/dist/types/modules/stream/index.base.d.ts +2 -0
- package/dist/types/modules/stream/internal/sink-adapter.d.ts +65 -0
- package/dist/types/modules/stream/pull-stream.d.ts +19 -2
- package/dist/types/modules/stream/types.d.ts +13 -1
- package/dist/types/modules/word/advanced/diff.d.ts +61 -0
- package/dist/types/modules/word/advanced/drawing-shapes.d.ts +269 -0
- package/dist/types/modules/word/advanced/field-engine.d.ts +43 -0
- package/dist/types/modules/word/advanced/glossary.d.ts +86 -0
- package/dist/types/modules/word/advanced/math-convert.d.ts +30 -0
- package/dist/types/modules/word/advanced/ole-objects.d.ts +115 -0
- package/dist/types/modules/word/advanced/style-map.d.ts +105 -0
- package/dist/types/modules/word/advanced/validation.d.ts +56 -0
- package/dist/types/modules/word/advanced/vba-project.d.ts +91 -0
- package/dist/types/modules/word/bridge/excel-bridge.d.ts +127 -0
- package/dist/types/modules/word/builder/document-handle.d.ts +151 -0
- package/dist/types/modules/word/builder/paragraph-builders.d.ts +61 -0
- package/dist/types/modules/word/builder/run-builders.d.ts +374 -0
- package/dist/types/modules/word/builder/table-builders.d.ts +23 -0
- package/dist/types/modules/word/constants.d.ts +39 -1
- package/dist/types/modules/word/convert/conversion-ir.d.ts +210 -0
- package/dist/types/modules/word/convert/docx-to-semantic.d.ts +39 -0
- package/dist/types/modules/word/convert/flat-opc.d.ts +44 -0
- package/dist/types/modules/word/convert/html/html-import.d.ts +50 -0
- package/dist/{browser/modules/word → types/modules/word/convert/html}/html-renderer.d.ts +14 -1
- package/dist/types/modules/word/convert/html/html.d.ts +15 -0
- package/dist/types/modules/word/convert/markdown/markdown-import.d.ts +68 -0
- package/dist/types/modules/word/convert/markdown/markdown-renderer.d.ts +25 -0
- package/dist/types/modules/word/convert/markdown/markdown.d.ts +15 -0
- package/dist/types/modules/word/convert/odt/odt.d.ts +41 -0
- package/dist/types/modules/word/{color-utils.d.ts → core/color-utils.d.ts} +8 -1
- package/dist/types/modules/word/core/internal-utils.d.ts +90 -0
- package/dist/types/modules/word/core/mapper.d.ts +44 -0
- package/dist/types/modules/word/core/opc-paths.d.ts +33 -0
- package/dist/types/modules/word/core/text-utils.d.ts +38 -0
- package/dist/types/modules/word/core/walker.d.ts +119 -0
- package/dist/types/modules/word/crypto.d.ts +14 -9
- package/dist/types/modules/word/document-io.d.ts +59 -27
- package/dist/types/modules/word/errors.d.ts +44 -1
- package/dist/types/modules/word/excel.d.ts +14 -0
- package/dist/types/modules/word/font/font-embed.d.ts +112 -0
- package/dist/types/modules/word/font/hyphenation.d.ts +65 -0
- package/dist/types/modules/word/font/text-shaping.d.ts +58 -0
- package/dist/types/modules/word/html.d.ts +7 -6
- package/dist/types/modules/word/incremental-edit.d.ts +123 -0
- package/dist/types/modules/word/index.base.d.ts +194 -10
- package/dist/types/modules/word/layout/layout-constants.d.ts +17 -0
- package/dist/types/modules/word/layout/layout-full.d.ts +53 -0
- package/dist/types/modules/word/layout/layout-model.d.ts +344 -0
- package/dist/types/modules/word/layout/layout.d.ts +63 -0
- package/dist/types/modules/word/layout/render-page.d.ts +57 -0
- package/dist/types/modules/word/markdown.d.ts +14 -0
- package/dist/types/modules/word/patcher.d.ts +62 -0
- package/dist/types/modules/word/query/compat.d.ts +25 -0
- package/dist/types/modules/word/query/data-binding.d.ts +22 -0
- package/dist/types/modules/word/query/form-fields.d.ts +41 -0
- package/dist/types/modules/word/query/format-search.d.ts +99 -0
- package/dist/types/modules/word/query/mail-merge.d.ts +25 -0
- package/dist/types/modules/word/query/merge.d.ts +50 -0
- package/dist/types/modules/word/query/replace.d.ts +47 -0
- package/dist/types/modules/word/query/revisions.d.ts +67 -0
- package/dist/types/modules/word/query/search.d.ts +129 -0
- package/dist/types/modules/word/query/split.d.ts +44 -0
- package/dist/types/modules/word/query/style-resolve.d.ts +104 -0
- package/dist/types/modules/word/reader/chart-parser.d.ts +20 -0
- package/dist/types/modules/word/reader/comments-parser.d.ts +26 -0
- package/dist/types/modules/word/reader/doc-props-parsers.d.ts +15 -0
- package/dist/types/modules/word/reader/docx-reader.d.ts +27 -0
- package/dist/types/modules/word/reader/drawing-helpers.d.ts +27 -0
- package/dist/types/modules/word/reader/form-field-parser.d.ts +21 -0
- package/dist/types/modules/word/reader/image-parsers.d.ts +11 -0
- package/dist/types/modules/word/reader/math-parser.d.ts +12 -0
- package/dist/types/modules/word/reader/metadata-parsers.d.ts +17 -0
- package/dist/types/modules/word/reader/numbering-parser.d.ts +13 -0
- package/dist/types/modules/word/reader/paragraph-section-parsers.d.ts +12 -0
- package/dist/types/modules/word/reader/parse-utils.d.ts +91 -0
- package/dist/types/modules/word/reader/properties-parsers.d.ts +21 -0
- package/dist/types/modules/word/reader/reader-context.d.ts +69 -0
- package/dist/types/modules/word/reader/sdt-helpers.d.ts +29 -0
- package/dist/types/modules/word/reader/settings-parser.d.ts +8 -0
- package/dist/types/modules/word/reader/styles-parser.d.ts +12 -0
- package/dist/types/modules/word/reader/table-properties-parsers.d.ts +12 -0
- package/dist/types/modules/word/reader/theme-parser.d.ts +8 -0
- package/dist/types/modules/word/reader/watermark-parser.d.ts +15 -0
- package/dist/types/modules/word/security/cfb-reader.d.ts +37 -0
- package/dist/types/modules/word/{digital-signatures.d.ts → security/digital-signatures.d.ts} +19 -11
- package/dist/types/modules/word/security/document-protection.d.ts +93 -0
- package/dist/{browser/modules/word → types/modules/word/security}/encryption.d.ts +51 -4
- package/dist/types/modules/word/security/policy.d.ts +80 -0
- package/dist/types/modules/word/template/template-chart.d.ts +56 -0
- package/dist/types/modules/word/template/template-datasource.d.ts +154 -0
- package/dist/types/modules/word/template/template-engine.d.ts +121 -0
- package/dist/types/modules/word/types.d.ts +224 -25
- package/dist/types/modules/word/units.d.ts +26 -0
- package/dist/types/modules/word/writer/checkbox-writer.d.ts +17 -0
- package/dist/{browser/modules/word/writers → types/modules/word/writer}/comment-writer.d.ts +2 -1
- package/dist/types/modules/word/writer/common-parts.d.ts +57 -0
- package/dist/{browser/modules/word → types/modules/word/writer}/content-types.d.ts +2 -2
- package/dist/types/modules/word/writer/document-writer.d.ts +24 -0
- package/dist/types/modules/word/writer/docx-packager.d.ts +35 -0
- package/dist/{browser/modules/word/writers → types/modules/word/writer}/footnote-writer.d.ts +3 -2
- package/dist/{browser/modules/word/writers → types/modules/word/writer}/header-footer-writer.d.ts +3 -2
- package/dist/{browser/modules/word/writers → types/modules/word/writer}/image-writer.d.ts +1 -1
- package/dist/types/modules/word/writer/math-writer.d.ts +20 -0
- package/dist/types/modules/word/{writers → writer}/numbering-writer.d.ts +1 -1
- package/dist/types/modules/word/{writers → writer}/paragraph-writer.d.ts +2 -1
- package/dist/types/modules/word/{writers → writer}/parts-writer.d.ts +3 -3
- package/dist/types/modules/word/writer/reference-scanners.d.ts +42 -0
- package/dist/types/modules/word/writer/relationships.d.ts +52 -0
- package/dist/types/modules/word/writer/render-context.d.ts +124 -0
- package/dist/types/modules/word/{writers → writer}/run-writer.d.ts +10 -1
- package/dist/types/modules/word/writer/sdt-writer.d.ts +25 -0
- package/dist/types/modules/word/writer/stream-buf.d.ts +37 -0
- package/dist/types/modules/word/writer/streaming-writer.d.ts +344 -0
- package/dist/types/modules/word/writer/string-buf.d.ts +8 -0
- package/dist/types/modules/word/{writers → writer}/table-writer.d.ts +2 -1
- package/dist/types/modules/xml/types.d.ts +22 -0
- package/dist/types/utils/crypto.browser.d.ts +3 -1
- package/dist/types/utils/crypto.d.ts +4 -1
- package/dist/types/utils/font-metrics.d.ts +63 -0
- package/dist/types/utils/string-buf.d.ts +42 -0
- package/dist/types/utils/theme-colors.d.ts +55 -0
- package/package.json +121 -39
- package/dist/browser/modules/word/color-utils.js +0 -94
- package/dist/browser/modules/word/document.d.ts +0 -657
- package/dist/browser/modules/word/document.js +0 -1533
- package/dist/browser/modules/word/docx-packager.d.ts +0 -14
- package/dist/browser/modules/word/docx-packager.js +0 -822
- package/dist/browser/modules/word/docx-reader.d.ts +0 -11
- package/dist/browser/modules/word/docx-reader.js +0 -4929
- package/dist/browser/modules/word/encryption.js +0 -274
- package/dist/browser/modules/word/internal-utils.d.ts +0 -23
- package/dist/browser/modules/word/internal-utils.js +0 -54
- package/dist/browser/modules/word/namespaces.d.ts +0 -159
- package/dist/browser/modules/word/namespaces.js +0 -189
- package/dist/browser/modules/word/relationships.d.ts +0 -30
- package/dist/browser/modules/word/relationships.js +0 -48
- package/dist/browser/modules/word/writers/checkbox-writer.d.ts +0 -9
- package/dist/browser/modules/word/writers/checkbox-writer.js +0 -42
- package/dist/browser/modules/word/writers/document-writer.d.ts +0 -16
- package/dist/browser/modules/word/writers/document-writer.js +0 -461
- package/dist/browser/modules/word/writers/math-writer.d.ts +0 -9
- package/dist/cjs/modules/word/color-utils.js +0 -97
- package/dist/cjs/modules/word/document.js +0 -1645
- package/dist/cjs/modules/word/docx-packager.js +0 -825
- package/dist/cjs/modules/word/docx-reader.js +0 -4932
- package/dist/cjs/modules/word/encryption.js +0 -282
- package/dist/cjs/modules/word/internal-utils.js +0 -59
- package/dist/cjs/modules/word/namespaces.js +0 -192
- package/dist/cjs/modules/word/relationships.js +0 -55
- package/dist/cjs/modules/word/writers/checkbox-writer.js +0 -45
- package/dist/cjs/modules/word/writers/document-writer.js +0 -465
- package/dist/esm/modules/word/color-utils.js +0 -94
- package/dist/esm/modules/word/document.js +0 -1533
- package/dist/esm/modules/word/docx-packager.js +0 -822
- package/dist/esm/modules/word/docx-reader.js +0 -4929
- package/dist/esm/modules/word/encryption.js +0 -274
- package/dist/esm/modules/word/internal-utils.js +0 -54
- package/dist/esm/modules/word/namespaces.js +0 -189
- package/dist/esm/modules/word/relationships.js +0 -48
- package/dist/esm/modules/word/writers/checkbox-writer.js +0 -42
- package/dist/esm/modules/word/writers/document-writer.js +0 -461
- package/dist/types/modules/word/document.d.ts +0 -657
- package/dist/types/modules/word/docx-packager.d.ts +0 -14
- package/dist/types/modules/word/docx-reader.d.ts +0 -11
- package/dist/types/modules/word/internal-utils.d.ts +0 -23
- package/dist/types/modules/word/namespaces.d.ts +0 -159
- package/dist/types/modules/word/relationships.d.ts +0 -30
- package/dist/types/modules/word/writers/checkbox-writer.d.ts +0 -9
- package/dist/types/modules/word/writers/document-writer.d.ts +0 -16
- package/dist/types/modules/word/writers/math-writer.d.ts +0 -9
- /package/dist/browser/modules/word/{font-obfuscation.d.ts → font/font-obfuscation.d.ts} +0 -0
- /package/dist/browser/modules/word/{writers → writer}/chart-writer.d.ts +0 -0
- /package/dist/browser/modules/word/{writers → writer}/section-writer.d.ts +0 -0
- /package/dist/browser/modules/word/{writers → writer}/section-writer.js +0 -0
- /package/dist/browser/modules/word/{writers → writer}/styles-writer.d.ts +0 -0
- /package/dist/browser/modules/word/{writers → writer}/textbox-writer.d.ts +0 -0
- /package/dist/browser/modules/word/{writers → writer}/textbox-writer.js +0 -0
- /package/dist/browser/modules/word/{writers → writer}/toc-writer.d.ts +0 -0
- /package/dist/browser/modules/word/{writers → writer}/toc-writer.js +0 -0
- /package/dist/cjs/modules/word/{writers → writer}/section-writer.js +0 -0
- /package/dist/cjs/modules/word/{writers → writer}/textbox-writer.js +0 -0
- /package/dist/cjs/modules/word/{writers → writer}/toc-writer.js +0 -0
- /package/dist/esm/modules/word/{writers → writer}/section-writer.js +0 -0
- /package/dist/esm/modules/word/{writers → writer}/textbox-writer.js +0 -0
- /package/dist/esm/modules/word/{writers → writer}/toc-writer.js +0 -0
- /package/dist/types/modules/word/{font-obfuscation.d.ts → font/font-obfuscation.d.ts} +0 -0
- /package/dist/types/modules/word/{writers → writer}/chart-writer.d.ts +0 -0
- /package/dist/types/modules/word/{writers → writer}/section-writer.d.ts +0 -0
- /package/dist/types/modules/word/{writers → writer}/styles-writer.d.ts +0 -0
- /package/dist/types/modules/word/{writers → writer}/textbox-writer.d.ts +0 -0
- /package/dist/types/modules/word/{writers → writer}/toc-writer.d.ts +0 -0
|
@@ -0,0 +1,647 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LayoutDocument → PDF translation layer.
|
|
3
|
+
*
|
|
4
|
+
* Consumes the fully-positioned `LayoutDocument` produced by
|
|
5
|
+
* `@word/layout/layout-full` and emits PDF operators via
|
|
6
|
+
* `PdfDocumentBuilder`. Coordinate translation is the only logic
|
|
7
|
+
* here — every flow decision (line wrapping, page breaks, table cell
|
|
8
|
+
* sizing, float positioning, footnote placement) has already been
|
|
9
|
+
* resolved by the layout engine.
|
|
10
|
+
*
|
|
11
|
+
* The Word layout coordinate system uses points with origin at the
|
|
12
|
+
* top-left of the **content area** of each page (not the page itself),
|
|
13
|
+
* with Y increasing downwards. The PDF coordinate system uses points
|
|
14
|
+
* with origin at the bottom-left of the page and Y increasing upwards.
|
|
15
|
+
* `pdfY = pageHeight - (geometry.marginTop + layoutY) - lineHeight`,
|
|
16
|
+
* with the per-element `lineHeight` baked into rect.height for non-
|
|
17
|
+
* paragraph variants and per-line for paragraphs.
|
|
18
|
+
*/
|
|
19
|
+
import { PdfDocumentBuilder } from "./builder/document-builder.js";
|
|
20
|
+
const BLACK = { r: 0, g: 0, b: 0 };
|
|
21
|
+
/**
|
|
22
|
+
* Render a `LayoutDocument` into a freshly-constructed
|
|
23
|
+
* `PdfDocumentBuilder`. Call `.build()` on the returned builder to get
|
|
24
|
+
* the final PDF bytes; alternatively use {@link layoutToPdfBytes}.
|
|
25
|
+
*/
|
|
26
|
+
export function renderLayoutDocumentToPdf(layout, options = {}) {
|
|
27
|
+
const builder = new PdfDocumentBuilder();
|
|
28
|
+
if (options.title || options.author || options.subject) {
|
|
29
|
+
builder.setMetadata({
|
|
30
|
+
title: options.title,
|
|
31
|
+
author: options.author,
|
|
32
|
+
subject: options.subject,
|
|
33
|
+
creator: options.creator
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
for (const page of layout.pages) {
|
|
37
|
+
const pdfPage = builder.addPage({
|
|
38
|
+
width: page.geometry.width,
|
|
39
|
+
height: page.geometry.height
|
|
40
|
+
});
|
|
41
|
+
renderLayoutPage(pdfPage, page, options);
|
|
42
|
+
}
|
|
43
|
+
return builder;
|
|
44
|
+
}
|
|
45
|
+
/** Convenience: render and immediately serialise to PDF bytes. */
|
|
46
|
+
export async function layoutToPdfBytes(layout, options = {}) {
|
|
47
|
+
const builder = renderLayoutDocumentToPdf(layout, options);
|
|
48
|
+
return builder.build();
|
|
49
|
+
}
|
|
50
|
+
// =============================================================================
|
|
51
|
+
// Internal: per-page rendering
|
|
52
|
+
// =============================================================================
|
|
53
|
+
function renderLayoutPage(pdfPage, page, opts) {
|
|
54
|
+
// Header / footer paragraphs are positioned with layout-y already
|
|
55
|
+
// expressed as a page-absolute offset (the layout engine adds
|
|
56
|
+
// `pgMar.header` to header content and starts footer content at
|
|
57
|
+
// `pageHeight - pgMar.footer`). Renderers therefore treat header /
|
|
58
|
+
// footer geometry as if the page had zero top margin so layout-y
|
|
59
|
+
// maps straight to the absolute page position via `toPdfY`.
|
|
60
|
+
const bandGeometry = { ...page.geometry, marginTop: 0 };
|
|
61
|
+
if (page.header) {
|
|
62
|
+
for (const item of page.header) {
|
|
63
|
+
renderHeaderFooterItem(pdfPage, item, bandGeometry, opts);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Body
|
|
67
|
+
for (const item of page.content) {
|
|
68
|
+
renderPageContent(pdfPage, item, page.geometry, opts);
|
|
69
|
+
}
|
|
70
|
+
if (page.footer) {
|
|
71
|
+
for (const item of page.footer) {
|
|
72
|
+
renderHeaderFooterItem(pdfPage, item, bandGeometry, opts);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Footnote area (rendered above the footer band). The optional
|
|
76
|
+
// separator above it follows ECMA-376 §17.11.10's convention:
|
|
77
|
+
// - "separator" → ⅓-content-width rule (page introduces fresh notes)
|
|
78
|
+
// - "continuationSeparator" → full-content-width rule (deferred from
|
|
79
|
+
// previous page).
|
|
80
|
+
if (page.footnoteSeparator) {
|
|
81
|
+
const sep = page.footnoteSeparator;
|
|
82
|
+
const xStart = page.geometry.marginLeft;
|
|
83
|
+
const ruleWidth = sep.kind === "separator" ? page.geometry.contentWidth / 3 : page.geometry.contentWidth;
|
|
84
|
+
const yPdf = toPdfY({ ...page.geometry, marginTop: 0 }, sep.y);
|
|
85
|
+
pdfPage.drawLine({
|
|
86
|
+
x1: xStart,
|
|
87
|
+
y1: yPdf,
|
|
88
|
+
x2: xStart + ruleWidth,
|
|
89
|
+
y2: yPdf,
|
|
90
|
+
color: BLACK,
|
|
91
|
+
lineWidth: 0.5
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (page.footnoteArea) {
|
|
95
|
+
for (const para of page.footnoteArea) {
|
|
96
|
+
renderParagraph(pdfPage, para, bandGeometry, opts);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Dispatch helper for `header` / `footer` whose entries can be paragraphs or tables. */
|
|
101
|
+
function renderHeaderFooterItem(pdfPage, item, geometry, opts) {
|
|
102
|
+
if (item.type === "paragraph") {
|
|
103
|
+
renderParagraph(pdfPage, item, geometry, opts);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
renderTable(pdfPage, item, geometry, opts);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function renderPageContent(pdfPage, item, geometry, opts) {
|
|
110
|
+
switch (item.type) {
|
|
111
|
+
case "paragraph":
|
|
112
|
+
renderParagraph(pdfPage, item, geometry, opts);
|
|
113
|
+
break;
|
|
114
|
+
case "table":
|
|
115
|
+
renderTable(pdfPage, item, geometry, opts);
|
|
116
|
+
break;
|
|
117
|
+
case "image":
|
|
118
|
+
renderImage(pdfPage, item, geometry);
|
|
119
|
+
break;
|
|
120
|
+
case "float":
|
|
121
|
+
renderFloat(pdfPage, item, geometry, opts);
|
|
122
|
+
break;
|
|
123
|
+
case "textBox":
|
|
124
|
+
renderTextBox(pdfPage, item, geometry, opts);
|
|
125
|
+
break;
|
|
126
|
+
case "shape":
|
|
127
|
+
renderShape(pdfPage, item, geometry, opts);
|
|
128
|
+
break;
|
|
129
|
+
case "chart":
|
|
130
|
+
renderChart(pdfPage, item, geometry, opts);
|
|
131
|
+
break;
|
|
132
|
+
case "sdt":
|
|
133
|
+
renderSdt(pdfPage, item, geometry, opts);
|
|
134
|
+
break;
|
|
135
|
+
case "math":
|
|
136
|
+
renderMath(pdfPage, item, geometry, opts);
|
|
137
|
+
break;
|
|
138
|
+
case "checkBox":
|
|
139
|
+
renderCheckBox(pdfPage, item, geometry);
|
|
140
|
+
break;
|
|
141
|
+
case "tableOfContents":
|
|
142
|
+
renderToc(pdfPage, item, geometry, opts);
|
|
143
|
+
break;
|
|
144
|
+
case "altChunk":
|
|
145
|
+
renderAltChunkPlaceholder(pdfPage, item, geometry);
|
|
146
|
+
break;
|
|
147
|
+
case "opaqueDrawing":
|
|
148
|
+
renderOpaqueDrawingPlaceholder(pdfPage, item, geometry);
|
|
149
|
+
break;
|
|
150
|
+
default: {
|
|
151
|
+
const _exhaustive = item;
|
|
152
|
+
throw new Error(`renderLayoutDocumentToPdf: unhandled PageContent ${_exhaustive.type}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// =============================================================================
|
|
157
|
+
// Coordinate helpers
|
|
158
|
+
// =============================================================================
|
|
159
|
+
/**
|
|
160
|
+
* Translate a layout-space (top-left, Y-down) point to PDF space
|
|
161
|
+
* (bottom-left, Y-up). Layout positions are stored relative to the
|
|
162
|
+
* content area; we add the page margin to get the page-absolute layout
|
|
163
|
+
* coordinate, then flip Y.
|
|
164
|
+
*/
|
|
165
|
+
function toPdfY(geometry, layoutY) {
|
|
166
|
+
return geometry.height - geometry.marginTop - layoutY;
|
|
167
|
+
}
|
|
168
|
+
function toPdfX(geometry, layoutX) {
|
|
169
|
+
return geometry.marginLeft + layoutX;
|
|
170
|
+
}
|
|
171
|
+
function hexToColor(hex) {
|
|
172
|
+
if (!hex) {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
const cleaned = hex.startsWith("#") ? hex.slice(1) : hex;
|
|
176
|
+
if (cleaned.length !== 6) {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
const r = parseInt(cleaned.slice(0, 2), 16);
|
|
180
|
+
const g = parseInt(cleaned.slice(2, 4), 16);
|
|
181
|
+
const b = parseInt(cleaned.slice(4, 6), 16);
|
|
182
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
return { r: r / 255, g: g / 255, b: b / 255 };
|
|
186
|
+
}
|
|
187
|
+
// =============================================================================
|
|
188
|
+
// Renderers — primitive variants
|
|
189
|
+
// =============================================================================
|
|
190
|
+
function renderParagraph(pdfPage, para, geometry, opts) {
|
|
191
|
+
for (const line of para.lines) {
|
|
192
|
+
renderLine(pdfPage, para, line, geometry, opts);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function renderLine(pdfPage, para, line, geometry, opts) {
|
|
196
|
+
// Layout y stores the top-of-line offset within the paragraph; baseline
|
|
197
|
+
// is the distance from that top to the glyph baseline. PDF wants the
|
|
198
|
+
// baseline as the y argument to drawText.
|
|
199
|
+
const baselineLayoutY = para.rect.y + line.y + line.baseline;
|
|
200
|
+
const baselinePdfY = toPdfY(geometry, baselineLayoutY);
|
|
201
|
+
// Top edge of the line for inline image placement.
|
|
202
|
+
const lineTopLayoutY = para.rect.y + line.y;
|
|
203
|
+
for (const item of line.runs) {
|
|
204
|
+
if (item.type === "image") {
|
|
205
|
+
renderInlineImage(pdfPage, item, para.rect.x, lineTopLayoutY, line.height, geometry);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
renderRun(pdfPage, item, para.rect.x, baselinePdfY, geometry, opts);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function renderInlineImage(pdfPage, item, paragraphX, lineTopLayoutY, lineHeight, geometry) {
|
|
213
|
+
if (item.data.length === 0) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const format = inferImageFormat(item.mimeType);
|
|
217
|
+
if (!format) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const x = toPdfX(geometry, paragraphX + item.x);
|
|
221
|
+
// Inline images sit on the line's baseline; translate the layout
|
|
222
|
+
// top-of-line into PDF coordinates and place the image's bottom
|
|
223
|
+
// edge there. When the image is shorter than the line, it
|
|
224
|
+
// bottom-aligns within the line — matches Word's default for inline
|
|
225
|
+
// images.
|
|
226
|
+
const imageBottomLayoutY = lineTopLayoutY + Math.min(lineHeight, item.height);
|
|
227
|
+
const yPdf = toPdfY(geometry, imageBottomLayoutY);
|
|
228
|
+
pdfPage.drawImage({
|
|
229
|
+
data: item.data,
|
|
230
|
+
format,
|
|
231
|
+
x,
|
|
232
|
+
y: yPdf,
|
|
233
|
+
width: item.width,
|
|
234
|
+
height: item.height
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function renderRun(pdfPage, run, paragraphX, baselinePdfY, geometry, opts) {
|
|
238
|
+
const x = toPdfX(geometry, paragraphX + run.x);
|
|
239
|
+
const fontFamily = run.font || opts.defaultFont || "Helvetica";
|
|
240
|
+
const fontSize = run.fontSize || opts.defaultFontSize || 11;
|
|
241
|
+
const color = hexToColor(run.color) ?? BLACK;
|
|
242
|
+
// Sub/superscript: shift the draw baseline by ⅓ of the (already
|
|
243
|
+
// scaled) font size. Word's actual offset is closer to half the
|
|
244
|
+
// surrounding-text size, but applying a third here matches the
|
|
245
|
+
// visual position users see in modern Word builds well enough for
|
|
246
|
+
// generated PDFs and keeps the run inside the line box even when
|
|
247
|
+
// the surrounding text is the same size as the source.
|
|
248
|
+
let drawBaselineY = baselinePdfY;
|
|
249
|
+
if (run.verticalAlign === "superscript") {
|
|
250
|
+
drawBaselineY = baselinePdfY + fontSize * 0.33;
|
|
251
|
+
}
|
|
252
|
+
else if (run.verticalAlign === "subscript") {
|
|
253
|
+
drawBaselineY = baselinePdfY - fontSize * 0.33;
|
|
254
|
+
}
|
|
255
|
+
if (run.text.length > 0) {
|
|
256
|
+
pdfPage.drawText(run.text, {
|
|
257
|
+
x,
|
|
258
|
+
y: drawBaselineY,
|
|
259
|
+
fontFamily,
|
|
260
|
+
fontSize,
|
|
261
|
+
bold: run.bold,
|
|
262
|
+
italic: run.italic,
|
|
263
|
+
color
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
// Underline / strikethrough — draw 1pt-thick lines at the conventional
|
|
267
|
+
// offsets relative to the (possibly shifted) baseline.
|
|
268
|
+
if (run.underline && run.text.length > 0) {
|
|
269
|
+
const underlineY = drawBaselineY - fontSize * 0.12;
|
|
270
|
+
pdfPage.drawLine({
|
|
271
|
+
x1: x,
|
|
272
|
+
y1: underlineY,
|
|
273
|
+
x2: x + run.width,
|
|
274
|
+
y2: underlineY,
|
|
275
|
+
color,
|
|
276
|
+
lineWidth: Math.max(0.5, fontSize * 0.05)
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
if (run.strikethrough && run.text.length > 0) {
|
|
280
|
+
const strikeY = drawBaselineY + fontSize * 0.3;
|
|
281
|
+
pdfPage.drawLine({
|
|
282
|
+
x1: x,
|
|
283
|
+
y1: strikeY,
|
|
284
|
+
x2: x + run.width,
|
|
285
|
+
y2: strikeY,
|
|
286
|
+
color,
|
|
287
|
+
lineWidth: Math.max(0.5, fontSize * 0.05)
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function renderTable(pdfPage, table, geometry, opts) {
|
|
292
|
+
for (const cell of table.cells) {
|
|
293
|
+
const xPdf = toPdfX(geometry, table.rect.x + cell.rect.x);
|
|
294
|
+
const yPdf = toPdfY(geometry, table.rect.y + cell.rect.y + cell.rect.height);
|
|
295
|
+
const w = cell.rect.width;
|
|
296
|
+
const h = cell.rect.height;
|
|
297
|
+
// Background
|
|
298
|
+
if (cell.backgroundColor) {
|
|
299
|
+
const fill = hexToColor(cell.backgroundColor);
|
|
300
|
+
if (fill) {
|
|
301
|
+
pdfPage.drawRect({ x: xPdf, y: yPdf, width: w, height: h, fill });
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// Borders
|
|
305
|
+
const borders = cell.borders;
|
|
306
|
+
if (borders) {
|
|
307
|
+
if (borders.top) {
|
|
308
|
+
const c = hexToColor(borders.top.color) ?? BLACK;
|
|
309
|
+
pdfPage.drawLine({
|
|
310
|
+
x1: xPdf,
|
|
311
|
+
y1: yPdf + h,
|
|
312
|
+
x2: xPdf + w,
|
|
313
|
+
y2: yPdf + h,
|
|
314
|
+
color: c,
|
|
315
|
+
lineWidth: borders.top.width
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
if (borders.bottom) {
|
|
319
|
+
const c = hexToColor(borders.bottom.color) ?? BLACK;
|
|
320
|
+
pdfPage.drawLine({
|
|
321
|
+
x1: xPdf,
|
|
322
|
+
y1: yPdf,
|
|
323
|
+
x2: xPdf + w,
|
|
324
|
+
y2: yPdf,
|
|
325
|
+
color: c,
|
|
326
|
+
lineWidth: borders.bottom.width
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
if (borders.left) {
|
|
330
|
+
const c = hexToColor(borders.left.color) ?? BLACK;
|
|
331
|
+
pdfPage.drawLine({
|
|
332
|
+
x1: xPdf,
|
|
333
|
+
y1: yPdf,
|
|
334
|
+
x2: xPdf,
|
|
335
|
+
y2: yPdf + h,
|
|
336
|
+
color: c,
|
|
337
|
+
lineWidth: borders.left.width
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (borders.right) {
|
|
341
|
+
const c = hexToColor(borders.right.color) ?? BLACK;
|
|
342
|
+
pdfPage.drawLine({
|
|
343
|
+
x1: xPdf + w,
|
|
344
|
+
y1: yPdf,
|
|
345
|
+
x2: xPdf + w,
|
|
346
|
+
y2: yPdf + h,
|
|
347
|
+
color: c,
|
|
348
|
+
lineWidth: borders.right.width
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
// Cell content — paragraphs and nested tables. Cell-internal
|
|
353
|
+
// coordinates need to be offset by the cell's origin within the
|
|
354
|
+
// table's origin. We rebuild a virtual paragraph/table with rects
|
|
355
|
+
// translated into the page coordinate space and reuse the top-level
|
|
356
|
+
// renderer so stroke/decoration logic stays in one place.
|
|
357
|
+
for (const inner of cell.content) {
|
|
358
|
+
if (inner.type === "paragraph") {
|
|
359
|
+
renderParagraph(pdfPage, {
|
|
360
|
+
...inner,
|
|
361
|
+
rect: {
|
|
362
|
+
...inner.rect,
|
|
363
|
+
x: table.rect.x + cell.rect.x + inner.rect.x,
|
|
364
|
+
y: table.rect.y + cell.rect.y + inner.rect.y
|
|
365
|
+
}
|
|
366
|
+
}, geometry, opts);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
renderTable(pdfPage, {
|
|
370
|
+
...inner,
|
|
371
|
+
rect: {
|
|
372
|
+
...inner.rect,
|
|
373
|
+
x: table.rect.x + cell.rect.x + inner.rect.x,
|
|
374
|
+
y: table.rect.y + cell.rect.y + inner.rect.y
|
|
375
|
+
}
|
|
376
|
+
}, geometry, opts);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function renderImage(pdfPage, img, geometry) {
|
|
382
|
+
if (img.data.length === 0) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const format = inferImageFormat(img.mimeType);
|
|
386
|
+
if (!format) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const xPdf = toPdfX(geometry, img.rect.x);
|
|
390
|
+
const yPdf = toPdfY(geometry, img.rect.y + img.rect.height);
|
|
391
|
+
pdfPage.drawImage({
|
|
392
|
+
data: img.data,
|
|
393
|
+
format,
|
|
394
|
+
x: xPdf,
|
|
395
|
+
y: yPdf,
|
|
396
|
+
width: img.rect.width,
|
|
397
|
+
height: img.rect.height
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Map a MIME string to the format tag accepted by
|
|
402
|
+
* `pdfPage.drawImage`. Layout always normalises image media-type to
|
|
403
|
+
* standard MIME (`image/png` / `image/jpeg` / …) before reaching the
|
|
404
|
+
* renderer, so we only handle that form. Returns `null` for formats
|
|
405
|
+
* the PDF builder cannot embed; callers skip those silently rather
|
|
406
|
+
* than emit a corrupt XObject.
|
|
407
|
+
*/
|
|
408
|
+
function inferImageFormat(mimeType) {
|
|
409
|
+
const lower = mimeType.toLowerCase();
|
|
410
|
+
if (lower === "image/jpeg") {
|
|
411
|
+
return "jpeg";
|
|
412
|
+
}
|
|
413
|
+
if (lower === "image/png") {
|
|
414
|
+
return "png";
|
|
415
|
+
}
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
function renderFloat(pdfPage, float, geometry, opts) {
|
|
419
|
+
if (float.content.type === "image") {
|
|
420
|
+
renderImage(pdfPage, float.content, geometry);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
renderParagraph(pdfPage, float.content, geometry, opts);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function renderTextBox(pdfPage, tb, geometry, opts) {
|
|
427
|
+
// Outline / fill of the box itself
|
|
428
|
+
const xPdf = toPdfX(geometry, tb.rect.x);
|
|
429
|
+
const yPdf = toPdfY(geometry, tb.rect.y + tb.rect.height);
|
|
430
|
+
const fill = tb.background ? hexToColor(tb.background) : undefined;
|
|
431
|
+
const stroke = tb.border ? hexToColor(tb.border.color) : undefined;
|
|
432
|
+
if (fill || stroke) {
|
|
433
|
+
pdfPage.drawRect({
|
|
434
|
+
x: xPdf,
|
|
435
|
+
y: yPdf,
|
|
436
|
+
width: tb.rect.width,
|
|
437
|
+
height: tb.rect.height,
|
|
438
|
+
fill,
|
|
439
|
+
stroke,
|
|
440
|
+
lineWidth: tb.border?.width ?? 0.75
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
// Inner content positions are already in page coordinates because the
|
|
444
|
+
// layout engine flowed them with the box's own width and stored
|
|
445
|
+
// absolute offsets. We just dispatch through the same content
|
|
446
|
+
// renderer.
|
|
447
|
+
const innerGeometry = {
|
|
448
|
+
...geometry,
|
|
449
|
+
marginLeft: geometry.marginLeft + tb.rect.x,
|
|
450
|
+
marginTop: geometry.marginTop + tb.rect.y
|
|
451
|
+
};
|
|
452
|
+
for (const inner of tb.content) {
|
|
453
|
+
renderPageContent(pdfPage, inner, innerGeometry, opts);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
function renderShape(pdfPage, shape, geometry, opts) {
|
|
457
|
+
const xPdf = toPdfX(geometry, shape.rect.x);
|
|
458
|
+
const yPdf = toPdfY(geometry, shape.rect.y + shape.rect.height);
|
|
459
|
+
const fill = shape.fillColor ? hexToColor(shape.fillColor) : undefined;
|
|
460
|
+
const stroke = shape.strokeColor ? hexToColor(shape.strokeColor) : undefined;
|
|
461
|
+
const lineWidth = shape.strokeWidth ?? 0.75;
|
|
462
|
+
if (shape.preset === "ellipse" || shape.preset === "oval") {
|
|
463
|
+
pdfPage.drawEllipse({
|
|
464
|
+
cx: xPdf + shape.rect.width / 2,
|
|
465
|
+
cy: yPdf + shape.rect.height / 2,
|
|
466
|
+
rx: shape.rect.width / 2,
|
|
467
|
+
ry: shape.rect.height / 2,
|
|
468
|
+
fill,
|
|
469
|
+
stroke,
|
|
470
|
+
lineWidth
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
else if (shape.preset === "line") {
|
|
474
|
+
pdfPage.drawLine({
|
|
475
|
+
x1: xPdf,
|
|
476
|
+
y1: yPdf + shape.rect.height,
|
|
477
|
+
x2: xPdf + shape.rect.width,
|
|
478
|
+
y2: yPdf,
|
|
479
|
+
color: stroke ?? BLACK,
|
|
480
|
+
lineWidth
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
pdfPage.drawRect({
|
|
485
|
+
x: xPdf,
|
|
486
|
+
y: yPdf,
|
|
487
|
+
width: shape.rect.width,
|
|
488
|
+
height: shape.rect.height,
|
|
489
|
+
fill,
|
|
490
|
+
stroke,
|
|
491
|
+
lineWidth
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
if (shape.textContent && shape.textContent.length > 0) {
|
|
495
|
+
const innerGeometry = {
|
|
496
|
+
...geometry,
|
|
497
|
+
marginLeft: geometry.marginLeft + shape.rect.x,
|
|
498
|
+
marginTop: geometry.marginTop + shape.rect.y
|
|
499
|
+
};
|
|
500
|
+
for (const inner of shape.textContent) {
|
|
501
|
+
renderPageContent(pdfPage, inner, innerGeometry, opts);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function renderChart(pdfPage, chart, geometry, opts) {
|
|
506
|
+
const xPdf = toPdfX(geometry, chart.rect.x);
|
|
507
|
+
const yPdf = toPdfY(geometry, chart.rect.y + chart.rect.height);
|
|
508
|
+
const rect = { x: xPdf, y: yPdf, width: chart.rect.width, height: chart.rect.height };
|
|
509
|
+
if (opts.chartRenderer) {
|
|
510
|
+
// `false` means the renderer declined; only `void`/`true` short-
|
|
511
|
+
// circuits the fallback path so consumers can plug in a renderer
|
|
512
|
+
// that only handles a subset of chart families without wiping out
|
|
513
|
+
// the placeholder for the rest.
|
|
514
|
+
const result = opts.chartRenderer(chart, pdfPage, rect);
|
|
515
|
+
if (result !== false) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (chart.svg) {
|
|
520
|
+
try {
|
|
521
|
+
pdfPage.drawSvg({
|
|
522
|
+
svg: chart.svg,
|
|
523
|
+
x: rect.x,
|
|
524
|
+
y: rect.y,
|
|
525
|
+
width: rect.width,
|
|
526
|
+
height: rect.height
|
|
527
|
+
});
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
catch {
|
|
531
|
+
// Fall through to placeholder if SVG can't be embedded.
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
// Placeholder rectangle + title
|
|
535
|
+
pdfPage.drawRect({
|
|
536
|
+
...rect,
|
|
537
|
+
stroke: { r: 0.5, g: 0.5, b: 0.5 },
|
|
538
|
+
lineWidth: 0.75
|
|
539
|
+
});
|
|
540
|
+
if (chart.title) {
|
|
541
|
+
pdfPage.drawText(chart.title, {
|
|
542
|
+
x: rect.x + rect.width / 2,
|
|
543
|
+
y: rect.y + rect.height / 2,
|
|
544
|
+
fontSize: 10,
|
|
545
|
+
anchor: "middle",
|
|
546
|
+
color: { r: 0.3, g: 0.3, b: 0.3 }
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function renderSdt(pdfPage, sdt, geometry, opts) {
|
|
551
|
+
// SDT is transparent: dispatch each child relative to the SDT origin.
|
|
552
|
+
const innerGeometry = {
|
|
553
|
+
...geometry,
|
|
554
|
+
marginLeft: geometry.marginLeft + sdt.rect.x,
|
|
555
|
+
marginTop: geometry.marginTop + sdt.rect.y
|
|
556
|
+
};
|
|
557
|
+
for (const inner of sdt.content) {
|
|
558
|
+
renderPageContent(pdfPage, inner, innerGeometry, opts);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function renderMath(pdfPage, math, geometry, opts) {
|
|
562
|
+
const xPdf = toPdfX(geometry, math.rect.x);
|
|
563
|
+
const baselinePdfY = toPdfY(geometry, math.rect.y + math.rect.height * 0.8);
|
|
564
|
+
pdfPage.drawText(math.text, {
|
|
565
|
+
x: xPdf,
|
|
566
|
+
y: baselinePdfY,
|
|
567
|
+
fontFamily: opts.defaultFont ?? "Helvetica",
|
|
568
|
+
fontSize: math.rect.height * 0.7,
|
|
569
|
+
italic: true
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
function renderCheckBox(pdfPage, cb, geometry) {
|
|
573
|
+
const xPdf = toPdfX(geometry, cb.rect.x);
|
|
574
|
+
const yPdf = toPdfY(geometry, cb.rect.y + cb.rect.height);
|
|
575
|
+
const size = cb.rect.height * 0.85;
|
|
576
|
+
pdfPage.drawRect({
|
|
577
|
+
x: xPdf,
|
|
578
|
+
y: yPdf,
|
|
579
|
+
width: size,
|
|
580
|
+
height: size,
|
|
581
|
+
stroke: BLACK,
|
|
582
|
+
lineWidth: 0.75
|
|
583
|
+
});
|
|
584
|
+
if (cb.checked) {
|
|
585
|
+
// Draw a check mark using two line segments. Coordinates are in PDF
|
|
586
|
+
// (Y up), so the visible "down-stroke" of the tick goes from a
|
|
587
|
+
// higher y to a lower y on the left side, then back up on the right.
|
|
588
|
+
const x1 = xPdf + size * 0.2;
|
|
589
|
+
const y1 = yPdf + size * 0.5;
|
|
590
|
+
const x2 = xPdf + size * 0.45;
|
|
591
|
+
const y2 = yPdf + size * 0.25;
|
|
592
|
+
const x3 = xPdf + size * 0.85;
|
|
593
|
+
const y3 = yPdf + size * 0.75;
|
|
594
|
+
pdfPage.drawLine({ x1, y1, x2, y2, color: BLACK, lineWidth: 1 });
|
|
595
|
+
pdfPage.drawLine({ x1: x2, y1: y2, x2: x3, y2: y3, color: BLACK, lineWidth: 1 });
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
function renderToc(pdfPage, toc, geometry, opts) {
|
|
599
|
+
// TOC entries already carry absolute (within content area) layout
|
|
600
|
+
// positions, so they render directly.
|
|
601
|
+
const innerGeometry = {
|
|
602
|
+
...geometry,
|
|
603
|
+
marginLeft: geometry.marginLeft + toc.rect.x,
|
|
604
|
+
marginTop: geometry.marginTop + toc.rect.y
|
|
605
|
+
};
|
|
606
|
+
for (const para of toc.entries) {
|
|
607
|
+
renderParagraph(pdfPage, para, innerGeometry, opts);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
function renderAltChunkPlaceholder(pdfPage, ac, geometry) {
|
|
611
|
+
const xPdf = toPdfX(geometry, ac.rect.x);
|
|
612
|
+
const yPdf = toPdfY(geometry, ac.rect.y + ac.rect.height);
|
|
613
|
+
pdfPage.drawRect({
|
|
614
|
+
x: xPdf,
|
|
615
|
+
y: yPdf,
|
|
616
|
+
width: ac.rect.width,
|
|
617
|
+
height: ac.rect.height,
|
|
618
|
+
stroke: { r: 0.6, g: 0.6, b: 0.6 },
|
|
619
|
+
lineWidth: 0.5
|
|
620
|
+
});
|
|
621
|
+
pdfPage.drawText(`[${ac.contentType}]`, {
|
|
622
|
+
x: xPdf + ac.rect.width / 2,
|
|
623
|
+
y: yPdf + ac.rect.height / 2,
|
|
624
|
+
fontSize: 9,
|
|
625
|
+
anchor: "middle",
|
|
626
|
+
color: { r: 0.4, g: 0.4, b: 0.4 }
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
function renderOpaqueDrawingPlaceholder(pdfPage, od, geometry) {
|
|
630
|
+
const xPdf = toPdfX(geometry, od.rect.x);
|
|
631
|
+
const yPdf = toPdfY(geometry, od.rect.y + od.rect.height);
|
|
632
|
+
pdfPage.drawRect({
|
|
633
|
+
x: xPdf,
|
|
634
|
+
y: yPdf,
|
|
635
|
+
width: od.rect.width,
|
|
636
|
+
height: od.rect.height,
|
|
637
|
+
stroke: { r: 0.6, g: 0.6, b: 0.6 },
|
|
638
|
+
lineWidth: 0.5
|
|
639
|
+
});
|
|
640
|
+
pdfPage.drawText("[drawing]", {
|
|
641
|
+
x: xPdf + od.rect.width / 2,
|
|
642
|
+
y: yPdf + od.rect.height / 2,
|
|
643
|
+
fontSize: 9,
|
|
644
|
+
anchor: "middle",
|
|
645
|
+
color: { r: 0.4, g: 0.4, b: 0.4 }
|
|
646
|
+
});
|
|
647
|
+
}
|