reamkit 1.15.1 → 1.15.3
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/esm/core/arc-to-bezier.d.ts +23 -0
- package/dist/esm/core/arc-to-bezier.js +23 -0
- package/dist/esm/core/bidi/algorithm.d.ts +26 -0
- package/dist/esm/core/bidi/algorithm.js +21 -0
- package/dist/esm/core/bidi/char-types.d.ts +17 -0
- package/dist/esm/core/bidi/char-types.js +10 -0
- package/dist/esm/core/bidi/index.d.ts +42 -0
- package/dist/esm/core/bidi/index.js +27 -0
- package/dist/esm/core/bidi/segments.d.ts +22 -0
- package/dist/esm/core/bidi/segments.js +14 -0
- package/dist/esm/core/bytes.d.ts +20 -0
- package/dist/esm/core/bytes.js +24 -1
- package/dist/esm/core/converter/facade.d.ts +38 -1
- package/dist/esm/core/converter/facade.js +25 -0
- package/dist/esm/core/converter/project.d.ts +12 -0
- package/dist/esm/core/converter/project.js +11 -0
- package/dist/esm/core/converter/ream.d.ts +107 -0
- package/dist/esm/core/converter/ream.js +76 -0
- package/dist/esm/core/crypto/asn1.d.ts +77 -0
- package/dist/esm/core/crypto/asn1.js +65 -0
- package/dist/esm/core/crypto/cms.d.ts +25 -0
- package/dist/esm/core/crypto/cms.js +8 -0
- package/dist/esm/core/document-model/index.d.ts +7 -0
- package/dist/esm/core/document-model/types.d.ts +328 -0
- package/dist/esm/core/drawingml/chart-geometry.d.ts +125 -0
- package/dist/esm/core/drawingml/chart-geometry.js +96 -0
- package/dist/esm/core/drawingml/chart-parser.d.ts +34 -0
- package/dist/esm/core/drawingml/chart-parser.js +34 -0
- package/dist/esm/core/drawingml/chart-serializer.d.ts +12 -0
- package/dist/esm/core/drawingml/chart-serializer.js +12 -0
- package/dist/esm/core/drawingml/colors.d.ts +53 -0
- package/dist/esm/core/drawingml/colors.js +41 -0
- package/dist/esm/core/drawingml/preset-geometry.d.ts +30 -0
- package/dist/esm/core/drawingml/preset-geometry.js +30 -0
- package/dist/esm/core/drawingml/shape-render.d.ts +54 -0
- package/dist/esm/core/drawingml/shape-render.js +54 -0
- package/dist/esm/core/drawingml/sparkline-geometry.d.ts +15 -0
- package/dist/esm/core/drawingml/sparkline-geometry.js +13 -0
- package/dist/esm/core/drawingml/theme-parser.d.ts +11 -0
- package/dist/esm/core/drawingml/theme-parser.js +11 -0
- package/dist/esm/core/font/arabic-joining.d.ts +21 -0
- package/dist/esm/core/font/arabic-joining.js +16 -0
- package/dist/esm/core/font/binary-reader.d.ts +17 -0
- package/dist/esm/core/font/binary-reader.js +17 -0
- package/dist/esm/core/font/font-registry.d.ts +37 -0
- package/dist/esm/core/font/font-registry.js +31 -0
- package/dist/esm/core/font/measure.d.ts +20 -0
- package/dist/esm/core/font/measure.js +11 -0
- package/dist/esm/core/font/opentype-layout.d.ts +49 -0
- package/dist/esm/core/font/opentype-layout.js +37 -0
- package/dist/esm/core/font/ttf-parser.d.ts +32 -0
- package/dist/esm/core/font/ttf-parser.js +7 -0
- package/dist/esm/core/font/ttf-subset.d.ts +21 -0
- package/dist/esm/core/font/ttf-subset.js +21 -0
- package/dist/esm/core/fonts/provider.d.ts +8 -1
- package/dist/esm/core/fonts/provider.js +1 -0
- package/dist/esm/core/fonts/remote-fonts.d.ts +22 -0
- package/dist/esm/core/fonts/remote-fonts.js +16 -0
- package/dist/esm/core/hyphenation/index.d.ts +25 -0
- package/dist/esm/core/hyphenation/index.js +17 -0
- package/dist/esm/core/hyphenation/liang.d.ts +27 -0
- package/dist/esm/core/hyphenation/liang.js +14 -0
- package/dist/esm/core/images.d.ts +32 -0
- package/dist/esm/core/images.js +12 -0
- package/dist/esm/core/ir/adapters.d.ts +23 -0
- package/dist/esm/core/ir/features.d.ts +8 -0
- package/dist/esm/core/ir/features.js +1 -0
- package/dist/esm/core/ir/flow.d.ts +20 -0
- package/dist/esm/core/ir/index.d.ts +7 -0
- package/dist/esm/core/ir/loss.d.ts +12 -0
- package/dist/esm/core/ir/loss.js +8 -0
- package/dist/esm/core/ir/resources.d.ts +12 -0
- package/dist/esm/core/ir/resources.js +11 -0
- package/dist/esm/core/ir/sheet.d.ts +81 -0
- package/dist/esm/core/ir/units.d.ts +9 -0
- package/dist/esm/core/ir/units.js +2 -0
- package/dist/esm/core/line-breaker/cjk.d.ts +26 -0
- package/dist/esm/core/line-breaker/cjk.js +60 -0
- package/dist/esm/core/line-breaker/greedy.d.ts +14 -0
- package/dist/esm/core/line-breaker/greedy.js +14 -0
- package/dist/esm/core/line-breaker/index.d.ts +1 -0
- package/dist/esm/core/line-breaker/index.js +3 -0
- package/dist/esm/core/line-breaker/knuth-plass.d.ts +29 -5
- package/dist/esm/core/line-breaker/knuth-plass.js +10 -5
- package/dist/esm/core/numbering/apply.d.ts +19 -0
- package/dist/esm/core/numbering/apply.js +19 -0
- package/dist/esm/core/numbering/state.d.ts +15 -0
- package/dist/esm/core/numbering/state.js +15 -0
- package/dist/esm/core/ole/cfb.d.ts +19 -0
- package/dist/esm/core/ole/cfb.js +16 -0
- package/dist/esm/core/opc/core-properties.d.ts +12 -0
- package/dist/esm/core/opc/core-properties.js +5 -0
- package/dist/esm/core/opc/opc-writer.d.ts +24 -4
- package/dist/esm/core/opc/opc-writer.js +12 -0
- package/dist/esm/core/opc/package.d.ts +55 -0
- package/dist/esm/core/opc/package.js +49 -1
- package/dist/esm/core/opc/relationship-types.d.ts +8 -0
- package/dist/esm/core/opc/relationship-types.js +5 -0
- package/dist/esm/core/opc/relationships.d.ts +12 -0
- package/dist/esm/core/opc/relationships.js +7 -0
- package/dist/esm/core/po-helpers.d.ts +38 -0
- package/dist/esm/core/po-helpers.js +33 -0
- package/dist/esm/core/spreadsheet-model/types.d.ts +302 -0
- package/dist/esm/core/style-cascade/resolver.d.ts +31 -0
- package/dist/esm/core/style-cascade/resolver.js +31 -0
- package/dist/esm/core/style-cascade/table.d.ts +7 -0
- package/dist/esm/core/style-cascade/table.js +7 -0
- package/dist/esm/core/style-cascade/types.d.ts +27 -0
- package/dist/esm/core/style-cascade/types.js +2 -0
- package/dist/esm/core/vector.d.ts +67 -0
- package/dist/esm/core/vector.js +23 -0
- package/dist/esm/excel/activex-parser.d.ts +31 -0
- package/dist/esm/excel/activex-parser.js +24 -0
- package/dist/esm/excel/cell-reference.d.ts +14 -0
- package/dist/esm/excel/cell-reference.js +9 -0
- package/dist/esm/excel/column-bands.d.ts +29 -0
- package/dist/esm/excel/column-bands.js +27 -7
- package/dist/esm/excel/comments-parser.d.ts +19 -0
- package/dist/esm/excel/comments-parser.js +19 -0
- package/dist/esm/excel/conditional-format.d.ts +38 -0
- package/dist/esm/excel/conditional-format.js +25 -0
- package/dist/esm/excel/defined-name-ref.d.ts +21 -0
- package/dist/esm/excel/defined-name-ref.js +20 -0
- package/dist/esm/excel/form-control-parser.d.ts +13 -0
- package/dist/esm/excel/form-control-parser.js +5 -0
- package/dist/esm/excel/formula/context.d.ts +37 -0
- package/dist/esm/excel/formula/dates.d.ts +23 -0
- package/dist/esm/excel/formula/dates.js +20 -0
- package/dist/esm/excel/formula/eval.d.ts +21 -0
- package/dist/esm/excel/formula/eval.js +11 -0
- package/dist/esm/excel/formula/functions.d.ts +12 -0
- package/dist/esm/excel/formula/functions.js +12 -0
- package/dist/esm/excel/formula/index.d.ts +21 -0
- package/dist/esm/excel/formula/index.js +16 -0
- package/dist/esm/excel/formula/lexer.d.ts +12 -0
- package/dist/esm/excel/formula/lexer.js +10 -0
- package/dist/esm/excel/formula/parser.d.ts +20 -0
- package/dist/esm/excel/formula/parser.js +53 -0
- package/dist/esm/excel/formula/value.d.ts +53 -0
- package/dist/esm/excel/formula/value.js +30 -0
- package/dist/esm/excel/header-footer.d.ts +9 -0
- package/dist/esm/excel/header-footer.js +9 -0
- package/dist/esm/excel/number-format.d.ts +34 -0
- package/dist/esm/excel/number-format.js +34 -0
- package/dist/esm/excel/pivot-table-parser.d.ts +8 -0
- package/dist/esm/excel/pivot-table-parser.js +8 -0
- package/dist/esm/excel/print-model.d.ts +77 -1
- package/dist/esm/excel/print-model.js +230 -26
- package/dist/esm/excel/shared-strings-parser.d.ts +13 -0
- package/dist/esm/excel/shared-strings-parser.js +5 -0
- package/dist/esm/excel/sheet-drawing.d.ts +34 -0
- package/dist/esm/excel/sheet-drawing.js +21 -0
- package/dist/esm/excel/sheet-shape-parser.d.ts +12 -0
- package/dist/esm/excel/sheet-shape-parser.js +12 -0
- package/dist/esm/excel/sheet-to-flow.d.ts +29 -0
- package/dist/esm/excel/sheet-to-flow.js +24 -7
- package/dist/esm/excel/slicer-parser.d.ts +23 -0
- package/dist/esm/excel/slicer-parser.js +10 -0
- package/dist/esm/excel/styles-parser.d.ts +8 -0
- package/dist/esm/excel/styles-parser.js +8 -0
- package/dist/esm/excel/table-parser.d.ts +24 -0
- package/dist/esm/excel/table-parser.js +5 -0
- package/dist/esm/excel/workbook-parser.d.ts +17 -0
- package/dist/esm/excel/workbook-parser.js +5 -0
- package/dist/esm/excel/worksheet-parser.d.ts +9 -0
- package/dist/esm/excel/worksheet-parser.js +39 -6
- package/dist/esm/excel/xls/biff-chart.d.ts +10 -0
- package/dist/esm/excel/xls/biff-chart.js +10 -0
- package/dist/esm/excel/xls/biff-reader.d.ts +27 -0
- package/dist/esm/excel/xls/biff-reader.js +44 -0
- package/dist/esm/excel/xls/biff-styles.d.ts +20 -0
- package/dist/esm/excel/xls/biff-styles.js +20 -0
- package/dist/esm/excel/xls/escher.d.ts +27 -0
- package/dist/esm/excel/xls/escher.js +18 -0
- package/dist/esm/excel/xls/xls-reader.d.ts +6 -0
- package/dist/esm/excel/xls/xls-reader.js +6 -0
- package/dist/esm/excel/xlsx-reader.d.ts +30 -0
- package/dist/esm/excel/xlsx-reader.js +38 -4
- package/dist/esm/excel/xlsx-to-pdf.d.ts +27 -0
- package/dist/esm/excel/xlsx-writer.d.ts +14 -0
- package/dist/esm/excel/xlsx-writer.js +13 -0
- package/dist/esm/html/html-writer.d.ts +18 -0
- package/dist/esm/html/html-writer.js +18 -0
- package/dist/esm/index.d.ts +23 -0
- package/dist/esm/layout/math-layout.d.ts +39 -0
- package/dist/esm/layout/math-layout.js +18 -0
- package/dist/esm/layout/page-doc.d.ts +91 -0
- package/dist/esm/layout/styled-layout.d.ts +175 -0
- package/dist/esm/layout/styled-layout.js +136 -4
- package/dist/esm/pdf/builtin-fonts.d.ts +5 -0
- package/dist/esm/pdf/cid-font.d.ts +22 -0
- package/dist/esm/pdf/cid-font.js +10 -0
- package/dist/esm/pdf/embedded-file.d.ts +16 -0
- package/dist/esm/pdf/embedded-file.js +9 -0
- package/dist/esm/pdf/encryption.d.ts +59 -0
- package/dist/esm/pdf/encryption.js +37 -0
- package/dist/esm/pdf/icc-profile.d.ts +8 -0
- package/dist/esm/pdf/icc-profile.js +8 -0
- package/dist/esm/pdf/image-xobject.d.ts +19 -0
- package/dist/esm/pdf/image-xobject.js +9 -0
- package/dist/esm/pdf/objects.d.ts +40 -0
- package/dist/esm/pdf/objects.js +36 -0
- package/dist/esm/pdf/serialize.d.ts +18 -0
- package/dist/esm/pdf/serialize.js +18 -0
- package/dist/esm/pdf/shading.d.ts +16 -0
- package/dist/esm/pdf/shading.js +16 -0
- package/dist/esm/pdf/signature.d.ts +36 -0
- package/dist/esm/pdf/signature.js +22 -0
- package/dist/esm/pdf/struct-tree.d.ts +64 -0
- package/dist/esm/pdf/struct-tree.js +60 -0
- package/dist/esm/pdf/styled-page-emitter.d.ts +33 -0
- package/dist/esm/pdf/styled-page-emitter.js +21 -0
- package/dist/esm/pdf/styled-page-renderer.d.ts +18 -0
- package/dist/esm/pdf/styled-page-renderer.js +18 -0
- package/dist/esm/pdf/text-encoding.d.ts +16 -0
- package/dist/esm/pdf/text-page-renderer.d.ts +11 -0
- package/dist/esm/pdf/vector-graphics.d.ts +12 -0
- package/dist/esm/pdf/vector-graphics.js +12 -0
- package/dist/esm/pdf/writer.d.ts +39 -0
- package/dist/esm/pdf/writer.js +27 -0
- package/dist/esm/pdf/xmp.d.ts +16 -0
- package/dist/esm/pdf/xmp.js +9 -0
- package/dist/esm/pdf-reader/ccitt.d.ts +25 -0
- package/dist/esm/pdf-reader/ccitt.js +15 -0
- package/dist/esm/pdf-reader/cmap.d.ts +12 -0
- package/dist/esm/pdf-reader/cmap.js +9 -0
- package/dist/esm/pdf-reader/content.d.ts +69 -0
- package/dist/esm/pdf-reader/content.js +16 -0
- package/dist/esm/pdf-reader/crypto.d.ts +5 -0
- package/dist/esm/pdf-reader/crypto.js +5 -0
- package/dist/esm/pdf-reader/decrypt.d.ts +17 -0
- package/dist/esm/pdf-reader/decrypt.js +12 -0
- package/dist/esm/pdf-reader/document.d.ts +53 -0
- package/dist/esm/pdf-reader/document.js +50 -0
- package/dist/esm/pdf-reader/flow-build.d.ts +47 -0
- package/dist/esm/pdf-reader/flow-build.js +42 -0
- package/dist/esm/pdf-reader/font.d.ts +12 -0
- package/dist/esm/pdf-reader/font.js +12 -0
- package/dist/esm/pdf-reader/image-decode.d.ts +21 -0
- package/dist/esm/pdf-reader/image-decode.js +14 -0
- package/dist/esm/pdf-reader/images.d.ts +19 -0
- package/dist/esm/pdf-reader/images.js +9 -0
- package/dist/esm/pdf-reader/layout.d.ts +15 -0
- package/dist/esm/pdf-reader/layout.js +15 -0
- package/dist/esm/pdf-reader/lexer.d.ts +43 -0
- package/dist/esm/pdf-reader/lexer.js +38 -0
- package/dist/esm/pdf-reader/parser.d.ts +15 -0
- package/dist/esm/pdf-reader/parser.js +8 -0
- package/dist/esm/pdf-reader/png-encode.d.ts +9 -0
- package/dist/esm/pdf-reader/png-encode.js +8 -0
- package/dist/esm/pdf-reader/predictor.d.ts +9 -0
- package/dist/esm/pdf-reader/predictor.js +8 -0
- package/dist/esm/pdf-reader/reader.d.ts +16 -0
- package/dist/esm/pdf-reader/reader.js +16 -0
- package/dist/esm/pdf-reader/shading.d.ts +10 -0
- package/dist/esm/pdf-reader/shading.js +10 -0
- package/dist/esm/pdf-reader/struct-tree.d.ts +24 -0
- package/dist/esm/pdf-reader/struct-tree.js +12 -0
- package/dist/esm/pdf-reader/tagged.d.ts +13 -0
- package/dist/esm/pdf-reader/tagged.js +13 -0
- package/dist/esm/pdf-reader/text.d.ts +11 -0
- package/dist/esm/pdf-reader/text.js +11 -0
- package/dist/esm/pdf-reader/vector.d.ts +19 -0
- package/dist/esm/pdf-reader/vector.js +9 -0
- package/dist/esm/pptx/placeholder-cascade.d.ts +21 -0
- package/dist/esm/pptx/placeholder-cascade.js +10 -0
- package/dist/esm/pptx/ppt/ppt-reader.d.ts +16 -0
- package/dist/esm/pptx/ppt/ppt-reader.js +16 -0
- package/dist/esm/pptx/ppt/ppt-text.d.ts +55 -0
- package/dist/esm/pptx/ppt/ppt-text.js +14 -0
- package/dist/esm/pptx/pptx-reader.d.ts +21 -0
- package/dist/esm/pptx/pptx-reader.js +23 -2
- package/dist/esm/pptx/slide-parser.d.ts +102 -0
- package/dist/esm/pptx/slide-parser.js +78 -0
- package/dist/esm/pptx/sp-helpers.d.ts +28 -0
- package/dist/esm/pptx/sp-helpers.js +22 -0
- package/dist/esm/svg/svg-writer.d.ts +17 -0
- package/dist/esm/svg/svg-writer.js +16 -0
- package/dist/esm/word/doc/doc-reader.d.ts +16 -0
- package/dist/esm/word/doc/doc-reader.js +16 -0
- package/dist/esm/word/doc/doc-text.d.ts +77 -0
- package/dist/esm/word/doc/doc-text.js +13 -0
- package/dist/esm/word/document-parser.d.ts +134 -0
- package/dist/esm/word/document-parser.js +86 -0
- package/dist/esm/word/docx-reader.d.ts +16 -0
- package/dist/esm/word/docx-reader.js +18 -2
- package/dist/esm/word/docx-to-pdf.d.ts +52 -0
- package/dist/esm/word/docx-to-pdf.js +21 -0
- package/dist/esm/word/docx-writer.d.ts +17 -0
- package/dist/esm/word/docx-writer.js +17 -0
- package/dist/esm/word/drawing-parser.d.ts +88 -0
- package/dist/esm/word/drawing-parser.js +68 -0
- package/dist/esm/word/font-table.d.ts +24 -0
- package/dist/esm/word/font-table.js +24 -0
- package/dist/esm/word/numbering-parser.d.ts +11 -0
- package/dist/esm/word/numbering-parser.js +11 -0
- package/dist/esm/word/omml-parser.d.ts +15 -0
- package/dist/esm/word/omml-parser.js +15 -0
- package/dist/esm/word/omml-serializer.d.ts +9 -0
- package/dist/esm/word/omml-serializer.js +9 -0
- package/dist/esm/word/paragraph-properties.d.ts +10 -0
- package/dist/esm/word/paragraph-properties.js +10 -0
- package/dist/esm/word/po-to-flat.d.ts +11 -0
- package/dist/esm/word/po-to-flat.js +11 -0
- package/dist/esm/word/run-properties.d.ts +10 -0
- package/dist/esm/word/run-properties.js +10 -0
- package/dist/esm/word/settings-parser.d.ts +13 -0
- package/dist/esm/word/settings-parser.js +8 -0
- package/dist/esm/word/styles-parser.d.ts +10 -0
- package/dist/esm/word/styles-parser.js +10 -0
- package/dist/esm/word/table-parser.d.ts +11 -0
- package/dist/esm/word/table-parser.js +11 -0
- package/dist/esm/word/text-extractor.d.ts +9 -0
- package/dist/esm/word/xml-helpers.d.ts +44 -0
- package/dist/esm/word/xml-helpers.js +38 -0
- package/package.json +5 -2
|
@@ -3,6 +3,17 @@ import { IDENTITY, interpretContent, multiply } from "./content.js";
|
|
|
3
3
|
import { buildContentFont } from "./font.js";
|
|
4
4
|
//#region src/pdf-reader/text.ts
|
|
5
5
|
var MAX_FORM_DEPTH = 8;
|
|
6
|
+
/**
|
|
7
|
+
* Extract a page's text as positioned {@link TextRun}s (E-PDF EP2/EP8/EP13).
|
|
8
|
+
* Interprets the page content stream and, recursively, the Form XObjects it
|
|
9
|
+
* paints (EP13 — their text would otherwise be missed), then tags any run whose
|
|
10
|
+
* origin falls inside a `/Link` annotation's `/Rect` with that link's URI (EP8)
|
|
11
|
+
* so hyperlinks survive.
|
|
12
|
+
*
|
|
13
|
+
* @param file The owning {@link PdfFile}.
|
|
14
|
+
* @param page The page to extract.
|
|
15
|
+
* @returns The page's runs, each carrying an `href` when it sits under a link.
|
|
16
|
+
*/
|
|
6
17
|
function extractPageText(file, page) {
|
|
7
18
|
const runs = [];
|
|
8
19
|
collectRuns(file, page.resources, file.pageContent(page), IDENTITY, 0, /* @__PURE__ */ new Set(), runs);
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { PathSeg } from './content.js';
|
|
2
2
|
import { ShapeGradient } from '../core/vector.js';
|
|
3
3
|
import { PdfFile, PdfPage } from './document.js';
|
|
4
|
+
/**
|
|
5
|
+
* One painted vector path lifted off a page (E-PDF EP10/EP11/EP16c): the path
|
|
6
|
+
* segments, whichever of solid fill / gradient fill / stroke survived the
|
|
7
|
+
* de-cluttering filter, and the path's page-space bounding box plus enclosing
|
|
8
|
+
* marked-content id.
|
|
9
|
+
*/
|
|
4
10
|
export interface PdfVector {
|
|
5
11
|
readonly segs: ReadonlyArray<PathSeg>;
|
|
12
|
+
/** Present iff a qualifying solid fill survived (EP10). */
|
|
6
13
|
readonly fillHex?: string;
|
|
14
|
+
/** Present iff a shading-pattern fill survived (EP16c). */
|
|
7
15
|
readonly gradient?: ShapeGradient;
|
|
16
|
+
/** Present iff a qualifying stroke survived (EP11). */
|
|
8
17
|
readonly strokeHex?: string;
|
|
18
|
+
/** Stroke width in page-space points (EP11). */
|
|
9
19
|
readonly lineWidth?: number;
|
|
10
20
|
readonly minX: number;
|
|
11
21
|
readonly minY: number;
|
|
@@ -13,4 +23,13 @@ export interface PdfVector {
|
|
|
13
23
|
readonly maxY: number;
|
|
14
24
|
readonly mcid?: number;
|
|
15
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Lift the painted vector paths off a page (E-PDF EP10/EP11/EP16c). Runs the
|
|
28
|
+
* content interpreter for its fill (EP10), stroke (EP11) and shading-pattern
|
|
29
|
+
* (EP16c) placements and keeps only the ones that read as real graphics:
|
|
30
|
+
* hairline/degenerate fills, invisible white paint, short stroke specks and the
|
|
31
|
+
* near-full-page background are all dropped, so a reconstructed document gains
|
|
32
|
+
* genuine coloured shapes, lines and gradients without the dot / page-background
|
|
33
|
+
* clutter. Clips and the bare `sh` operator are not captured (a documented loss).
|
|
34
|
+
*/
|
|
16
35
|
export declare function collectPageVectors(file: PdfFile, page: PdfPage): Array<PdfVector>;
|
|
@@ -6,6 +6,15 @@ var MIN_SIDE = 2;
|
|
|
6
6
|
var MIN_AREA = 16;
|
|
7
7
|
var MIN_STROKE_LEN = 6;
|
|
8
8
|
var MAX_VECTORS = 2e3;
|
|
9
|
+
/**
|
|
10
|
+
* Lift the painted vector paths off a page (E-PDF EP10/EP11/EP16c). Runs the
|
|
11
|
+
* content interpreter for its fill (EP10), stroke (EP11) and shading-pattern
|
|
12
|
+
* (EP16c) placements and keeps only the ones that read as real graphics:
|
|
13
|
+
* hairline/degenerate fills, invisible white paint, short stroke specks and the
|
|
14
|
+
* near-full-page background are all dropped, so a reconstructed document gains
|
|
15
|
+
* genuine coloured shapes, lines and gradients without the dot / page-background
|
|
16
|
+
* clutter. Clips and the bare `sh` operator are not captured (a documented loss).
|
|
17
|
+
*/
|
|
9
18
|
function collectPageVectors(file, page) {
|
|
10
19
|
const [px0, py0, px1, py1] = page.mediaBox;
|
|
11
20
|
const pageArea = Math.max(1, Math.abs((px1 - px0) * (py1 - py0)));
|
|
@@ -2,8 +2,29 @@ import { RunProperties } from '../core/document-model/index.js';
|
|
|
2
2
|
import { ColorResolver } from '../core/drawingml/colors.js';
|
|
3
3
|
import { PoNode } from '../core/po-helpers.js';
|
|
4
4
|
import { PlaceholderRef, ShapeBoxEmu } from './sp-helpers.js';
|
|
5
|
+
/**
|
|
6
|
+
* The placeholder cascade (PX2): the resolver a slide parser consults whenever a
|
|
7
|
+
* slide placeholder shape (`p:sp` with a `p:ph`) lacks its own geometry or run
|
|
8
|
+
* formatting, supplying the inherited values from the slide's layout, then its
|
|
9
|
+
* master.
|
|
10
|
+
*/
|
|
5
11
|
export interface PlaceholderCascade {
|
|
12
|
+
/** The inherited EMU box for a slide placeholder without its own `a:xfrm`. */
|
|
6
13
|
readonly geometryFor: (ph: PlaceholderRef) => ShapeBoxEmu | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The master's default run formatting for a placeholder's paragraph at the
|
|
16
|
+
* given 0-based outline level (empty when no master text styles apply).
|
|
17
|
+
*/
|
|
7
18
|
readonly defaultsFor: (ph: PlaceholderRef, level: number) => RunProperties;
|
|
8
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Build a {@link PlaceholderCascade} from a slide's already-parsed layout and
|
|
22
|
+
* master trees: it resolves a placeholder's inherited geometry (the layout's
|
|
23
|
+
* matching `a:xfrm`, else the master's) and per-level default run formatting (the
|
|
24
|
+
* master's `p:txStyles`).
|
|
25
|
+
*
|
|
26
|
+
* @param layoutTree The parsed `p:sldLayout` part.
|
|
27
|
+
* @param masterTree The parsed `p:sldMaster` part, when present.
|
|
28
|
+
* @param colors The deck's colour resolver, for scheme colours in the text styles.
|
|
29
|
+
*/
|
|
9
30
|
export declare function buildPlaceholderCascade(layoutTree: ReadonlyArray<PoNode>, masterTree: ReadonlyArray<PoNode> | undefined, colors: ColorResolver): PlaceholderCascade;
|
|
@@ -6,6 +6,16 @@ function categoryOf(type) {
|
|
|
6
6
|
if (type === void 0 || type === "body" || type === "subTitle" || type === "obj") return "body";
|
|
7
7
|
return "other";
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Build a {@link PlaceholderCascade} from a slide's already-parsed layout and
|
|
11
|
+
* master trees: it resolves a placeholder's inherited geometry (the layout's
|
|
12
|
+
* matching `a:xfrm`, else the master's) and per-level default run formatting (the
|
|
13
|
+
* master's `p:txStyles`).
|
|
14
|
+
*
|
|
15
|
+
* @param layoutTree The parsed `p:sldLayout` part.
|
|
16
|
+
* @param masterTree The parsed `p:sldMaster` part, when present.
|
|
17
|
+
* @param colors The deck's colour resolver, for scheme colours in the text styles.
|
|
18
|
+
*/
|
|
9
19
|
function buildPlaceholderCascade(layoutTree, masterTree, colors) {
|
|
10
20
|
const layoutPhs = collectPlaceholders(layoutTree, "p:sldLayout");
|
|
11
21
|
const masterPhs = masterTree ? collectPlaceholders(masterTree, "p:sldMaster") : [];
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { DocumentReader, ReadResult } from '../../core/ir/adapters.js';
|
|
2
2
|
import { FlowDoc } from '../../core/ir/flow.js';
|
|
3
|
+
/**
|
|
4
|
+
* Read a legacy `.ppt` (PowerPoint 97–2003 OLE2/CFB) into the same
|
|
5
|
+
* {@link FlowDoc} the OOXML pptx reader produces: one page per slide at the deck
|
|
6
|
+
* size, with each slide's text (run + paragraph formatting), embedded images,
|
|
7
|
+
* per-shape placement and decorative autoshapes. Always reports a single
|
|
8
|
+
* {@link Loss} — degraded (the format is read best-effort; re-save as `.pptx` for
|
|
9
|
+
* full fidelity), or dropped when the file is encrypted/obfuscated.
|
|
10
|
+
*
|
|
11
|
+
* @param bytes The raw `.ppt` (CFB) bytes.
|
|
12
|
+
* @returns The {@link FlowDoc} plus the one-element loss report.
|
|
13
|
+
*/
|
|
3
14
|
export declare function readPpt(bytes: Uint8Array): ReadResult<FlowDoc>;
|
|
15
|
+
/**
|
|
16
|
+
* The {@link DocumentReader} for legacy `.ppt`: sniffs an OLE2/CFB container with
|
|
17
|
+
* a `PowerPoint Document` stream (which also keeps an `.xls`/`.doc` or an
|
|
18
|
+
* encrypted OOXML from mis-routing here) and reads it via {@link readPpt}.
|
|
19
|
+
*/
|
|
4
20
|
export declare const pptReader: DocumentReader<FlowDoc>;
|
|
@@ -29,6 +29,17 @@ var PPT_ENCRYPTED_LOSS = {
|
|
|
29
29
|
feature: FEATURES.text,
|
|
30
30
|
detail: "legacy .ppt is encrypted/obfuscated — its text cannot be read"
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Read a legacy `.ppt` (PowerPoint 97–2003 OLE2/CFB) into the same
|
|
34
|
+
* {@link FlowDoc} the OOXML pptx reader produces: one page per slide at the deck
|
|
35
|
+
* size, with each slide's text (run + paragraph formatting), embedded images,
|
|
36
|
+
* per-shape placement and decorative autoshapes. Always reports a single
|
|
37
|
+
* {@link Loss} — degraded (the format is read best-effort; re-save as `.pptx` for
|
|
38
|
+
* full fidelity), or dropped when the file is encrypted/obfuscated.
|
|
39
|
+
*
|
|
40
|
+
* @param bytes The raw `.ppt` (CFB) bytes.
|
|
41
|
+
* @returns The {@link FlowDoc} plus the one-element loss report.
|
|
42
|
+
*/
|
|
32
43
|
function readPpt(bytes) {
|
|
33
44
|
const content = extractPptContent(bytes);
|
|
34
45
|
const width = pt(content.slideWidthPt ?? DEFAULT_SLIDE_W);
|
|
@@ -326,6 +337,11 @@ function anchorParagraph(breakBefore) {
|
|
|
326
337
|
}
|
|
327
338
|
};
|
|
328
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* The {@link DocumentReader} for legacy `.ppt`: sniffs an OLE2/CFB container with
|
|
342
|
+
* a `PowerPoint Document` stream (which also keeps an `.xls`/`.doc` or an
|
|
343
|
+
* encrypted OOXML from mis-routing here) and reads it via {@link readPpt}.
|
|
344
|
+
*/
|
|
329
345
|
var pptReader = {
|
|
330
346
|
id: "ppt",
|
|
331
347
|
produces: "flow",
|
|
@@ -1,25 +1,45 @@
|
|
|
1
|
+
/** A run of uniformly-formatted text within a paragraph (PPT-2). */
|
|
1
2
|
export interface PptRun {
|
|
2
3
|
readonly text: string;
|
|
3
4
|
readonly bold?: boolean;
|
|
4
5
|
readonly italic?: boolean;
|
|
5
6
|
readonly underline?: boolean;
|
|
7
|
+
/** The font size in points, when set on the run. */
|
|
6
8
|
readonly sizePt?: number;
|
|
9
|
+
/** The run colour as 6-hex RGB (no `#`), when an explicit sRGB colour is set. */
|
|
7
10
|
readonly colorHex?: string;
|
|
8
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* One slide paragraph: its runs plus the raw PPT alignment enum (0 left, 1
|
|
14
|
+
* center, 2 right, 3 justify, 4 distribute) and indent level (0–4), mapped by the
|
|
15
|
+
* reader.
|
|
16
|
+
*/
|
|
9
17
|
export interface PptParagraph {
|
|
10
18
|
readonly runs: ReadonlyArray<PptRun>;
|
|
19
|
+
/** The raw PowerPoint TextAlignmentEnum (mapped to a document-model alignment by the reader). */
|
|
11
20
|
readonly align?: number;
|
|
21
|
+
/** The 0-based outline/indent level. */
|
|
12
22
|
readonly level?: number;
|
|
13
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* An embedded picture referenced by a slide shape — the raw image bytes pulled
|
|
26
|
+
* from the Pictures stream (PPT-3).
|
|
27
|
+
*/
|
|
14
28
|
export interface PptImage {
|
|
15
29
|
readonly bytes: Uint8Array;
|
|
16
30
|
}
|
|
31
|
+
/** A shape's rectangle on the slide, in points (from the OfficeArtClientAnchor). */
|
|
17
32
|
export interface PptRect {
|
|
18
33
|
readonly x: number;
|
|
19
34
|
readonly y: number;
|
|
20
35
|
readonly w: number;
|
|
21
36
|
readonly h: number;
|
|
22
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* One command of a freeform path (PPT-7), in geometry-bounds space
|
|
40
|
+
* (`0..pathWidth`, `0..pathHeight`, y down) — the same path-space the DrawingML
|
|
41
|
+
* custom geometry uses.
|
|
42
|
+
*/
|
|
23
43
|
export type PptPathCmd = {
|
|
24
44
|
readonly kind: 'move';
|
|
25
45
|
readonly x: number;
|
|
@@ -39,31 +59,66 @@ export type PptPathCmd = {
|
|
|
39
59
|
} | {
|
|
40
60
|
readonly kind: 'close';
|
|
41
61
|
};
|
|
62
|
+
/**
|
|
63
|
+
* A shape's exact custom geometry (PPT-7): the freeform path from the OPT's
|
|
64
|
+
* `pVertices` + `pSegmentInfo` arrays, in its geometry-bounds coordinate space.
|
|
65
|
+
*/
|
|
42
66
|
export interface PptCustomGeometry {
|
|
43
67
|
readonly pathWidth: number;
|
|
44
68
|
readonly pathHeight: number;
|
|
45
69
|
readonly commands: ReadonlyArray<PptPathCmd>;
|
|
46
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* A decorative autoshape (PPT-5): its preset type plus any literal fill / line
|
|
73
|
+
* colour. Carried only by an anchored shape that has no text and no picture. A
|
|
74
|
+
* freeform additionally carries its exact custom geometry (PPT-7).
|
|
75
|
+
*/
|
|
47
76
|
export interface PptAutoShape {
|
|
77
|
+
/** The MSOSPT shape type (the FSP `recInstance`). */
|
|
48
78
|
readonly shapeType: number;
|
|
79
|
+
/** The resolved fill colour as 6-hex RGB, when present. */
|
|
49
80
|
readonly fillColorHex?: string;
|
|
81
|
+
/** The resolved line colour as 6-hex RGB, when present. */
|
|
50
82
|
readonly lineColorHex?: string;
|
|
51
83
|
readonly geometry?: PptCustomGeometry;
|
|
52
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* One slide shape (PPT-4..5): its text, picture and/or autoshape geometry, plus
|
|
87
|
+
* its slide rectangle when the shape carries an explicit anchor (else it is laid
|
|
88
|
+
* out in reading order).
|
|
89
|
+
*/
|
|
53
90
|
export interface PptShape {
|
|
54
91
|
readonly rectPt?: PptRect;
|
|
55
92
|
readonly paragraphs?: ReadonlyArray<PptParagraph>;
|
|
56
93
|
readonly image?: PptImage;
|
|
57
94
|
readonly autoShape?: PptAutoShape;
|
|
58
95
|
}
|
|
96
|
+
/** One slide: its shapes in document order. */
|
|
59
97
|
export interface PptSlide {
|
|
60
98
|
readonly shapes: ReadonlyArray<PptShape>;
|
|
61
99
|
}
|
|
100
|
+
/** The extracted content of a `.ppt`: its slides, deck page size and encryption flag. */
|
|
62
101
|
export interface PptContent {
|
|
63
102
|
readonly slides: ReadonlyArray<PptSlide>;
|
|
103
|
+
/** The deck page size in points, when the DocumentAtom gives a sane slide size. */
|
|
64
104
|
readonly slideWidthPt?: number;
|
|
65
105
|
readonly slideHeightPt?: number;
|
|
106
|
+
/** Whether the document streams are encrypted/obfuscated (so no text can be read). */
|
|
66
107
|
readonly encrypted: boolean;
|
|
67
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Walk a `.ppt` (CFB) into its {@link PptContent}: reads the `Current User`
|
|
111
|
+
* stream for the latest edit (and the encryption token), walks the edit chain to
|
|
112
|
+
* a persist directory, resolves the DocumentContainer and its slide list, and
|
|
113
|
+
* reads each slide's shapes/text/pictures. Degrades gracefully — when the
|
|
114
|
+
* persist/document structure can't be resolved it falls back to scanning the
|
|
115
|
+
* stream for slide containers directly, and structural doubt yields missing
|
|
116
|
+
* content, never wrong content. An encrypted file returns no slides with
|
|
117
|
+
* `encrypted: true`.
|
|
118
|
+
*
|
|
119
|
+
* @param bytes The raw `.ppt` (CFB) bytes.
|
|
120
|
+
* @returns The slides, deck size and encryption flag (empty when not a readable `.ppt`).
|
|
121
|
+
*/
|
|
68
122
|
export declare function extractPptContent(bytes: Uint8Array): PptContent;
|
|
123
|
+
/** The concatenated plain text of a paragraph's runs. */
|
|
69
124
|
export declare function paragraphText(p: PptParagraph): string;
|
|
@@ -66,6 +66,19 @@ function* records(d) {
|
|
|
66
66
|
off += consumed;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Walk a `.ppt` (CFB) into its {@link PptContent}: reads the `Current User`
|
|
71
|
+
* stream for the latest edit (and the encryption token), walks the edit chain to
|
|
72
|
+
* a persist directory, resolves the DocumentContainer and its slide list, and
|
|
73
|
+
* reads each slide's shapes/text/pictures. Degrades gracefully — when the
|
|
74
|
+
* persist/document structure can't be resolved it falls back to scanning the
|
|
75
|
+
* stream for slide containers directly, and structural doubt yields missing
|
|
76
|
+
* content, never wrong content. An encrypted file returns no slides with
|
|
77
|
+
* `encrypted: true`.
|
|
78
|
+
*
|
|
79
|
+
* @param bytes The raw `.ppt` (CFB) bytes.
|
|
80
|
+
* @returns The slides, deck size and encryption flag (empty when not a readable `.ppt`).
|
|
81
|
+
*/
|
|
69
82
|
function extractPptContent(bytes) {
|
|
70
83
|
const empty = {
|
|
71
84
|
slides: [],
|
|
@@ -549,6 +562,7 @@ function matchesMagic(d, off, magic) {
|
|
|
549
562
|
for (let i = 0; i < magic.length; i++) if (d[off + i] !== magic[i]) return false;
|
|
550
563
|
return true;
|
|
551
564
|
}
|
|
565
|
+
/** The concatenated plain text of a paragraph's runs. */
|
|
552
566
|
function paragraphText(p) {
|
|
553
567
|
return p.runs.map((r) => r.text).join("");
|
|
554
568
|
}
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { DocumentReader, ReadResult } from '../core/ir/adapters.js';
|
|
2
2
|
import { FlowDoc } from '../core/ir/flow.js';
|
|
3
3
|
import { PoNode } from '../core/po-helpers.js';
|
|
4
|
+
/**
|
|
5
|
+
* Read a PresentationML (`.pptx`) package into a {@link FlowDoc}: one page per
|
|
6
|
+
* slide at the deck size (`p:sldSz`), each slide's shapes placed as absolutely
|
|
7
|
+
* positioned floating elements. Hidden slides (`p:sld@show="0"`) are omitted (and
|
|
8
|
+
* recorded as a {@link Loss}, mirroring PowerPoint/LibreOffice export). Resolves
|
|
9
|
+
* each slide's layout → master → theme chain into the placeholder cascade, colour
|
|
10
|
+
* resolver and inherited background, plus its images and charts.
|
|
11
|
+
*
|
|
12
|
+
* @param bytes The raw `.pptx` (OPC ZIP) bytes.
|
|
13
|
+
* @returns The {@link FlowDoc} plus the accumulated loss report.
|
|
14
|
+
*/
|
|
4
15
|
export declare function readPptx(bytes: Uint8Array): ReadResult<FlowDoc>;
|
|
16
|
+
/**
|
|
17
|
+
* Parse an OOXML part's bytes into preserve-order {@link PoNode} roots with the
|
|
18
|
+
* module's shared, presentation-tuned {@link XMLParser} (attributes kept, values
|
|
19
|
+
* not coerced, whitespace preserved). Shared with the slide-style resolvers.
|
|
20
|
+
*/
|
|
5
21
|
export declare function parseXml(data: Uint8Array): Array<PoNode>;
|
|
22
|
+
/**
|
|
23
|
+
* The {@link DocumentReader} for PresentationML (`.pptx`): sniffs the OPC ZIP for
|
|
24
|
+
* `ppt/presentation.xml` (a cheap substring probe, no unzip) and reads it via
|
|
25
|
+
* {@link readPptx}.
|
|
26
|
+
*/
|
|
6
27
|
export declare const pptxReader: DocumentReader<FlowDoc>;
|
|
@@ -4,7 +4,7 @@ import { FEATURES } from "../core/ir/features.js";
|
|
|
4
4
|
import { EMPTY_STYLE_SHEET, resolveBodyStyles } from "../core/style-cascade/resolver.js";
|
|
5
5
|
import "../core/style-cascade/index.js";
|
|
6
6
|
import { poAttr, poChildren, poFindDescendant, poIntAttr, poIs } from "../core/po-helpers.js";
|
|
7
|
-
import {
|
|
7
|
+
import { bytesIncludePartName } from "../core/bytes.js";
|
|
8
8
|
import { DEFAULT_THEME_PALETTE, defaultColorResolver, makeColorResolver } from "../core/drawingml/colors.js";
|
|
9
9
|
import { parseChart, withChartColorStyle } from "../core/drawingml/chart-parser.js";
|
|
10
10
|
import { parseTheme } from "../core/drawingml/theme-parser.js";
|
|
@@ -30,6 +30,17 @@ function isSlideHidden(data) {
|
|
|
30
30
|
const root = decoder.decode(data.subarray(0, 4096)).match(/<p:sld\b[^>]*>/);
|
|
31
31
|
return root ? /\bshow\s*=\s*["']0["']/.test(root[0]) : false;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Read a PresentationML (`.pptx`) package into a {@link FlowDoc}: one page per
|
|
35
|
+
* slide at the deck size (`p:sldSz`), each slide's shapes placed as absolutely
|
|
36
|
+
* positioned floating elements. Hidden slides (`p:sld@show="0"`) are omitted (and
|
|
37
|
+
* recorded as a {@link Loss}, mirroring PowerPoint/LibreOffice export). Resolves
|
|
38
|
+
* each slide's layout → master → theme chain into the placeholder cascade, colour
|
|
39
|
+
* resolver and inherited background, plus its images and charts.
|
|
40
|
+
*
|
|
41
|
+
* @param bytes The raw `.pptx` (OPC ZIP) bytes.
|
|
42
|
+
* @returns The {@link FlowDoc} plus the accumulated loss report.
|
|
43
|
+
*/
|
|
33
44
|
function readPptx(bytes) {
|
|
34
45
|
const losses = [];
|
|
35
46
|
const pkg = OpcPackage.open(bytes);
|
|
@@ -133,6 +144,11 @@ function readPptx(bytes) {
|
|
|
133
144
|
losses
|
|
134
145
|
};
|
|
135
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Parse an OOXML part's bytes into preserve-order {@link PoNode} roots with the
|
|
149
|
+
* module's shared, presentation-tuned {@link XMLParser} (attributes kept, values
|
|
150
|
+
* not coerced, whitespace preserved). Shared with the slide-style resolvers.
|
|
151
|
+
*/
|
|
136
152
|
function parseXml(data) {
|
|
137
153
|
return parser.parse(decoder.decode(data));
|
|
138
154
|
}
|
|
@@ -238,6 +254,11 @@ function deckColorResolver(pkg, masterPath) {
|
|
|
238
254
|
for (const [slot, hex] of parseTheme(theme.data)) palette.set(slot, hex);
|
|
239
255
|
return makeColorResolver(palette);
|
|
240
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* The {@link DocumentReader} for PresentationML (`.pptx`): sniffs the OPC ZIP for
|
|
259
|
+
* `ppt/presentation.xml` (a cheap substring probe, no unzip) and reads it via
|
|
260
|
+
* {@link readPptx}.
|
|
261
|
+
*/
|
|
241
262
|
var pptxReader = {
|
|
242
263
|
id: "pptx",
|
|
243
264
|
produces: "flow",
|
|
@@ -248,7 +269,7 @@ var pptxReader = {
|
|
|
248
269
|
FEATURES.charts,
|
|
249
270
|
FEATURES.tables
|
|
250
271
|
]),
|
|
251
|
-
sniff: (bytes) => bytes[0] === 80 && bytes[1] === 75 &&
|
|
272
|
+
sniff: (bytes) => bytes[0] === 80 && bytes[1] === 75 && bytesIncludePartName(bytes, "ppt/presentation.xml"),
|
|
252
273
|
read: (bytes) => readPptx(bytes)
|
|
253
274
|
};
|
|
254
275
|
//#endregion
|
|
@@ -4,23 +4,125 @@ import { Loss, Pt, ResourceId } from '../core/ir/index.js';
|
|
|
4
4
|
import { PoNode } from '../core/po-helpers.js';
|
|
5
5
|
import { PlaceholderCascade } from './placeholder-cascade.js';
|
|
6
6
|
import { PlaceholderRef, ShapeBoxEmu } from './sp-helpers.js';
|
|
7
|
+
/**
|
|
8
|
+
* Per-slide parsing context: the placeholder cascade (PX2), an image resolver
|
|
9
|
+
* that turns a slide-scoped relationship id (`a:blip @r:embed`) into a
|
|
10
|
+
* {@link ResourceId} (PX3a), and a chart resolver that parses a referenced chart
|
|
11
|
+
* part (`c:chart @r:id`) and returns its document-unique key (PX4a). All optional
|
|
12
|
+
* — a bare slide needs none.
|
|
13
|
+
*/
|
|
7
14
|
export interface SlideContext {
|
|
8
15
|
readonly cascade?: PlaceholderCascade;
|
|
16
|
+
/** A slide-scoped blip relationship id (`a:blip @r:embed`) → a stored resource (PX3a). */
|
|
9
17
|
readonly resolveImage?: (relId: string) => ResourceId | undefined;
|
|
18
|
+
/** A chart relationship id (`c:chart @r:id`) → its document-unique key (PX4a). */
|
|
10
19
|
readonly resolveChart?: (relId: string) => string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The deck's colour resolver (master theme palette, PX5); defaults to the
|
|
22
|
+
* Office palette when absent.
|
|
23
|
+
*/
|
|
11
24
|
readonly colors?: ColorResolver;
|
|
25
|
+
/** A run hyperlink (`a:hlinkClick @r:id`) → its external URL (PX6). */
|
|
12
26
|
readonly resolveHyperlink?: (relId: string) => string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* A SmartArt data relationship (`dgm:relIds @r:dm`) → the diagram's pre-rendered
|
|
29
|
+
* drawing override (its `dsp:spTree`), or `undefined` when the file ships no
|
|
30
|
+
* override (E-SMARTART SA0).
|
|
31
|
+
*/
|
|
13
32
|
readonly resolveDiagram?: (relId: string) => PoNode | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Sink for graceful-degradation notices (E-SMARTART SA3): a SmartArt that
|
|
35
|
+
* declares a diagram but ships no drawing override records a dropped-feature
|
|
36
|
+
* {@link Loss} here rather than vanishing without a trace.
|
|
37
|
+
*/
|
|
14
38
|
readonly onLoss?: (loss: Loss) => void;
|
|
15
39
|
}
|
|
16
40
|
type LinkResolver = ((relId: string) => string | undefined) | undefined;
|
|
17
41
|
type GroupTransform = (box: ShapeBoxEmu) => ShapeBoxEmu;
|
|
42
|
+
/**
|
|
43
|
+
* Walk a shape container (`p:spTree` or a `p:grpSp`), turning each `p:sp` into a
|
|
44
|
+
* floating text/graphic shape, each `p:pic` into a floating image, each
|
|
45
|
+
* `p:graphicFrame` into a chart/table, and recursing into nested `p:grpSp` groups
|
|
46
|
+
* (composing their transforms).
|
|
47
|
+
*
|
|
48
|
+
* @param container The shape container node.
|
|
49
|
+
* @param ctx The per-slide parsing context.
|
|
50
|
+
* @param transform Maps child-space boxes to the slide (identity at the top level).
|
|
51
|
+
* @returns The container's shapes as positioned {@link BodyElement}s.
|
|
52
|
+
*/
|
|
18
53
|
export declare function parseSlideShapes(container: PoNode, ctx?: SlideContext, transform?: GroupTransform): Array<BodyElement>;
|
|
54
|
+
/**
|
|
55
|
+
* The diagram's child shapes live in the spTree's own coordinate space
|
|
56
|
+
* (`dsp:grpSpPr/a:xfrm` `chOff`/`chExt`); map that onto a target box (the frame on
|
|
57
|
+
* a slide, or the inline/anchored box in docx). Usually the child space equals
|
|
58
|
+
* the box, so the scale is 1. Shared by pptx and docx (E-SMARTART).
|
|
59
|
+
*
|
|
60
|
+
* @param spTree The diagram drawing's `dsp:spTree`.
|
|
61
|
+
* @param frame The target box the diagram is placed into.
|
|
62
|
+
* @returns A transform mapping diagram-space boxes onto `frame`.
|
|
63
|
+
*/
|
|
19
64
|
export declare function diagramTransform(spTree: PoNode, frame: ShapeBoxEmu): GroupTransform;
|
|
65
|
+
/**
|
|
66
|
+
* A {@link Loss} for a SmartArt diagram that declares its data part but ships no
|
|
67
|
+
* pre-rendered drawing override (older files, or a generator that omitted the
|
|
68
|
+
* fallback). Ream renders the override rather than executing Office's layout
|
|
69
|
+
* engine, so without it the diagram can't be drawn — this records the gap as a
|
|
70
|
+
* dropped feature instead of letting it vanish. Shared by pptx and docx
|
|
71
|
+
* (E-SMARTART SA3).
|
|
72
|
+
*
|
|
73
|
+
* @param where Optional location tag for the loss report (e.g. `slide 3`).
|
|
74
|
+
*/
|
|
20
75
|
export declare function noDiagramOverrideLoss(where?: string): Loss;
|
|
76
|
+
/**
|
|
77
|
+
* Render a SmartArt drawing override (a `dsp:spTree`) into floating shapes. The
|
|
78
|
+
* `dsp:` wrapper holds an ordinary `a:` `spPr`/`txBody`, so the shared DrawingML
|
|
79
|
+
* readers apply unchanged. Shared by pptx and docx (E-SMARTART); diagrams carry
|
|
80
|
+
* no placeholder cascade.
|
|
81
|
+
*
|
|
82
|
+
* @param spTree The diagram drawing's `dsp:spTree`.
|
|
83
|
+
* @param transform Maps each shape's diagram-space box to the target space.
|
|
84
|
+
* @param makeFloat Anchors a box — page-relative for a slide, column/paragraph-
|
|
85
|
+
* relative for an inline docx diagram.
|
|
86
|
+
* @param colors The colour resolver for the shapes' fills/strokes/text.
|
|
87
|
+
* @param resolveLink A run hyperlink resolver, or `undefined`.
|
|
88
|
+
* @returns The diagram's visible shapes as positioned {@link ShapeBlock}s.
|
|
89
|
+
*/
|
|
21
90
|
export declare function parseDiagramDrawing(spTree: PoNode, transform: GroupTransform, makeFloat: (box: ShapeBoxEmu) => FloatAnchor, colors: ColorResolver, resolveLink: LinkResolver): Array<ShapeBlock>;
|
|
91
|
+
/**
|
|
92
|
+
* `p:bg` → the background fill, or `undefined` when none/unsupported. `p:bgPr`
|
|
93
|
+
* carries the fill directly (`a:solidFill`/`a:gradFill` — the same children
|
|
94
|
+
* `parseFill` reads; a picture background is not yet supported); `p:bgRef` (a
|
|
95
|
+
* theme fill-style index) is approximated by its colour child as a solid fill.
|
|
96
|
+
* Used for the slide's own background and the inherited layout/master one (PX5b).
|
|
97
|
+
*/
|
|
22
98
|
export declare function parseBackgroundFill(bg: PoNode, colors: ColorResolver): ShapeFill | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* A full-slide backdrop element for a background fill: a rectangle covering the
|
|
101
|
+
* page, anchored behind the content (PX5b).
|
|
102
|
+
*
|
|
103
|
+
* @param fill The resolved background fill.
|
|
104
|
+
* @param widthPt The page width in points.
|
|
105
|
+
* @param heightPt The page height in points.
|
|
106
|
+
*/
|
|
23
107
|
export declare function backdropElement(fill: ShapeFill, widthPt: Pt, heightPt: Pt): BodyElement;
|
|
108
|
+
/**
|
|
109
|
+
* `p:spPr` geometry: `a:prstGeom` (preset) or `a:custGeom` (custom path), default
|
|
110
|
+
* rect. Exported for sheet shapes (E-SHEET W2), whose `xdr:spPr` carries the same
|
|
111
|
+
* `a:` children.
|
|
112
|
+
*/
|
|
24
113
|
export declare function parseGeometry(spPr: PoNode | undefined): ShapeGeometry;
|
|
114
|
+
/**
|
|
115
|
+
* `p:txBody` → {@link ShapeTextBody}. `a:bodyPr` carries the insets and the
|
|
116
|
+
* vertical anchor (PX6: anchor `t`/`ctr`/`b`). Exported for sheet shapes
|
|
117
|
+
* (E-SHEET W2) — like SmartArt, they pass no placeholder cascade, so runs use
|
|
118
|
+
* their direct `a:rPr` formatting.
|
|
119
|
+
*
|
|
120
|
+
* @param txBody The `p:txBody` node.
|
|
121
|
+
* @param ph The owning placeholder ref, when this is a placeholder shape.
|
|
122
|
+
* @param cascade The placeholder cascade supplying inherited run defaults.
|
|
123
|
+
* @param colors The colour resolver for run colours.
|
|
124
|
+
* @param resolveLink A run hyperlink resolver, or `undefined`.
|
|
125
|
+
* @returns The text body, or `undefined` when it holds no paragraphs.
|
|
126
|
+
*/
|
|
25
127
|
export declare function parseTxBody(txBody: PoNode, ph: PlaceholderRef | undefined, cascade: PlaceholderCascade | undefined, colors: ColorResolver, resolveLink: LinkResolver): ShapeTextBody | undefined;
|
|
26
128
|
export {};
|
|
@@ -21,6 +21,17 @@ var RECT_GEOMETRY = {
|
|
|
21
21
|
adjust: /* @__PURE__ */ new Map()
|
|
22
22
|
};
|
|
23
23
|
var IDENTITY_TRANSFORM = (box) => box;
|
|
24
|
+
/**
|
|
25
|
+
* Walk a shape container (`p:spTree` or a `p:grpSp`), turning each `p:sp` into a
|
|
26
|
+
* floating text/graphic shape, each `p:pic` into a floating image, each
|
|
27
|
+
* `p:graphicFrame` into a chart/table, and recursing into nested `p:grpSp` groups
|
|
28
|
+
* (composing their transforms).
|
|
29
|
+
*
|
|
30
|
+
* @param container The shape container node.
|
|
31
|
+
* @param ctx The per-slide parsing context.
|
|
32
|
+
* @param transform Maps child-space boxes to the slide (identity at the top level).
|
|
33
|
+
* @returns The container's shapes as positioned {@link BodyElement}s.
|
|
34
|
+
*/
|
|
24
35
|
function parseSlideShapes(container, ctx = {}, transform = IDENTITY_TRANSFORM) {
|
|
25
36
|
const out = [];
|
|
26
37
|
for (const child of poChildren(container)) if (poIs(child, "p:sp")) {
|
|
@@ -148,6 +159,16 @@ function parseGraphicFrame(gf, ctx, transform) {
|
|
|
148
159
|
}
|
|
149
160
|
return [];
|
|
150
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* The diagram's child shapes live in the spTree's own coordinate space
|
|
164
|
+
* (`dsp:grpSpPr/a:xfrm` `chOff`/`chExt`); map that onto a target box (the frame on
|
|
165
|
+
* a slide, or the inline/anchored box in docx). Usually the child space equals
|
|
166
|
+
* the box, so the scale is 1. Shared by pptx and docx (E-SMARTART).
|
|
167
|
+
*
|
|
168
|
+
* @param spTree The diagram drawing's `dsp:spTree`.
|
|
169
|
+
* @param frame The target box the diagram is placed into.
|
|
170
|
+
* @returns A transform mapping diagram-space boxes onto `frame`.
|
|
171
|
+
*/
|
|
151
172
|
function diagramTransform(spTree, frame) {
|
|
152
173
|
const grpSpPr = poChildren(spTree).find((c) => poIs(c, "dsp:grpSpPr"));
|
|
153
174
|
const xfrm = grpSpPr ? poChildren(grpSpPr).find((c) => poIs(c, "a:xfrm")) : void 0;
|
|
@@ -166,6 +187,16 @@ function diagramTransform(spTree, frame) {
|
|
|
166
187
|
cy: b.cy * sy
|
|
167
188
|
});
|
|
168
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* A {@link Loss} for a SmartArt diagram that declares its data part but ships no
|
|
192
|
+
* pre-rendered drawing override (older files, or a generator that omitted the
|
|
193
|
+
* fallback). Ream renders the override rather than executing Office's layout
|
|
194
|
+
* engine, so without it the diagram can't be drawn — this records the gap as a
|
|
195
|
+
* dropped feature instead of letting it vanish. Shared by pptx and docx
|
|
196
|
+
* (E-SMARTART SA3).
|
|
197
|
+
*
|
|
198
|
+
* @param where Optional location tag for the loss report (e.g. `slide 3`).
|
|
199
|
+
*/
|
|
169
200
|
function noDiagramOverrideLoss(where) {
|
|
170
201
|
return {
|
|
171
202
|
severity: "dropped",
|
|
@@ -174,6 +205,20 @@ function noDiagramOverrideLoss(where) {
|
|
|
174
205
|
...where ? { where } : {}
|
|
175
206
|
};
|
|
176
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Render a SmartArt drawing override (a `dsp:spTree`) into floating shapes. The
|
|
210
|
+
* `dsp:` wrapper holds an ordinary `a:` `spPr`/`txBody`, so the shared DrawingML
|
|
211
|
+
* readers apply unchanged. Shared by pptx and docx (E-SMARTART); diagrams carry
|
|
212
|
+
* no placeholder cascade.
|
|
213
|
+
*
|
|
214
|
+
* @param spTree The diagram drawing's `dsp:spTree`.
|
|
215
|
+
* @param transform Maps each shape's diagram-space box to the target space.
|
|
216
|
+
* @param makeFloat Anchors a box — page-relative for a slide, column/paragraph-
|
|
217
|
+
* relative for an inline docx diagram.
|
|
218
|
+
* @param colors The colour resolver for the shapes' fills/strokes/text.
|
|
219
|
+
* @param resolveLink A run hyperlink resolver, or `undefined`.
|
|
220
|
+
* @returns The diagram's visible shapes as positioned {@link ShapeBlock}s.
|
|
221
|
+
*/
|
|
177
222
|
function parseDiagramDrawing(spTree, transform, makeFloat, colors, resolveLink) {
|
|
178
223
|
const out = [];
|
|
179
224
|
for (const sp of poChildren(spTree)) {
|
|
@@ -202,6 +247,13 @@ function parseDiagramDrawing(spTree, transform, makeFloat, colors, resolveLink)
|
|
|
202
247
|
}
|
|
203
248
|
return out;
|
|
204
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* `p:bg` → the background fill, or `undefined` when none/unsupported. `p:bgPr`
|
|
252
|
+
* carries the fill directly (`a:solidFill`/`a:gradFill` — the same children
|
|
253
|
+
* `parseFill` reads; a picture background is not yet supported); `p:bgRef` (a
|
|
254
|
+
* theme fill-style index) is approximated by its colour child as a solid fill.
|
|
255
|
+
* Used for the slide's own background and the inherited layout/master one (PX5b).
|
|
256
|
+
*/
|
|
205
257
|
function parseBackgroundFill(bg, colors) {
|
|
206
258
|
const bgPr = poChildren(bg).find((c) => poIs(c, "p:bgPr"));
|
|
207
259
|
if (bgPr) {
|
|
@@ -217,6 +269,14 @@ function parseBackgroundFill(bg, colors) {
|
|
|
217
269
|
};
|
|
218
270
|
}
|
|
219
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* A full-slide backdrop element for a background fill: a rectangle covering the
|
|
274
|
+
* page, anchored behind the content (PX5b).
|
|
275
|
+
*
|
|
276
|
+
* @param fill The resolved background fill.
|
|
277
|
+
* @param widthPt The page width in points.
|
|
278
|
+
* @param heightPt The page height in points.
|
|
279
|
+
*/
|
|
220
280
|
function backdropElement(fill, widthPt, heightPt) {
|
|
221
281
|
return {
|
|
222
282
|
kind: "shape",
|
|
@@ -241,6 +301,11 @@ function backdropElement(fill, widthPt, heightPt) {
|
|
|
241
301
|
}
|
|
242
302
|
};
|
|
243
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* `p:spPr` geometry: `a:prstGeom` (preset) or `a:custGeom` (custom path), default
|
|
306
|
+
* rect. Exported for sheet shapes (E-SHEET W2), whose `xdr:spPr` carries the same
|
|
307
|
+
* `a:` children.
|
|
308
|
+
*/
|
|
244
309
|
function parseGeometry(spPr) {
|
|
245
310
|
if (!spPr) return RECT_GEOMETRY;
|
|
246
311
|
const prst = poChildren(spPr).find((c) => poIs(c, "a:prstGeom"));
|
|
@@ -286,6 +351,19 @@ function txBodyParagraphs(txBody, ph, cascade, colors, resolveLink) {
|
|
|
286
351
|
}
|
|
287
352
|
return content;
|
|
288
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* `p:txBody` → {@link ShapeTextBody}. `a:bodyPr` carries the insets and the
|
|
356
|
+
* vertical anchor (PX6: anchor `t`/`ctr`/`b`). Exported for sheet shapes
|
|
357
|
+
* (E-SHEET W2) — like SmartArt, they pass no placeholder cascade, so runs use
|
|
358
|
+
* their direct `a:rPr` formatting.
|
|
359
|
+
*
|
|
360
|
+
* @param txBody The `p:txBody` node.
|
|
361
|
+
* @param ph The owning placeholder ref, when this is a placeholder shape.
|
|
362
|
+
* @param cascade The placeholder cascade supplying inherited run defaults.
|
|
363
|
+
* @param colors The colour resolver for run colours.
|
|
364
|
+
* @param resolveLink A run hyperlink resolver, or `undefined`.
|
|
365
|
+
* @returns The text body, or `undefined` when it holds no paragraphs.
|
|
366
|
+
*/
|
|
289
367
|
function parseTxBody(txBody, ph, cascade, colors, resolveLink) {
|
|
290
368
|
const content = txBodyParagraphs(txBody, ph, cascade, colors, resolveLink);
|
|
291
369
|
if (content.length === 0) return void 0;
|