reamkit 1.15.0 → 1.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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 +9 -0
- package/dist/esm/core/bytes.js +9 -0
- 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 +50 -4
- 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 +46 -0
- 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 +281 -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 +26 -0
- 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 +56 -0
- package/dist/esm/excel/print-model.js +43 -0
- 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 +19 -0
- package/dist/esm/excel/sheet-to-flow.js +10 -0
- 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 +9 -0
- 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 +26 -0
- package/dist/esm/excel/xlsx-reader.js +26 -0
- 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 +117 -2
- 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 +51 -2
- package/dist/esm/pdf-reader/flow-build.js +67 -2
- 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 +17 -2
- 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 +15 -2
- 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 +37 -1
- 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 +26 -4
- package/dist/esm/word/doc/doc-text.d.ts +81 -0
- package/dist/esm/word/doc/doc-text.js +38 -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 +16 -0
- 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 +1 -1
|
@@ -3,35 +3,74 @@ import { FontMeasure, ParsedTtf } from '../core/font/index.js';
|
|
|
3
3
|
import { ResolvedParagraphProperties, ResolvedRunProperties } from '../core/style-cascade/index.js';
|
|
4
4
|
import { PathSegment, VectorShape } from '../core/vector.js';
|
|
5
5
|
import { PreparedImage } from '../core/images.js';
|
|
6
|
+
/** A font bound into a {@link LaidOutDocument}: the parsed face plus what layout/emit need from it. */
|
|
6
7
|
export interface FontResource {
|
|
7
8
|
readonly resourceName: string;
|
|
8
9
|
readonly parsed: ParsedTtf;
|
|
10
|
+
/**
|
|
11
|
+
* Pure measurement/encoding (no `PdfDocument`): layout measures with this and
|
|
12
|
+
* emit encodes with it; the PDF font objects are created in the emit phase.
|
|
13
|
+
*/
|
|
9
14
|
readonly measure: FontMeasure;
|
|
15
|
+
/** Glyphs collected by the usage walk — the emit phase subsets to these. */
|
|
10
16
|
readonly gids: ReadonlySet<number>;
|
|
11
17
|
}
|
|
18
|
+
/** A run of text on a {@link Line}: the string plus its resolved font, size, width and link/tagging state. */
|
|
12
19
|
export interface TextToken {
|
|
13
20
|
readonly kind: 'text';
|
|
14
21
|
readonly text: string;
|
|
15
22
|
readonly isSpace: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* External hyperlink target inherited from the source run (rels-resolved).
|
|
25
|
+
* Writers MUST sanitize the scheme (`core/links`) before emitting anything
|
|
26
|
+
* clickable.
|
|
27
|
+
*/
|
|
16
28
|
readonly href?: string;
|
|
29
|
+
/**
|
|
30
|
+
* §17.11.14 — the token renders a footnote reference number; pagination
|
|
31
|
+
* reserves the note's block at the bottom of the page it lands on.
|
|
32
|
+
*/
|
|
17
33
|
readonly footnoteRef?: string;
|
|
34
|
+
/**
|
|
35
|
+
* §17.16.22 — internal link target: a bookmark name in this document (not a
|
|
36
|
+
* URL; resolves to a GoTo destination, never through the scheme list).
|
|
37
|
+
*/
|
|
18
38
|
readonly anchor?: string;
|
|
39
|
+
/**
|
|
40
|
+
* List-item marker glyphs (`"1."`, `"•"`) — tagged PDF brackets them in a Lbl
|
|
41
|
+
* element separate from the item body.
|
|
42
|
+
*/
|
|
19
43
|
readonly listMarker?: true;
|
|
44
|
+
/**
|
|
45
|
+
* The token falls inside a comment range (`commentRangeRefs`): the emitter
|
|
46
|
+
* fills a soft highlight behind it (E-COMMENTS CM2c).
|
|
47
|
+
*/
|
|
20
48
|
readonly highlight?: true;
|
|
21
49
|
readonly resolvedRun: ResolvedRunProperties;
|
|
22
50
|
readonly font: FontResource;
|
|
23
51
|
readonly fontSizePt: number;
|
|
24
52
|
readonly widthPt: number;
|
|
53
|
+
/**
|
|
54
|
+
* UAX #9 embedding level of this token's characters (0 for pure-LTR docs).
|
|
55
|
+
* Even = LTR, odd = RTL. Used for visual reordering at emit time.
|
|
56
|
+
*/
|
|
25
57
|
readonly bidiLevel: number;
|
|
26
58
|
}
|
|
59
|
+
/** An inline image on a {@link Line}: its sized box plus the resource name binding to the page XObject. */
|
|
27
60
|
export interface ImageToken {
|
|
28
61
|
readonly kind: 'image';
|
|
29
62
|
readonly imageResourceName: string;
|
|
30
63
|
readonly widthPt: number;
|
|
31
64
|
readonly heightPt: number;
|
|
65
|
+
/** Constants kept to satisfy {@link Token} consumers — they never read these for images. */
|
|
32
66
|
readonly isSpace: false;
|
|
33
67
|
readonly bidiLevel: number;
|
|
34
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* A math draw item with its font already resolved (`math-layout` emits a
|
|
71
|
+
* variant; the tokenizer maps it to a {@link FontResource} so the emit phase
|
|
72
|
+
* needs no fonts).
|
|
73
|
+
*/
|
|
35
74
|
export type ResolvedMathItem = {
|
|
36
75
|
readonly kind: 'glyph';
|
|
37
76
|
readonly x: number;
|
|
@@ -51,6 +90,10 @@ export type ResolvedMathItem = {
|
|
|
51
90
|
readonly strokeWidthPt?: number;
|
|
52
91
|
readonly fill?: boolean;
|
|
53
92
|
};
|
|
93
|
+
/**
|
|
94
|
+
* An inline OfficeMath object — an atomic box straddling the baseline (its own
|
|
95
|
+
* ascent/descent extend the line height).
|
|
96
|
+
*/
|
|
54
97
|
export interface MathToken {
|
|
55
98
|
readonly kind: 'math';
|
|
56
99
|
readonly items: ReadonlyArray<ResolvedMathItem>;
|
|
@@ -60,7 +103,9 @@ export interface MathToken {
|
|
|
60
103
|
readonly isSpace: false;
|
|
61
104
|
readonly bidiLevel: number;
|
|
62
105
|
}
|
|
106
|
+
/** A positioned atom on a {@link Line}: a text run, an inline image, or an inline math box. */
|
|
63
107
|
export type Token = TextToken | ImageToken | MathToken;
|
|
108
|
+
/** A laid-out line of a paragraph: its broken tokens plus the geometry pagination needs. */
|
|
64
109
|
export interface Line {
|
|
65
110
|
readonly tokens: ReadonlyArray<Token>;
|
|
66
111
|
readonly contentWidthPt: number;
|
|
@@ -69,25 +114,61 @@ export interface Line {
|
|
|
69
114
|
readonly firstLine: boolean;
|
|
70
115
|
readonly resolved: ResolvedParagraphProperties;
|
|
71
116
|
isLastInParagraph: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Max ascent/descent contributed by math tokens (0 when none) — they straddle
|
|
119
|
+
* the baseline, so the line height/descent must grow to fit them.
|
|
120
|
+
*/
|
|
72
121
|
readonly mathAscentPt?: number;
|
|
73
122
|
readonly mathDescentPt?: number;
|
|
123
|
+
/**
|
|
124
|
+
* E-PARITY: metric-derived single-line height and descent (Pt), the max over
|
|
125
|
+
* the line's text-token fonts under a non-default `layoutProfile`. Absent under
|
|
126
|
+
* `'ream'`, where leading stays the flat 1.2×/0.2 model (byte-identical).
|
|
127
|
+
*/
|
|
74
128
|
readonly metricHeightPt?: number;
|
|
75
129
|
readonly metricDescentPt?: number;
|
|
76
130
|
}
|
|
131
|
+
/** An image bound into a {@link LaidOutDocument}: its resource name plus the decoded/validated bytes. */
|
|
77
132
|
export interface ImageResource {
|
|
78
133
|
readonly resourceName: string;
|
|
134
|
+
/**
|
|
135
|
+
* Decoded/validated at layout time (the probe); the emit phase replays it
|
|
136
|
+
* without touching the source bytes again.
|
|
137
|
+
*/
|
|
79
138
|
readonly prepared: PreparedImage;
|
|
80
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* The fields every {@link PageItem} shares (ir-design §6, frozen at stage 6.4):
|
|
142
|
+
* the positioned, layout-output vocabulary a page is made of. Page-frame
|
|
143
|
+
* geometry is branded `Pt` (PostScript points) with a TOP-LEFT origin, y growing
|
|
144
|
+
* downward (like CSS/SVG); the PDF emitter converts into PDF's native y-up frame
|
|
145
|
+
* at emission. Offsets measured from a text baseline (math/inline-image boxes
|
|
146
|
+
* inside a {@link Line}) and styling magnitudes (font/stroke sizes) stay plain
|
|
147
|
+
* numbers — they are not page-frame coordinates.
|
|
148
|
+
*/
|
|
81
149
|
export interface PageItemBase {
|
|
150
|
+
/**
|
|
151
|
+
* Tagged PDF (§14.8): the logical structure node this item's content belongs
|
|
152
|
+
* to. Set only on body content in tagged mode; undefined text in the line pass
|
|
153
|
+
* is treated as an artifact. Ignored when not tagging.
|
|
154
|
+
*/
|
|
82
155
|
readonly structId?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Tagged PDF: explicitly mark this item as a pagination artifact (running
|
|
158
|
+
* header/footer, §14.8.2.2.2). Distinguishes header/footer text from
|
|
159
|
+
* not-yet-tagged body content so it is typed `/Artifact /Pagination`, never a P.
|
|
160
|
+
*/
|
|
83
161
|
readonly artifact?: 'pagination';
|
|
84
162
|
}
|
|
163
|
+
/** A laid-out line of text (tokens carry their fonts/sizes/positions). */
|
|
85
164
|
export interface TextLineItem extends PageItemBase {
|
|
86
165
|
readonly type: 'line';
|
|
87
166
|
readonly line: Line;
|
|
88
167
|
readonly originX: Pt;
|
|
168
|
+
/** Distance from the page TOP down to the text baseline. */
|
|
89
169
|
readonly baselineY: Pt;
|
|
90
170
|
}
|
|
171
|
+
/** One edge of a table-cell frame; `(x, y)` is the cell box's top-left corner. */
|
|
91
172
|
export interface BorderItem extends PageItemBase {
|
|
92
173
|
readonly type: 'border';
|
|
93
174
|
readonly side: 'top' | 'right' | 'bottom' | 'left';
|
|
@@ -98,6 +179,7 @@ export interface BorderItem extends PageItemBase {
|
|
|
98
179
|
readonly borderSizePt: number;
|
|
99
180
|
readonly borderColorHex: string;
|
|
100
181
|
}
|
|
182
|
+
/** A filled rectangle (cell shading); `(x, y)` is its top-left corner. */
|
|
101
183
|
export interface FillItem extends PageItemBase {
|
|
102
184
|
readonly type: 'fill';
|
|
103
185
|
readonly x: Pt;
|
|
@@ -106,6 +188,10 @@ export interface FillItem extends PageItemBase {
|
|
|
106
188
|
readonly height: Pt;
|
|
107
189
|
readonly fillColorHex: string;
|
|
108
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* A placed raster image (resource name binds to the page XObject dict); `(x, y)`
|
|
193
|
+
* is its top-left corner.
|
|
194
|
+
*/
|
|
109
195
|
export interface ImageItem extends PageItemBase {
|
|
110
196
|
readonly type: 'image';
|
|
111
197
|
readonly x: Pt;
|
|
@@ -114,10 +200,15 @@ export interface ImageItem extends PageItemBase {
|
|
|
114
200
|
readonly height: Pt;
|
|
115
201
|
readonly imageResourceName: string;
|
|
116
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* DrawingML vector geometry. `shape.transform` maps the shape's local y-up frame
|
|
205
|
+
* into the top-left page frame (see `flipTransform`).
|
|
206
|
+
*/
|
|
117
207
|
export interface ShapeItem extends PageItemBase {
|
|
118
208
|
readonly type: 'shape';
|
|
119
209
|
readonly shape: VectorShape;
|
|
120
210
|
}
|
|
211
|
+
/** A positioned item on a laid-out page: a text line, border, fill, image, or vector shape. */
|
|
121
212
|
export type PageItem = TextLineItem | BorderItem | FillItem | ImageItem | ShapeItem;
|
|
122
213
|
export interface PagePaintPlan {
|
|
123
214
|
readonly fills: ReadonlyArray<FillItem>;
|
|
@@ -8,29 +8,100 @@ import { SignaturePlaceholder } from '../pdf/signature.js';
|
|
|
8
8
|
import { PdfEncryptOptions } from '../pdf/encryption.js';
|
|
9
9
|
import { ResourceStore } from '../core/ir/index.js';
|
|
10
10
|
import { StructTreeBuilder } from '../pdf/struct-tree.js';
|
|
11
|
+
/**
|
|
12
|
+
* PDF/A conformance string: part 1 (ISO 19005-1, PDF 1.4) / 2 (ISO 19005-2) / 3
|
|
13
|
+
* (ISO 19005-3, both PDF 1.7); conformance level a (tagged) / b (visual) /
|
|
14
|
+
* u (Unicode — only 2/3).
|
|
15
|
+
*/
|
|
11
16
|
export type PdfALevel = 'PDF/A-1b' | 'PDF/A-1a' | 'PDF/A-2b' | 'PDF/A-2u' | 'PDF/A-2a' | 'PDF/A-3b' | 'PDF/A-3u' | 'PDF/A-3a';
|
|
17
|
+
/** A {@link PdfALevel} decomposed into the part, level, and the apparatus they imply. */
|
|
12
18
|
export interface PdfAProfile {
|
|
13
19
|
readonly part: 1 | 2 | 3;
|
|
14
20
|
readonly level: 'a' | 'b' | 'u';
|
|
21
|
+
/** Whether the level mandates a tagged PDF (level `a`). */
|
|
15
22
|
readonly tagged: boolean;
|
|
23
|
+
/** PDF version the part pins: part 1 → 1.4, else 1.7. */
|
|
16
24
|
readonly version: '1.4' | '1.7';
|
|
17
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* E-PARITY: renderer-compatibility profile for the line-height model.
|
|
28
|
+
* `'ream'` (default) — Ream's flat 1.2× leading; byte-identical to before.
|
|
29
|
+
* `'word'` — leading from the font's OS/2 usWin metrics (the GDI cell box).
|
|
30
|
+
* `'libreoffice'` — leading from hhea (or OS/2 typo when USE_TYPO_METRICS is set).
|
|
31
|
+
*
|
|
32
|
+
* Opt-in: a profile emulates that renderer's vertical rhythm for closer visual
|
|
33
|
+
* parity. It never changes default (`'ream'`) output.
|
|
34
|
+
*/
|
|
18
35
|
export type LayoutProfile = 'ream' | 'word' | 'libreoffice';
|
|
36
|
+
/**
|
|
37
|
+
* The full option set the layout engine and PDF emitter consume: the resolved
|
|
38
|
+
* font registry, the style/numbering tables, the section model and page
|
|
39
|
+
* geometry, the after-body apparatus (footnotes, endnotes, comments), and every
|
|
40
|
+
* PDF-output toggle (PDF/A, tagged, PDF/UA, encryption, attachments,
|
|
41
|
+
* signatures). Only `registry` and `styles` are required; everything else falls
|
|
42
|
+
* back to a sensible default.
|
|
43
|
+
*/
|
|
19
44
|
export interface StyledRenderOptions {
|
|
45
|
+
/** The resolved font set every run draws with (the guaranteed fallback registry). */
|
|
20
46
|
readonly registry: FontRegistry;
|
|
47
|
+
/** Renderer-compatibility profile for the line-height model (default `'ream'`). */
|
|
21
48
|
readonly layoutProfile?: LayoutProfile;
|
|
49
|
+
/**
|
|
50
|
+
* Per-run font resolution: when supplied, each text run picks the registry of
|
|
51
|
+
* its declared family (sans→arimo / serif→tinos / mono→cousine via the run's
|
|
52
|
+
* `w:ascii`) instead of always using `registry`. Absent ⇒ single-family (every
|
|
53
|
+
* run uses `registry`), byte-identical to before. `registry` remains the
|
|
54
|
+
* guaranteed fallback for math/chart/default glyphs and any missing family.
|
|
55
|
+
*/
|
|
22
56
|
readonly registriesByFamily?: ReadonlyMap<FamilyKey, FontRegistry>;
|
|
57
|
+
/**
|
|
58
|
+
* The document's OWN embedded fonts (`word/fonts/*.odttf`, de-obfuscated),
|
|
59
|
+
* keyed by normalized font name. A run whose `w:ascii` matches one renders with
|
|
60
|
+
* the real font — glyph-exact, no substitution. Highest priority.
|
|
61
|
+
*/
|
|
23
62
|
readonly embeddedFonts?: ReadonlyMap<string, FontRegistry>;
|
|
63
|
+
/** §18.8 / ECMA-376 style table the cascade resolves against. */
|
|
24
64
|
readonly styles: StyleSheet;
|
|
65
|
+
/** §17.9 numbering definitions; applied to list paragraphs before layout. */
|
|
25
66
|
readonly numbering?: Numbering;
|
|
67
|
+
/**
|
|
68
|
+
* Single-section legacy entry-point. If `sections` is set it takes precedence
|
|
69
|
+
* and `section` is ignored.
|
|
70
|
+
*/
|
|
26
71
|
readonly section?: SectionProperties;
|
|
72
|
+
/**
|
|
73
|
+
* ECMA-376 §17.6 — ordered list of sections. Each section's `endIndex` is the
|
|
74
|
+
* exclusive bound into the body array (section N covers
|
|
75
|
+
* `body[sections[N-1].endIndex..sections[N].endIndex)`).
|
|
76
|
+
*/
|
|
27
77
|
readonly sections?: ReadonlyArray<Section>;
|
|
78
|
+
/** Header/footer body content keyed by relationship id. */
|
|
28
79
|
readonly headersFooters?: ReadonlyMap<string, ReadonlyArray<BodyElement>>;
|
|
80
|
+
/**
|
|
81
|
+
* §17.11 notes content by id. Footnotes render in a reserved band at the
|
|
82
|
+
* bottom of the referencing page; endnotes flow after the body.
|
|
83
|
+
*/
|
|
29
84
|
readonly footnotes?: ReadonlyMap<string, ReadonlyArray<BodyElement>>;
|
|
30
85
|
readonly endnotes?: ReadonlyMap<string, ReadonlyArray<BodyElement>>;
|
|
86
|
+
/**
|
|
87
|
+
* §17.13.4 review comments by id; rendered as superscript markers in text and
|
|
88
|
+
* a list after the body (after endnotes), each with its author/date.
|
|
89
|
+
*/
|
|
31
90
|
readonly comments?: ReadonlyMap<string, Comment>;
|
|
91
|
+
/**
|
|
92
|
+
* CM2b — also emit each comment as a native PDF `/Text` (sticky-note)
|
|
93
|
+
* annotation at its marker. Opt-in and interactive-only: suppressed under
|
|
94
|
+
* PDF/A and tagged output (where it would need annotation/appearance
|
|
95
|
+
* conformance), since the clickable marker + Comments section already carry
|
|
96
|
+
* the content there.
|
|
97
|
+
*/
|
|
32
98
|
readonly commentAnnotations?: boolean;
|
|
99
|
+
/** Content-addressed binary store; image nodes reference it by {@link ResourceId}. */
|
|
33
100
|
readonly resources?: ResourceStore;
|
|
101
|
+
/**
|
|
102
|
+
* Parsed charts keyed by relationship id (`ChartBlock.chartRelId`). Supplied by
|
|
103
|
+
* the converter, which resolves the chart parts from the package.
|
|
104
|
+
*/
|
|
34
105
|
readonly charts?: ReadonlyMap<string, Chart>;
|
|
35
106
|
readonly pageWidth?: number;
|
|
36
107
|
readonly pageHeight?: number;
|
|
@@ -38,39 +109,130 @@ export interface StyledRenderOptions {
|
|
|
38
109
|
readonly marginRight?: number;
|
|
39
110
|
readonly marginTop?: number;
|
|
40
111
|
readonly marginBottom?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Optional Liang hyphenator. When set, each word token is split at allowed
|
|
114
|
+
* hyphenation positions and offered to Knuth-Plass as potential break points
|
|
115
|
+
* (with a small disincentive). Improves justified paragraph rags.
|
|
116
|
+
*/
|
|
41
117
|
readonly hyphenator?: Hyphenator;
|
|
118
|
+
/**
|
|
119
|
+
* Optional `/Info` dictionary metadata (ISO 32000-1 §14.3.3). Unset fields are
|
|
120
|
+
* omitted; if any field is set a PDF `/Info` entry is emitted.
|
|
121
|
+
*/
|
|
42
122
|
readonly info?: DocumentInfo;
|
|
123
|
+
/**
|
|
124
|
+
* When set, emit a PDF/A-conformant file: an OutputIntent with an embedded
|
|
125
|
+
* sRGB ICC profile, document XMP `/Metadata` (the pdfaid identifier), `/ID`,
|
|
126
|
+
* and subset-tagged fonts with a `/CIDSet`. The profile picks the rest:
|
|
127
|
+
* part 1 → PDF 1.4 + flattened image alpha (no transparency);
|
|
128
|
+
* part 2/3 → PDF 1.7 + preserved transparency (image `/SMask` + page group);
|
|
129
|
+
* part 3 → may carry embedded associated files (see `attachments`);
|
|
130
|
+
* level a → tagged (logical structure); b → visual; u → b + Unicode mapping.
|
|
131
|
+
*/
|
|
43
132
|
readonly pdfA?: PdfALevel;
|
|
133
|
+
/**
|
|
134
|
+
* Emit a tagged PDF (ISO 32000-1 §14.8): a `/StructTreeRoot` describing reading
|
|
135
|
+
* order, marked content (BDC/EMC + MCID) on body text, and `/Artifact` marking
|
|
136
|
+
* of page decoration. Implied by `pdfA: 'PDF/A-1a'`. Independent of PDF/A
|
|
137
|
+
* otherwise (a plain tagged PDF is useful on its own).
|
|
138
|
+
*/
|
|
44
139
|
readonly tagged?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* PDF/UA-1 (ISO 14289-1): implies tagged; the XMP carries `pdfuaid:part=1` and
|
|
142
|
+
* the document always gets a title (AT announces it). Combines freely with
|
|
143
|
+
* `pdfA` level-a profiles.
|
|
144
|
+
*/
|
|
45
145
|
readonly pdfUA?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Document natural language (BCP 47, e.g. `"en-US"`, `"ru-RU"`) for the
|
|
148
|
+
* tagged-PDF catalog `/Lang` (§14.9.2). Defaults to `"en-US"`. The docx
|
|
149
|
+
* converter fills this from the document's default `w:lang`.
|
|
150
|
+
*/
|
|
46
151
|
readonly language?: string;
|
|
152
|
+
/**
|
|
153
|
+
* §7.6 PDF encryption (AES-256, R6). Only honoured on the ASYNC conversion
|
|
154
|
+
* path (WebCrypto); mutually exclusive with `pdfA` (ISO 19005 forbids
|
|
155
|
+
* `/Encrypt`) and with signatures (v1).
|
|
156
|
+
*/
|
|
47
157
|
readonly encrypt?: PdfEncryptOptions;
|
|
158
|
+
/**
|
|
159
|
+
* Files to embed as associated files (catalog `/AF` + `/Names`
|
|
160
|
+
* `/EmbeddedFiles`). Only emitted for plain PDF and PDF/A-3 (PDF/A-1/2 forbid
|
|
161
|
+
* arbitrary embedded files); ignored for PDF/A-1/2. The docx/xlsx converters
|
|
162
|
+
* can embed the source document automatically via `embedSource`.
|
|
163
|
+
*/
|
|
48
164
|
readonly attachments?: ReadonlyArray<AttachedFile>;
|
|
165
|
+
/**
|
|
166
|
+
* Emit an (invisible) signature field + signature dictionary with placeholder
|
|
167
|
+
* `/ByteRange` and `/Contents` (ISO 32000 §12.8). The result is an UNSIGNED
|
|
168
|
+
* PDF; pass it to `signPdf()` to fill the placeholder with a real PKCS#7
|
|
169
|
+
* signature.
|
|
170
|
+
*/
|
|
49
171
|
readonly signaturePlaceholder?: SignaturePlaceholder;
|
|
50
172
|
}
|
|
51
173
|
export type { DocumentInfo } from '../core/document-model/index.js';
|
|
174
|
+
/** A4 page width in points (the page-geometry fallback). */
|
|
52
175
|
export declare const A4_WIDTH = 595;
|
|
176
|
+
/** A4 page height in points (the page-geometry fallback). */
|
|
53
177
|
export declare const A4_HEIGHT = 842;
|
|
178
|
+
/**
|
|
179
|
+
* §17.13.6.2 — a bookmark's GoTo destination: the page (0-based) and the y-up
|
|
180
|
+
* top of the anchoring paragraph's first line.
|
|
181
|
+
*/
|
|
54
182
|
export interface BookmarkPosition {
|
|
55
183
|
readonly pageIdx: number;
|
|
56
184
|
readonly yTopPt: number;
|
|
57
185
|
}
|
|
186
|
+
/** A comment's `/Text` annotation payload: the author and the flattened body (CM2b). */
|
|
58
187
|
export interface CommentNote {
|
|
59
188
|
readonly author?: string;
|
|
60
189
|
readonly contents: string;
|
|
61
190
|
}
|
|
191
|
+
/**
|
|
192
|
+
* PDF-only companion the same layout pass produces (oop-design A13): the
|
|
193
|
+
* logical-structure tree, per-section geometry (the emit fallback page), and the
|
|
194
|
+
* parsed PDF/A profile. Consumed only by `emitStyledPdf`; the SVG writer never
|
|
195
|
+
* sees it.
|
|
196
|
+
*/
|
|
62
197
|
export interface PdfLayoutAux {
|
|
63
198
|
readonly structBuilder: StructTreeBuilder | undefined;
|
|
64
199
|
readonly sectionCtxs: ReadonlyArray<SectionRenderCtx>;
|
|
65
200
|
readonly pdfaProfile: PdfAProfile | undefined;
|
|
66
201
|
readonly tagged: boolean;
|
|
67
202
|
readonly bookmarks: ReadonlyMap<string, BookmarkPosition>;
|
|
203
|
+
/**
|
|
204
|
+
* CM2b — comment marker anchor (`comment-${n}`) → the note the emitter attaches
|
|
205
|
+
* as a `/Text` annotation. Present only when `commentAnnotations` was requested.
|
|
206
|
+
*/
|
|
68
207
|
readonly commentNotes?: ReadonlyMap<string, CommentNote>;
|
|
69
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* What {@link layoutStyledDocument} actually returns: the PageDoc with the PDF
|
|
211
|
+
* companion riding on `pdf`. Assignable to the narrow `LaidOutDocument`, so
|
|
212
|
+
* PageDoc-only consumers (`writeSvg`) take it as-is.
|
|
213
|
+
*/
|
|
70
214
|
export interface LaidOutPdfDocument extends LaidOutDocument {
|
|
71
215
|
readonly pdf: PdfLayoutAux;
|
|
72
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Layout phase (the FlowDoc→PageDoc transform of ir-design §7): body →
|
|
219
|
+
* positioned pages (PageItems), font/image resources, logical structure. Drives
|
|
220
|
+
* the whole pass — numbering and note numbering, per-section geometry, per-block
|
|
221
|
+
* layout, the footnote/endnote/comment tails, then pagination — and returns the
|
|
222
|
+
* {@link LaidOutPdfDocument} (the PageDoc plus its PDF companion).
|
|
223
|
+
*
|
|
224
|
+
* @param body The document body the section model partitions.
|
|
225
|
+
* @param options The resolved fonts, styles, section model, and PDF-output toggles.
|
|
226
|
+
* @returns The positioned pages plus the PDF-only {@link PdfLayoutAux} companion.
|
|
227
|
+
*/
|
|
73
228
|
export declare function layoutStyledDocument(body: ReadonlyArray<BodyElement>, options: StyledRenderOptions): LaidOutPdfDocument;
|
|
229
|
+
/**
|
|
230
|
+
* The resolved page box + header/footer offsets, in points. Priority for page
|
|
231
|
+
* geometry:
|
|
232
|
+
* 1. explicit value in {@link StyledRenderOptions} (test/library caller override)
|
|
233
|
+
* 2. value from section properties (`sectPr/pgSz/pgMar` from the docx)
|
|
234
|
+
* 3. A4 + 1-inch margins fallback
|
|
235
|
+
*/
|
|
74
236
|
export interface PageDimensions {
|
|
75
237
|
readonly pageWidth: number;
|
|
76
238
|
readonly pageHeight: number;
|
|
@@ -81,6 +243,13 @@ export interface PageDimensions {
|
|
|
81
243
|
readonly headerOffsetPt: number;
|
|
82
244
|
readonly footerOffsetPt: number;
|
|
83
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* Per-section render context: the section's exclusive body `endIndex`, its
|
|
248
|
+
* resolved {@link PageDimensions} (flattened), the derived content box, the
|
|
249
|
+
* column geometry, the pre-laid header/footer bands, and the title-page /
|
|
250
|
+
* even-and-odd header toggles. Built once per section and threaded through both
|
|
251
|
+
* layout and pagination.
|
|
252
|
+
*/
|
|
84
253
|
export interface SectionRenderCtx {
|
|
85
254
|
readonly endIndex: number;
|
|
86
255
|
readonly properties: SectionProperties;
|
|
@@ -91,6 +260,12 @@ export interface SectionRenderCtx {
|
|
|
91
260
|
readonly marginBottom: number;
|
|
92
261
|
readonly contentWidth: number;
|
|
93
262
|
readonly pageContentHeight: number;
|
|
263
|
+
/**
|
|
264
|
+
* §17.6.4 multi-column sections: per-column x-offset (from `marginLeft`) and
|
|
265
|
+
* width. Absent for single-column sections. Body blocks are laid out at the
|
|
266
|
+
* FIRST column's width (explicit unequal widths degrade to flowing without
|
|
267
|
+
* re-wrap); headers/footers and footnotes keep the full content width.
|
|
268
|
+
*/
|
|
94
269
|
readonly columns?: ReadonlyArray<{
|
|
95
270
|
readonly xOffsetPt: number;
|
|
96
271
|
readonly widthPt: number;
|
|
@@ -8,6 +8,8 @@ import { segmentLevels } from "../core/bidi/segments.js";
|
|
|
8
8
|
import { analyzeString, hasBidiCharacters } from "../core/bidi/index.js";
|
|
9
9
|
import { FORCED_BREAK, breakLines } from "../core/line-breaker/knuth-plass.js";
|
|
10
10
|
import { greedyBreakLines } from "../core/line-breaker/greedy.js";
|
|
11
|
+
import { cjkBreakBetween, splitCjkSegment } from "../core/line-breaker/cjk.js";
|
|
12
|
+
import "../core/line-breaker/index.js";
|
|
11
13
|
import { applyNumbering, applyNumberingToHeadersFooters } from "../core/numbering/apply.js";
|
|
12
14
|
import { DEFAULT_RESOLVED_PARAGRAPH, DEFAULT_RESOLVED_RUN } from "../core/style-cascade/types.js";
|
|
13
15
|
import { resolveParagraphProperties, resolveRunProperties } from "../core/style-cascade/resolver.js";
|
|
@@ -242,6 +244,17 @@ function commentTailBlocks(comment, n, opts) {
|
|
|
242
244
|
}
|
|
243
245
|
}, ...comment.content];
|
|
244
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Layout phase (the FlowDoc→PageDoc transform of ir-design §7): body →
|
|
249
|
+
* positioned pages (PageItems), font/image resources, logical structure. Drives
|
|
250
|
+
* the whole pass — numbering and note numbering, per-section geometry, per-block
|
|
251
|
+
* layout, the footnote/endnote/comment tails, then pagination — and returns the
|
|
252
|
+
* {@link LaidOutPdfDocument} (the PageDoc plus its PDF companion).
|
|
253
|
+
*
|
|
254
|
+
* @param body The document body the section model partitions.
|
|
255
|
+
* @param options The resolved fonts, styles, section model, and PDF-output toggles.
|
|
256
|
+
* @returns The positioned pages plus the PDF-only {@link PdfLayoutAux} companion.
|
|
257
|
+
*/
|
|
245
258
|
function layoutStyledDocument(body, options) {
|
|
246
259
|
const sectionList = resolveSectionList(body, options);
|
|
247
260
|
const noteAssigned = assignNoteNumbers(applyNumbering(body, options.numbering), options.comments ? new Set(options.comments.keys()) : void 0);
|
|
@@ -1323,15 +1336,20 @@ function tokenizeText(text) {
|
|
|
1323
1336
|
text: m[1],
|
|
1324
1337
|
isSpace: true
|
|
1325
1338
|
});
|
|
1326
|
-
else if (m[2] !== void 0) out.push({
|
|
1327
|
-
text:
|
|
1339
|
+
else if (m[2] !== void 0) for (const piece of splitCjkSegment(m[2])) out.push({
|
|
1340
|
+
text: piece,
|
|
1328
1341
|
isSpace: false
|
|
1329
1342
|
});
|
|
1330
1343
|
return out;
|
|
1331
1344
|
}
|
|
1332
1345
|
var HYPHENATION_PENALTY = 50;
|
|
1346
|
+
function lastCodePoint(s) {
|
|
1347
|
+
const chars = [...s];
|
|
1348
|
+
return chars.length > 0 ? chars[chars.length - 1].codePointAt(0) : 0;
|
|
1349
|
+
}
|
|
1333
1350
|
function paragraphItemStream(tokens, hyphenator) {
|
|
1334
1351
|
const entries = [];
|
|
1352
|
+
let prevBoxEndCp = null;
|
|
1335
1353
|
for (const tok of tokens) {
|
|
1336
1354
|
if (tok.isSpace || tok.kind === "image" || tok.kind === "math") {
|
|
1337
1355
|
entries.push({
|
|
@@ -1346,8 +1364,20 @@ function paragraphItemStream(tokens, hyphenator) {
|
|
|
1346
1364
|
},
|
|
1347
1365
|
token: tok
|
|
1348
1366
|
});
|
|
1367
|
+
prevBoxEndCp = null;
|
|
1349
1368
|
continue;
|
|
1350
1369
|
}
|
|
1370
|
+
const startCp = tok.text.codePointAt(0) ?? 0;
|
|
1371
|
+
if (prevBoxEndCp !== null && cjkBreakBetween(prevBoxEndCp, startCp)) entries.push({
|
|
1372
|
+
item: {
|
|
1373
|
+
type: "penalty",
|
|
1374
|
+
width: 0,
|
|
1375
|
+
penalty: 0,
|
|
1376
|
+
flagged: false
|
|
1377
|
+
},
|
|
1378
|
+
token: null
|
|
1379
|
+
});
|
|
1380
|
+
prevBoxEndCp = lastCodePoint(tok.text);
|
|
1351
1381
|
const positions = hyphenator ? hyphenator.hyphenate(tok.text) : [];
|
|
1352
1382
|
if (positions.length === 0) {
|
|
1353
1383
|
entries.push({
|
|
@@ -1837,7 +1867,23 @@ function listItemParagraphNode(builder, stack, list, wantLbl) {
|
|
|
1837
1867
|
...lblId !== void 0 ? { lblId } : {}
|
|
1838
1868
|
};
|
|
1839
1869
|
}
|
|
1870
|
+
/**
|
|
1871
|
+
* A9 (oop-design §4.3): the page-assembly state machine, extracted verbatim from
|
|
1872
|
+
* `paginateSections`. One instance assembles all pages of a document: fields are
|
|
1873
|
+
* the former local state, methods the former closures — the block loop drives it.
|
|
1874
|
+
* Push order into `current`/`pages` IS the byte order of the emitted PDF, so the
|
|
1875
|
+
* bodies move unchanged.
|
|
1876
|
+
*/
|
|
1840
1877
|
var PageAssembler = class {
|
|
1878
|
+
/**
|
|
1879
|
+
* @param sectionCtxs The per-section render contexts, in order; assembly
|
|
1880
|
+
* starts on the first section's first page.
|
|
1881
|
+
* @param builder The tagged-PDF structure builder, or `undefined` for
|
|
1882
|
+
* untagged output.
|
|
1883
|
+
* @param notes The footnote plan (lazy per-section layout), or
|
|
1884
|
+
* `undefined` when there are none.
|
|
1885
|
+
* @param bookmarkPositions Out-param: bookmark name → its GoTo destination.
|
|
1886
|
+
*/
|
|
1841
1887
|
constructor(sectionCtxs, builder, notes, bookmarkPositions) {
|
|
1842
1888
|
this.sectionCtxs = sectionCtxs;
|
|
1843
1889
|
this.builder = builder;
|
|
@@ -1854,11 +1900,21 @@ var PageAssembler = class {
|
|
|
1854
1900
|
current = [];
|
|
1855
1901
|
pendingPageBreak = false;
|
|
1856
1902
|
cursorY;
|
|
1903
|
+
/**
|
|
1904
|
+
* §17.6.4 multi-column flow: content fills column after column before the page
|
|
1905
|
+
* flushes. `colStartLen` marks where the current column's items begin in
|
|
1906
|
+
* `current` — the single-column "page has content" guard generalizes to "this
|
|
1907
|
+
* column has content" (identical when there is one column).
|
|
1908
|
+
*/
|
|
1857
1909
|
colIdx = 0;
|
|
1858
1910
|
colStartLen = 0;
|
|
1911
|
+
/** The current column's left edge (`marginLeft` plus the column x-offset). */
|
|
1859
1912
|
colLeft = () => this.ctx.marginLeft + (this.ctx.columns?.[this.colIdx]?.xOffsetPt ?? 0);
|
|
1913
|
+
/** The current column's width (the section content width when single-column). */
|
|
1860
1914
|
colWidth = () => this.ctx.columns?.[this.colIdx]?.widthPt ?? this.ctx.contentWidth;
|
|
1915
|
+
/** Whether the current column has received any items yet. */
|
|
1861
1916
|
colHasContent = () => this.current.length > this.colStartLen;
|
|
1917
|
+
/** Overflow step: next column on this page, or a fresh page after the last. */
|
|
1862
1918
|
advanceColumn = () => {
|
|
1863
1919
|
if (this.ctx.columns && this.colIdx + 1 < this.ctx.columns.length) {
|
|
1864
1920
|
this.colIdx++;
|
|
@@ -1866,9 +1922,19 @@ var PageAssembler = class {
|
|
|
1866
1922
|
this.cursorY = this.ctx.pageHeight - this.ctx.marginTop;
|
|
1867
1923
|
} else this.flushPage();
|
|
1868
1924
|
};
|
|
1925
|
+
/**
|
|
1926
|
+
* §20.4.2.3 out-of-flow drawings (wrap `'none'`): they render at their anchored
|
|
1927
|
+
* position without moving the cursor. `behindDoc` sinks below the body text,
|
|
1928
|
+
* everything else above it; both flush with the page.
|
|
1929
|
+
*/
|
|
1869
1930
|
floatsBehind = [];
|
|
1870
1931
|
floatsFront = [];
|
|
1932
|
+
/**
|
|
1933
|
+
* Side-wrapping floats (wrapSquare/tight/through): rectangles the body text
|
|
1934
|
+
* must flow around. Page-scoped, like the float graphics.
|
|
1935
|
+
*/
|
|
1871
1936
|
exclusions = [];
|
|
1937
|
+
/** The float's left edge on the page, resolved from its horizontal anchor. */
|
|
1872
1938
|
floatX = (f, widthPt) => {
|
|
1873
1939
|
const h = f.posH;
|
|
1874
1940
|
if (!h) return this.colLeft();
|
|
@@ -1878,6 +1944,10 @@ var PageAssembler = class {
|
|
|
1878
1944
|
if (h.align === "right") return base + span - widthPt;
|
|
1879
1945
|
return base + (h.offsetPt ?? 0);
|
|
1880
1946
|
};
|
|
1947
|
+
/**
|
|
1948
|
+
* The drawing's TOP in the y-up cursor frame. Paragraph/line-relative offsets
|
|
1949
|
+
* hang off the anchoring paragraph's current position.
|
|
1950
|
+
*/
|
|
1881
1951
|
floatTopYUp = (f) => {
|
|
1882
1952
|
const v = f.posV;
|
|
1883
1953
|
if (!v) return this.cursorY;
|
|
@@ -1885,11 +1955,26 @@ var PageAssembler = class {
|
|
|
1885
1955
|
if (v.relativeFrom === "margin") return this.ctx.pageHeight - this.ctx.marginTop - (v.offsetPt ?? 0);
|
|
1886
1956
|
return this.cursorY - (v.offsetPt ?? 0);
|
|
1887
1957
|
};
|
|
1958
|
+
/**
|
|
1959
|
+
* Tagged PDF: the stack of open list levels (for L/LI/LBody nesting). Cleared
|
|
1960
|
+
* whenever a non-list-item block interrupts the run of list paragraphs.
|
|
1961
|
+
*/
|
|
1888
1962
|
listStack = [];
|
|
1963
|
+
/**
|
|
1964
|
+
* §17.11 footnotes: `pageNotes` reserved for the CURRENT page (greedy — a line
|
|
1965
|
+
* carrying a reference pulls its note's height out of the page bottom, so the
|
|
1966
|
+
* line and its note land together). `placedNotes` is global: a note renders
|
|
1967
|
+
* once, on its first reference's page.
|
|
1968
|
+
*/
|
|
1889
1969
|
pageNotes = [];
|
|
1890
1970
|
noteReserve = 0;
|
|
1891
1971
|
placedNotes = /* @__PURE__ */ new Set();
|
|
1972
|
+
/** The page's usable bottom: the margin plus whatever the notes band has claimed so far. */
|
|
1892
1973
|
bottomLimit = () => this.ctx.marginBottom + this.noteReserve;
|
|
1974
|
+
/**
|
|
1975
|
+
* The first exclusion a line spanning `[yTop-h, yTop]` collides with in the
|
|
1976
|
+
* current column (x-overlap with the column required).
|
|
1977
|
+
*/
|
|
1893
1978
|
exclusionAt = (yTop, h) => {
|
|
1894
1979
|
const cl = this.colLeft();
|
|
1895
1980
|
const cr = cl + this.colWidth();
|
|
@@ -1899,6 +1984,10 @@ var PageAssembler = class {
|
|
|
1899
1984
|
return e;
|
|
1900
1985
|
}
|
|
1901
1986
|
};
|
|
1987
|
+
/**
|
|
1988
|
+
* Per-line geometry beside an exclusion: the narrowed width and the x shift.
|
|
1989
|
+
* Text goes on the WIDER side of the float (one side per line, v1).
|
|
1990
|
+
*/
|
|
1902
1991
|
lineGeometryAt = (yTop, h) => {
|
|
1903
1992
|
const full = this.colWidth();
|
|
1904
1993
|
const e = this.exclusionAt(yTop, h);
|
|
@@ -1921,6 +2010,12 @@ var PageAssembler = class {
|
|
|
1921
2010
|
xOffset: 0
|
|
1922
2011
|
};
|
|
1923
2012
|
};
|
|
2013
|
+
/**
|
|
2014
|
+
* Estimated per-line widths for a paragraph starting at `startY`: narrowed
|
|
2015
|
+
* while lines (estimated at the first line's height) overlap an exclusion, then
|
|
2016
|
+
* one full width Knuth-Plass reuses for the tail. `undefined` when nothing
|
|
2017
|
+
* overlaps — the caller keeps the original block.
|
|
2018
|
+
*/
|
|
1924
2019
|
lineWidthsFor = (block, startY) => {
|
|
1925
2020
|
if (this.exclusions.length === 0 || block.lines.length === 0) return void 0;
|
|
1926
2021
|
const h0 = computeLineHeight(block.lines[0], block.resolved);
|
|
@@ -1938,6 +2033,10 @@ var PageAssembler = class {
|
|
|
1938
2033
|
}
|
|
1939
2034
|
return narrowed ? widths : void 0;
|
|
1940
2035
|
};
|
|
2036
|
+
/**
|
|
2037
|
+
* New (unplaced) footnotes referenced by a line's tokens, with their layout at
|
|
2038
|
+
* the current section's width.
|
|
2039
|
+
*/
|
|
1941
2040
|
lineFootnotes = (line) => {
|
|
1942
2041
|
if (!this.notes) return [];
|
|
1943
2042
|
const out = [];
|
|
@@ -1957,6 +2056,10 @@ var PageAssembler = class {
|
|
|
1957
2056
|
}
|
|
1958
2057
|
return out;
|
|
1959
2058
|
};
|
|
2059
|
+
/**
|
|
2060
|
+
* The notes band for the flushing page: separator rule + each note's blocks
|
|
2061
|
+
* stacked inside the reserved area. Tagged: each note is a Note→P element.
|
|
2062
|
+
*/
|
|
1960
2063
|
renderNotesBand = () => {
|
|
1961
2064
|
if (this.pageNotes.length === 0) return [];
|
|
1962
2065
|
const out = [];
|
|
@@ -1981,7 +2084,19 @@ var PageAssembler = class {
|
|
|
1981
2084
|
}
|
|
1982
2085
|
return out;
|
|
1983
2086
|
};
|
|
2087
|
+
/**
|
|
2088
|
+
* Dynamic PAGE/NUMPAGES bands re-render after pagination (both numbers are
|
|
2089
|
+
* known only then); each use records where its commands must be spliced.
|
|
2090
|
+
*/
|
|
1984
2091
|
dynBands = [];
|
|
2092
|
+
/**
|
|
2093
|
+
* Finish the in-progress page: pick the header/footer band, queue any dynamic
|
|
2094
|
+
* band, push the assembled commands as a page, then reset all per-page state
|
|
2095
|
+
* (cursor, floats, exclusions, notes, columns) for the next one.
|
|
2096
|
+
*
|
|
2097
|
+
* @param force Emit a page even when no body content was placed (used to
|
|
2098
|
+
* guarantee one page for a header/footer-only document).
|
|
2099
|
+
*/
|
|
1985
2100
|
flushPage = (force = false) => {
|
|
1986
2101
|
if (this.current.length === 0 && !force) return;
|
|
1987
2102
|
const band = bandForPage(this.pageInSection, this.globalPageIdx, this.ctx.titlePg, this.ctx.evenAndOddHeaders);
|