reamkit 1.33.1 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +13 -10
  2. package/dist/esm/core/converter/facade.js +1 -0
  3. package/dist/esm/core/converter/ream.d.ts +6 -6
  4. package/dist/esm/core/converter/ream.js +11 -5
  5. package/dist/esm/core/crypto/index.js +1 -2
  6. package/dist/esm/core/document-model/index.d.ts +1 -1
  7. package/dist/esm/core/document-model/types.d.ts +15 -0
  8. package/dist/esm/core/drawingml/text-warp.d.ts +34 -0
  9. package/dist/esm/core/drawingml/text-warp.js +49 -1
  10. package/dist/esm/core/font/index.d.ts +1 -1
  11. package/dist/esm/core/font/index.js +8 -0
  12. package/dist/esm/core/font/indic-shaper.d.ts +47 -0
  13. package/dist/esm/core/font/indic-shaper.js +1146 -0
  14. package/dist/esm/core/font/indic-table.d.ts +12 -0
  15. package/dist/esm/core/font/indic-table.js +463 -0
  16. package/dist/esm/core/font/measure.d.ts +45 -4
  17. package/dist/esm/core/font/measure.js +253 -14
  18. package/dist/esm/core/font/opentype-lookups.d.ts +214 -0
  19. package/dist/esm/core/font/opentype-lookups.js +1112 -0
  20. package/dist/esm/core/fonts/families.d.ts +4 -0
  21. package/dist/esm/core/fonts/families.js +43 -12
  22. package/dist/esm/core/fonts/provider.js +1 -0
  23. package/dist/esm/core/fonts/remote-fonts.d.ts +4 -2
  24. package/dist/esm/core/fonts/remote-fonts.js +36 -0
  25. package/dist/esm/core/fonts/scripts.d.ts +19 -0
  26. package/dist/esm/core/fonts/scripts.js +96 -1
  27. package/dist/esm/core/numbering/apply.js +12 -8
  28. package/dist/esm/core/style-cascade/index.d.ts +1 -1
  29. package/dist/esm/core/style-cascade/index.js +2 -2
  30. package/dist/esm/core/style-cascade/resolver.d.ts +9 -0
  31. package/dist/esm/core/style-cascade/resolver.js +31 -3
  32. package/dist/esm/core/style-cascade/table.js +3 -8
  33. package/dist/esm/excel/xlsx-to-pdf.js +1 -0
  34. package/dist/esm/index.js +1 -0
  35. package/dist/esm/layout/line-paint.d.ts +5 -4
  36. package/dist/esm/layout/line-paint.js +6 -5
  37. package/dist/esm/layout/page-doc.d.ts +26 -0
  38. package/dist/esm/layout/styled-layout.d.ts +8 -1
  39. package/dist/esm/layout/styled-layout.js +459 -112
  40. package/dist/esm/layout/undrawn.d.ts +18 -0
  41. package/dist/esm/layout/undrawn.js +59 -0
  42. package/dist/esm/pdf/cid-font.d.ts +5 -0
  43. package/dist/esm/pdf/cid-font.js +8 -2
  44. package/dist/esm/pdf/styled-page-emitter.js +117 -28
  45. package/dist/esm/pdf/text-page-renderer.js +1 -0
  46. package/dist/esm/pdf-reader/content.d.ts +1 -1
  47. package/dist/esm/pdf-reader/content.js +48 -13
  48. package/dist/esm/pdf-reader/embedded-fonts.js +1 -0
  49. package/dist/esm/pdf-reader/encodings.d.ts +9 -0
  50. package/dist/esm/pdf-reader/encodings.js +66 -1
  51. package/dist/esm/pdf-reader/face-outlines.js +1 -0
  52. package/dist/esm/pdf-reader/text.d.ts +10 -0
  53. package/dist/esm/pdf-reader/text.js +25 -3
  54. package/dist/esm/pdf-reader/vector.js +2 -2
  55. package/dist/esm/pptx/embedded-fonts.js +1 -0
  56. package/dist/esm/pptx/slide-parser.js +22 -7
  57. package/dist/esm/pptx/sp-helpers.d.ts +3 -2
  58. package/dist/esm/pptx/sp-helpers.js +9 -4
  59. package/dist/esm/svg/svg-text.js +30 -7
  60. package/dist/esm/word/doc/doc-reader.js +148 -57
  61. package/dist/esm/word/doc/doc-text.d.ts +80 -11
  62. package/dist/esm/word/doc/doc-text.js +438 -75
  63. package/dist/esm/word/document-parser.js +48 -28
  64. package/dist/esm/word/docx-to-pdf.d.ts +5 -5
  65. package/dist/esm/word/docx-to-pdf.js +9 -7
  66. package/dist/esm/word/docx-writer.js +3 -5
  67. package/dist/esm/word/font-embed.js +1 -0
  68. package/dist/esm/word/font-table.js +1 -0
  69. package/dist/esm/word/numbering-parser.js +3 -0
  70. package/dist/esm/word/paragraph-properties.js +2 -2
  71. package/dist/esm/word/run-properties.js +2 -2
  72. package/dist/esm/word/xml-helpers.d.ts +18 -0
  73. package/dist/esm/word/xml-helpers.js +48 -1
  74. package/package.json +3 -3
@@ -6,6 +6,14 @@ export interface DocCharProps {
6
6
  readonly underlineKul?: number;
7
7
  /** Font size in half-points. */
8
8
  readonly sizeHalfPts?: number;
9
+ /** The font of ASCII characters, by name — `sprmCRgFtc0`. */
10
+ readonly fontAscii?: string;
11
+ /** The font of East Asian characters — `sprmCRgFtc1`. */
12
+ readonly fontEastAsia?: string;
13
+ /** The font of the characters neither ASCII nor East Asian — `sprmCRgFtc2`. */
14
+ readonly fontOther?: string;
15
+ /** The font of complex-script characters — `sprmCFtcBi`. */
16
+ readonly fontBi?: string;
9
17
  /** The character is special — `sprmCFSpec` (e.g. a picture placeholder). */
10
18
  readonly fSpec?: boolean;
11
19
  /** `sprmCPicLocation` — offset into the `Data` stream of the picture's PICF. */
@@ -80,6 +88,8 @@ export interface DocParaProps {
80
88
  readonly keepNext?: boolean;
81
89
  /** `sprmPFKeep` — every line on one page. */
82
90
  readonly keepLines?: boolean;
91
+ /** `sprmPFPageBreakBefore` — the paragraph starts a new page. */
92
+ readonly pageBreakBefore?: boolean;
83
93
  }
84
94
  /** One maximal same-formatting run of text, or an embedded picture. */
85
95
  export interface DocRun {
@@ -87,6 +97,15 @@ export interface DocRun {
87
97
  readonly props: DocCharProps;
88
98
  /** Set instead of `text` when the run is an embedded picture. */
89
99
  readonly picture?: DocPicture;
100
+ /** The run is a manual page break (0x0C), alone in a run with no text. */
101
+ readonly pageBreak?: boolean;
102
+ /** The run is a manual column break (0x0E), alone in a run whose text is `\n`. */
103
+ readonly columnBreak?: boolean;
104
+ /**
105
+ * The run is the result of a PAGE or NUMPAGES field, whose `text` is the
106
+ * number Word cached when it last saved.
107
+ */
108
+ readonly field?: 'PAGE' | 'NUMPAGES';
90
109
  }
91
110
  /** One paragraph: its runs plus the decoded paragraph properties. */
92
111
  export interface DocParagraph {
@@ -97,11 +116,59 @@ export interface DocParagraph {
97
116
  * closes a table cell. With `props.rowEnd` it also closes the row.
98
117
  */
99
118
  readonly cellMark?: boolean;
119
+ /**
120
+ * The paragraph was ended by the section mark of the (zero-based) section it
121
+ * is the last of — the index into {@link DocContent.sections}.
122
+ */
123
+ readonly sectionEnd?: number;
124
+ /** The paragraph mark's own character properties: what an empty line is set in. */
125
+ readonly mark?: DocCharProps;
126
+ }
127
+ /** One section of the main document (§2.8.26 PlcfSed): what its SEP says. */
128
+ export interface DocSection {
129
+ /**
130
+ * `sprmSBkc` — where the section starts: 0 on the page in hand, 1 in the next
131
+ * column, 2 on a new page, 3 on an even page, 4 on an odd page. Absent when
132
+ * the SEP says nothing, which is a new page.
133
+ */
134
+ readonly bkc?: number;
135
+ /** The page size in points (xaPage/yaPage), when present and sane. */
136
+ readonly pageSize?: {
137
+ readonly widthPt: number;
138
+ readonly heightPt: number;
139
+ };
140
+ /** `sprmSFTitlePage` — the first page shows the first-page header and footer. */
141
+ readonly titlePage?: boolean;
142
+ /** The margins the SEP states, in twips; each absent one is Word's default. */
143
+ readonly margins?: DocMargins;
144
+ /**
145
+ * `sprmSFPgnRestart` with `sprmSPgnStart97` — the number the section's first
146
+ * page is printed with, when the section starts its count again; absent, the
147
+ * count runs on from the section before.
148
+ */
149
+ readonly pageNumberStart?: number;
150
+ /** `sprmSNfcPgn` — the MSONFC the section's page numbers print in; absent, arabic. */
151
+ readonly pageNumberNfc?: number;
152
+ }
153
+ /**
154
+ * A section's margins in twips (§2.6.4 sprmSDxaLeft … sprmSDzaGutter). A top or
155
+ * bottom margin is stored signed, negative for one the header or footer may not
156
+ * push; its size is the same either way.
157
+ */
158
+ export interface DocMargins {
159
+ readonly leftTwips?: number;
160
+ readonly rightTwips?: number;
161
+ readonly topTwips?: number;
162
+ readonly bottomTwips?: number;
163
+ readonly headerTwips?: number;
164
+ readonly footerTwips?: number;
165
+ readonly gutterTwips?: number;
100
166
  }
101
167
  /**
102
- * The section's header/footer stories (best-effort: the binary story ordering
103
- * cannot be validated against a real file, so only well-formed, non-empty stories
104
- * are surfaced). `default` is the odd-page (primary) header/footer.
168
+ * One section's header/footer stories ([MS-DOC] Plcfhdd: six per section, after
169
+ * the six separator stories). `default` is the odd-page (primary) one. A story
170
+ * the section leaves empty is the previous section's, the very same array; one
171
+ * that holds no text is absent.
105
172
  */
106
173
  export interface DocHeaderFooters {
107
174
  readonly defaultHeader?: ReadonlyArray<DocParagraph>;
@@ -121,6 +188,8 @@ export interface DocLvl {
121
188
  readonly nfc: number;
122
189
  readonly iStartAt: number;
123
190
  readonly xst: ReadonlyArray<number>;
191
+ /** `ixchFollow` — what follows the number text: 0 a tab, 1 a space, 2 nothing. */
192
+ readonly follow: number;
124
193
  }
125
194
  /**
126
195
  * The document's list tables (DOC-10): an LFO → lsid map (a paragraph's 1-based
@@ -136,23 +205,23 @@ export interface DocListTables {
136
205
  /** Everything extracted from a `.doc`'s `WordDocument` stream. */
137
206
  export interface DocContent {
138
207
  readonly paragraphs: ReadonlyArray<DocParagraph>;
139
- readonly headerFooters?: DocHeaderFooters;
208
+ /** Each section's header/footer stories, in section order. */
209
+ readonly headerFooters?: ReadonlyArray<DocHeaderFooters>;
210
+ /** `Dop.fFacingPages` — even pages show the even header and footer. */
211
+ readonly facingPages?: boolean;
140
212
  /** The list tables resolving a paragraph's (ilfo, ilvl) to its number format. */
141
213
  readonly listTables?: DocListTables;
142
214
  /**
143
- * The first section's page size in points (xaPage/yaPage from its SEP), when
144
- * present and sane; absent ⇒ the reader's default (US Letter) applies.
215
+ * Every section of the main document, in order, when the PlcfSed is usable. A
216
+ * section with no page size takes the reader's default (US Letter).
145
217
  */
146
- readonly pageSize?: {
147
- readonly widthPt: number;
148
- readonly heightPt: number;
149
- };
218
+ readonly sections?: ReadonlyArray<DocSection>;
150
219
  /** The file is encrypted/obfuscated — text cannot be read without the key. */
151
220
  readonly encrypted: boolean;
152
221
  }
153
222
  /**
154
223
  * Extract a `.doc`'s `WordDocument` stream into its main-document paragraphs plus
155
- * the section's header/footer stories, list tables and first-section page size.
224
+ * the section's header/footer stories, list tables and sections.
156
225
  * Joins the piece table (CLX → CPs/FCs), CHPX run formatting and PAPX paragraph
157
226
  * formatting, splitting at the CR / cell marks. Every offset is bounds-checked, so
158
227
  * a structurally odd file yields no text rather than throwing.