reamkit 1.15.1 → 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.
Files changed (316) hide show
  1. package/dist/esm/core/arc-to-bezier.d.ts +23 -0
  2. package/dist/esm/core/arc-to-bezier.js +23 -0
  3. package/dist/esm/core/bidi/algorithm.d.ts +26 -0
  4. package/dist/esm/core/bidi/algorithm.js +21 -0
  5. package/dist/esm/core/bidi/char-types.d.ts +17 -0
  6. package/dist/esm/core/bidi/char-types.js +10 -0
  7. package/dist/esm/core/bidi/index.d.ts +42 -0
  8. package/dist/esm/core/bidi/index.js +27 -0
  9. package/dist/esm/core/bidi/segments.d.ts +22 -0
  10. package/dist/esm/core/bidi/segments.js +14 -0
  11. package/dist/esm/core/bytes.d.ts +9 -0
  12. package/dist/esm/core/bytes.js +9 -0
  13. package/dist/esm/core/converter/facade.d.ts +38 -1
  14. package/dist/esm/core/converter/facade.js +25 -0
  15. package/dist/esm/core/converter/project.d.ts +12 -0
  16. package/dist/esm/core/converter/project.js +11 -0
  17. package/dist/esm/core/converter/ream.d.ts +107 -0
  18. package/dist/esm/core/converter/ream.js +76 -0
  19. package/dist/esm/core/crypto/asn1.d.ts +77 -0
  20. package/dist/esm/core/crypto/asn1.js +65 -0
  21. package/dist/esm/core/crypto/cms.d.ts +25 -0
  22. package/dist/esm/core/crypto/cms.js +8 -0
  23. package/dist/esm/core/document-model/index.d.ts +7 -0
  24. package/dist/esm/core/document-model/types.d.ts +328 -0
  25. package/dist/esm/core/drawingml/chart-geometry.d.ts +125 -0
  26. package/dist/esm/core/drawingml/chart-geometry.js +96 -0
  27. package/dist/esm/core/drawingml/chart-parser.d.ts +34 -0
  28. package/dist/esm/core/drawingml/chart-parser.js +34 -0
  29. package/dist/esm/core/drawingml/chart-serializer.d.ts +12 -0
  30. package/dist/esm/core/drawingml/chart-serializer.js +12 -0
  31. package/dist/esm/core/drawingml/colors.d.ts +53 -0
  32. package/dist/esm/core/drawingml/colors.js +41 -0
  33. package/dist/esm/core/drawingml/preset-geometry.d.ts +30 -0
  34. package/dist/esm/core/drawingml/preset-geometry.js +30 -0
  35. package/dist/esm/core/drawingml/shape-render.d.ts +54 -0
  36. package/dist/esm/core/drawingml/shape-render.js +54 -0
  37. package/dist/esm/core/drawingml/sparkline-geometry.d.ts +15 -0
  38. package/dist/esm/core/drawingml/sparkline-geometry.js +13 -0
  39. package/dist/esm/core/drawingml/theme-parser.d.ts +11 -0
  40. package/dist/esm/core/drawingml/theme-parser.js +11 -0
  41. package/dist/esm/core/font/arabic-joining.d.ts +21 -0
  42. package/dist/esm/core/font/arabic-joining.js +16 -0
  43. package/dist/esm/core/font/binary-reader.d.ts +17 -0
  44. package/dist/esm/core/font/binary-reader.js +17 -0
  45. package/dist/esm/core/font/font-registry.d.ts +37 -0
  46. package/dist/esm/core/font/font-registry.js +31 -0
  47. package/dist/esm/core/font/measure.d.ts +20 -0
  48. package/dist/esm/core/font/measure.js +11 -0
  49. package/dist/esm/core/font/opentype-layout.d.ts +49 -0
  50. package/dist/esm/core/font/opentype-layout.js +37 -0
  51. package/dist/esm/core/font/ttf-parser.d.ts +32 -0
  52. package/dist/esm/core/font/ttf-parser.js +7 -0
  53. package/dist/esm/core/font/ttf-subset.d.ts +21 -0
  54. package/dist/esm/core/font/ttf-subset.js +21 -0
  55. package/dist/esm/core/fonts/provider.d.ts +8 -1
  56. package/dist/esm/core/fonts/provider.js +1 -0
  57. package/dist/esm/core/fonts/remote-fonts.d.ts +22 -0
  58. package/dist/esm/core/fonts/remote-fonts.js +16 -0
  59. package/dist/esm/core/hyphenation/index.d.ts +25 -0
  60. package/dist/esm/core/hyphenation/index.js +17 -0
  61. package/dist/esm/core/hyphenation/liang.d.ts +27 -0
  62. package/dist/esm/core/hyphenation/liang.js +14 -0
  63. package/dist/esm/core/images.d.ts +32 -0
  64. package/dist/esm/core/images.js +12 -0
  65. package/dist/esm/core/ir/adapters.d.ts +23 -0
  66. package/dist/esm/core/ir/features.d.ts +8 -0
  67. package/dist/esm/core/ir/features.js +1 -0
  68. package/dist/esm/core/ir/flow.d.ts +20 -0
  69. package/dist/esm/core/ir/index.d.ts +7 -0
  70. package/dist/esm/core/ir/loss.d.ts +12 -0
  71. package/dist/esm/core/ir/loss.js +8 -0
  72. package/dist/esm/core/ir/resources.d.ts +12 -0
  73. package/dist/esm/core/ir/resources.js +11 -0
  74. package/dist/esm/core/ir/sheet.d.ts +81 -0
  75. package/dist/esm/core/ir/units.d.ts +9 -0
  76. package/dist/esm/core/ir/units.js +2 -0
  77. package/dist/esm/core/line-breaker/cjk.d.ts +26 -0
  78. package/dist/esm/core/line-breaker/cjk.js +60 -0
  79. package/dist/esm/core/line-breaker/greedy.d.ts +14 -0
  80. package/dist/esm/core/line-breaker/greedy.js +14 -0
  81. package/dist/esm/core/line-breaker/index.d.ts +1 -0
  82. package/dist/esm/core/line-breaker/index.js +3 -0
  83. package/dist/esm/core/line-breaker/knuth-plass.d.ts +29 -5
  84. package/dist/esm/core/line-breaker/knuth-plass.js +10 -5
  85. package/dist/esm/core/numbering/apply.d.ts +19 -0
  86. package/dist/esm/core/numbering/apply.js +19 -0
  87. package/dist/esm/core/numbering/state.d.ts +15 -0
  88. package/dist/esm/core/numbering/state.js +15 -0
  89. package/dist/esm/core/ole/cfb.d.ts +19 -0
  90. package/dist/esm/core/ole/cfb.js +16 -0
  91. package/dist/esm/core/opc/core-properties.d.ts +12 -0
  92. package/dist/esm/core/opc/core-properties.js +5 -0
  93. package/dist/esm/core/opc/opc-writer.d.ts +24 -4
  94. package/dist/esm/core/opc/opc-writer.js +12 -0
  95. package/dist/esm/core/opc/package.d.ts +55 -0
  96. package/dist/esm/core/opc/package.js +46 -0
  97. package/dist/esm/core/opc/relationship-types.d.ts +8 -0
  98. package/dist/esm/core/opc/relationship-types.js +5 -0
  99. package/dist/esm/core/opc/relationships.d.ts +12 -0
  100. package/dist/esm/core/opc/relationships.js +7 -0
  101. package/dist/esm/core/po-helpers.d.ts +38 -0
  102. package/dist/esm/core/po-helpers.js +33 -0
  103. package/dist/esm/core/spreadsheet-model/types.d.ts +281 -0
  104. package/dist/esm/core/style-cascade/resolver.d.ts +31 -0
  105. package/dist/esm/core/style-cascade/resolver.js +31 -0
  106. package/dist/esm/core/style-cascade/table.d.ts +7 -0
  107. package/dist/esm/core/style-cascade/table.js +7 -0
  108. package/dist/esm/core/style-cascade/types.d.ts +27 -0
  109. package/dist/esm/core/style-cascade/types.js +2 -0
  110. package/dist/esm/core/vector.d.ts +67 -0
  111. package/dist/esm/core/vector.js +23 -0
  112. package/dist/esm/excel/activex-parser.d.ts +31 -0
  113. package/dist/esm/excel/activex-parser.js +24 -0
  114. package/dist/esm/excel/cell-reference.d.ts +14 -0
  115. package/dist/esm/excel/cell-reference.js +9 -0
  116. package/dist/esm/excel/column-bands.d.ts +29 -0
  117. package/dist/esm/excel/column-bands.js +26 -0
  118. package/dist/esm/excel/comments-parser.d.ts +19 -0
  119. package/dist/esm/excel/comments-parser.js +19 -0
  120. package/dist/esm/excel/conditional-format.d.ts +38 -0
  121. package/dist/esm/excel/conditional-format.js +25 -0
  122. package/dist/esm/excel/defined-name-ref.d.ts +21 -0
  123. package/dist/esm/excel/defined-name-ref.js +20 -0
  124. package/dist/esm/excel/form-control-parser.d.ts +13 -0
  125. package/dist/esm/excel/form-control-parser.js +5 -0
  126. package/dist/esm/excel/formula/context.d.ts +37 -0
  127. package/dist/esm/excel/formula/dates.d.ts +23 -0
  128. package/dist/esm/excel/formula/dates.js +20 -0
  129. package/dist/esm/excel/formula/eval.d.ts +21 -0
  130. package/dist/esm/excel/formula/eval.js +11 -0
  131. package/dist/esm/excel/formula/functions.d.ts +12 -0
  132. package/dist/esm/excel/formula/functions.js +12 -0
  133. package/dist/esm/excel/formula/index.d.ts +21 -0
  134. package/dist/esm/excel/formula/index.js +16 -0
  135. package/dist/esm/excel/formula/lexer.d.ts +12 -0
  136. package/dist/esm/excel/formula/lexer.js +10 -0
  137. package/dist/esm/excel/formula/parser.d.ts +20 -0
  138. package/dist/esm/excel/formula/parser.js +53 -0
  139. package/dist/esm/excel/formula/value.d.ts +53 -0
  140. package/dist/esm/excel/formula/value.js +30 -0
  141. package/dist/esm/excel/header-footer.d.ts +9 -0
  142. package/dist/esm/excel/header-footer.js +9 -0
  143. package/dist/esm/excel/number-format.d.ts +34 -0
  144. package/dist/esm/excel/number-format.js +34 -0
  145. package/dist/esm/excel/pivot-table-parser.d.ts +8 -0
  146. package/dist/esm/excel/pivot-table-parser.js +8 -0
  147. package/dist/esm/excel/print-model.d.ts +56 -0
  148. package/dist/esm/excel/print-model.js +43 -0
  149. package/dist/esm/excel/shared-strings-parser.d.ts +13 -0
  150. package/dist/esm/excel/shared-strings-parser.js +5 -0
  151. package/dist/esm/excel/sheet-drawing.d.ts +34 -0
  152. package/dist/esm/excel/sheet-drawing.js +21 -0
  153. package/dist/esm/excel/sheet-shape-parser.d.ts +12 -0
  154. package/dist/esm/excel/sheet-shape-parser.js +12 -0
  155. package/dist/esm/excel/sheet-to-flow.d.ts +19 -0
  156. package/dist/esm/excel/sheet-to-flow.js +10 -0
  157. package/dist/esm/excel/slicer-parser.d.ts +23 -0
  158. package/dist/esm/excel/slicer-parser.js +10 -0
  159. package/dist/esm/excel/styles-parser.d.ts +8 -0
  160. package/dist/esm/excel/styles-parser.js +8 -0
  161. package/dist/esm/excel/table-parser.d.ts +24 -0
  162. package/dist/esm/excel/table-parser.js +5 -0
  163. package/dist/esm/excel/workbook-parser.d.ts +17 -0
  164. package/dist/esm/excel/workbook-parser.js +5 -0
  165. package/dist/esm/excel/worksheet-parser.d.ts +9 -0
  166. package/dist/esm/excel/worksheet-parser.js +9 -0
  167. package/dist/esm/excel/xls/biff-chart.d.ts +10 -0
  168. package/dist/esm/excel/xls/biff-chart.js +10 -0
  169. package/dist/esm/excel/xls/biff-reader.d.ts +27 -0
  170. package/dist/esm/excel/xls/biff-reader.js +44 -0
  171. package/dist/esm/excel/xls/biff-styles.d.ts +20 -0
  172. package/dist/esm/excel/xls/biff-styles.js +20 -0
  173. package/dist/esm/excel/xls/escher.d.ts +27 -0
  174. package/dist/esm/excel/xls/escher.js +18 -0
  175. package/dist/esm/excel/xls/xls-reader.d.ts +6 -0
  176. package/dist/esm/excel/xls/xls-reader.js +6 -0
  177. package/dist/esm/excel/xlsx-reader.d.ts +26 -0
  178. package/dist/esm/excel/xlsx-reader.js +26 -0
  179. package/dist/esm/excel/xlsx-to-pdf.d.ts +27 -0
  180. package/dist/esm/excel/xlsx-writer.d.ts +14 -0
  181. package/dist/esm/excel/xlsx-writer.js +13 -0
  182. package/dist/esm/html/html-writer.d.ts +18 -0
  183. package/dist/esm/html/html-writer.js +18 -0
  184. package/dist/esm/index.d.ts +23 -0
  185. package/dist/esm/layout/math-layout.d.ts +39 -0
  186. package/dist/esm/layout/math-layout.js +18 -0
  187. package/dist/esm/layout/page-doc.d.ts +91 -0
  188. package/dist/esm/layout/styled-layout.d.ts +175 -0
  189. package/dist/esm/layout/styled-layout.js +117 -2
  190. package/dist/esm/pdf/builtin-fonts.d.ts +5 -0
  191. package/dist/esm/pdf/cid-font.d.ts +22 -0
  192. package/dist/esm/pdf/cid-font.js +10 -0
  193. package/dist/esm/pdf/embedded-file.d.ts +16 -0
  194. package/dist/esm/pdf/embedded-file.js +9 -0
  195. package/dist/esm/pdf/encryption.d.ts +59 -0
  196. package/dist/esm/pdf/encryption.js +37 -0
  197. package/dist/esm/pdf/icc-profile.d.ts +8 -0
  198. package/dist/esm/pdf/icc-profile.js +8 -0
  199. package/dist/esm/pdf/image-xobject.d.ts +19 -0
  200. package/dist/esm/pdf/image-xobject.js +9 -0
  201. package/dist/esm/pdf/objects.d.ts +40 -0
  202. package/dist/esm/pdf/objects.js +36 -0
  203. package/dist/esm/pdf/serialize.d.ts +18 -0
  204. package/dist/esm/pdf/serialize.js +18 -0
  205. package/dist/esm/pdf/shading.d.ts +16 -0
  206. package/dist/esm/pdf/shading.js +16 -0
  207. package/dist/esm/pdf/signature.d.ts +36 -0
  208. package/dist/esm/pdf/signature.js +22 -0
  209. package/dist/esm/pdf/struct-tree.d.ts +64 -0
  210. package/dist/esm/pdf/struct-tree.js +60 -0
  211. package/dist/esm/pdf/styled-page-emitter.d.ts +33 -0
  212. package/dist/esm/pdf/styled-page-emitter.js +21 -0
  213. package/dist/esm/pdf/styled-page-renderer.d.ts +18 -0
  214. package/dist/esm/pdf/styled-page-renderer.js +18 -0
  215. package/dist/esm/pdf/text-encoding.d.ts +16 -0
  216. package/dist/esm/pdf/text-page-renderer.d.ts +11 -0
  217. package/dist/esm/pdf/vector-graphics.d.ts +12 -0
  218. package/dist/esm/pdf/vector-graphics.js +12 -0
  219. package/dist/esm/pdf/writer.d.ts +39 -0
  220. package/dist/esm/pdf/writer.js +27 -0
  221. package/dist/esm/pdf/xmp.d.ts +16 -0
  222. package/dist/esm/pdf/xmp.js +9 -0
  223. package/dist/esm/pdf-reader/ccitt.d.ts +25 -0
  224. package/dist/esm/pdf-reader/ccitt.js +15 -0
  225. package/dist/esm/pdf-reader/cmap.d.ts +12 -0
  226. package/dist/esm/pdf-reader/cmap.js +9 -0
  227. package/dist/esm/pdf-reader/content.d.ts +69 -0
  228. package/dist/esm/pdf-reader/content.js +16 -0
  229. package/dist/esm/pdf-reader/crypto.d.ts +5 -0
  230. package/dist/esm/pdf-reader/crypto.js +5 -0
  231. package/dist/esm/pdf-reader/decrypt.d.ts +17 -0
  232. package/dist/esm/pdf-reader/decrypt.js +12 -0
  233. package/dist/esm/pdf-reader/document.d.ts +53 -0
  234. package/dist/esm/pdf-reader/document.js +50 -0
  235. package/dist/esm/pdf-reader/flow-build.d.ts +47 -0
  236. package/dist/esm/pdf-reader/flow-build.js +42 -0
  237. package/dist/esm/pdf-reader/font.d.ts +12 -0
  238. package/dist/esm/pdf-reader/font.js +12 -0
  239. package/dist/esm/pdf-reader/image-decode.d.ts +21 -0
  240. package/dist/esm/pdf-reader/image-decode.js +14 -0
  241. package/dist/esm/pdf-reader/images.d.ts +19 -0
  242. package/dist/esm/pdf-reader/images.js +9 -0
  243. package/dist/esm/pdf-reader/layout.d.ts +15 -0
  244. package/dist/esm/pdf-reader/layout.js +15 -0
  245. package/dist/esm/pdf-reader/lexer.d.ts +43 -0
  246. package/dist/esm/pdf-reader/lexer.js +38 -0
  247. package/dist/esm/pdf-reader/parser.d.ts +15 -0
  248. package/dist/esm/pdf-reader/parser.js +8 -0
  249. package/dist/esm/pdf-reader/png-encode.d.ts +9 -0
  250. package/dist/esm/pdf-reader/png-encode.js +8 -0
  251. package/dist/esm/pdf-reader/predictor.d.ts +9 -0
  252. package/dist/esm/pdf-reader/predictor.js +8 -0
  253. package/dist/esm/pdf-reader/reader.d.ts +16 -0
  254. package/dist/esm/pdf-reader/reader.js +16 -0
  255. package/dist/esm/pdf-reader/shading.d.ts +10 -0
  256. package/dist/esm/pdf-reader/shading.js +10 -0
  257. package/dist/esm/pdf-reader/struct-tree.d.ts +24 -0
  258. package/dist/esm/pdf-reader/struct-tree.js +12 -0
  259. package/dist/esm/pdf-reader/tagged.d.ts +13 -0
  260. package/dist/esm/pdf-reader/tagged.js +13 -0
  261. package/dist/esm/pdf-reader/text.d.ts +11 -0
  262. package/dist/esm/pdf-reader/text.js +11 -0
  263. package/dist/esm/pdf-reader/vector.d.ts +19 -0
  264. package/dist/esm/pdf-reader/vector.js +9 -0
  265. package/dist/esm/pptx/placeholder-cascade.d.ts +21 -0
  266. package/dist/esm/pptx/placeholder-cascade.js +10 -0
  267. package/dist/esm/pptx/ppt/ppt-reader.d.ts +16 -0
  268. package/dist/esm/pptx/ppt/ppt-reader.js +16 -0
  269. package/dist/esm/pptx/ppt/ppt-text.d.ts +55 -0
  270. package/dist/esm/pptx/ppt/ppt-text.js +14 -0
  271. package/dist/esm/pptx/pptx-reader.d.ts +21 -0
  272. package/dist/esm/pptx/pptx-reader.js +21 -0
  273. package/dist/esm/pptx/slide-parser.d.ts +102 -0
  274. package/dist/esm/pptx/slide-parser.js +78 -0
  275. package/dist/esm/pptx/sp-helpers.d.ts +28 -0
  276. package/dist/esm/pptx/sp-helpers.js +22 -0
  277. package/dist/esm/svg/svg-writer.d.ts +17 -0
  278. package/dist/esm/svg/svg-writer.js +16 -0
  279. package/dist/esm/word/doc/doc-reader.d.ts +16 -0
  280. package/dist/esm/word/doc/doc-reader.js +16 -0
  281. package/dist/esm/word/doc/doc-text.d.ts +77 -0
  282. package/dist/esm/word/doc/doc-text.js +13 -0
  283. package/dist/esm/word/document-parser.d.ts +134 -0
  284. package/dist/esm/word/document-parser.js +86 -0
  285. package/dist/esm/word/docx-reader.d.ts +16 -0
  286. package/dist/esm/word/docx-reader.js +16 -0
  287. package/dist/esm/word/docx-to-pdf.d.ts +52 -0
  288. package/dist/esm/word/docx-to-pdf.js +21 -0
  289. package/dist/esm/word/docx-writer.d.ts +17 -0
  290. package/dist/esm/word/docx-writer.js +17 -0
  291. package/dist/esm/word/drawing-parser.d.ts +88 -0
  292. package/dist/esm/word/drawing-parser.js +68 -0
  293. package/dist/esm/word/font-table.d.ts +24 -0
  294. package/dist/esm/word/font-table.js +24 -0
  295. package/dist/esm/word/numbering-parser.d.ts +11 -0
  296. package/dist/esm/word/numbering-parser.js +11 -0
  297. package/dist/esm/word/omml-parser.d.ts +15 -0
  298. package/dist/esm/word/omml-parser.js +15 -0
  299. package/dist/esm/word/omml-serializer.d.ts +9 -0
  300. package/dist/esm/word/omml-serializer.js +9 -0
  301. package/dist/esm/word/paragraph-properties.d.ts +10 -0
  302. package/dist/esm/word/paragraph-properties.js +10 -0
  303. package/dist/esm/word/po-to-flat.d.ts +11 -0
  304. package/dist/esm/word/po-to-flat.js +11 -0
  305. package/dist/esm/word/run-properties.d.ts +10 -0
  306. package/dist/esm/word/run-properties.js +10 -0
  307. package/dist/esm/word/settings-parser.d.ts +13 -0
  308. package/dist/esm/word/settings-parser.js +8 -0
  309. package/dist/esm/word/styles-parser.d.ts +10 -0
  310. package/dist/esm/word/styles-parser.js +10 -0
  311. package/dist/esm/word/table-parser.d.ts +11 -0
  312. package/dist/esm/word/table-parser.js +11 -0
  313. package/dist/esm/word/text-extractor.d.ts +9 -0
  314. package/dist/esm/word/xml-helpers.d.ts +44 -0
  315. package/dist/esm/word/xml-helpers.js +38 -0
  316. package/package.json +1 -1
@@ -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: m[2],
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);
@@ -1,2 +1,7 @@
1
+ /** One of the 14 Standard Type 1 font names (ISO 32000-1 §9.6.2.2). */
1
2
  export type BuiltinFontName = 'Helvetica' | 'Helvetica-Bold' | 'Helvetica-Oblique' | 'Helvetica-BoldOblique' | 'Times-Roman' | 'Times-Bold' | 'Times-Italic' | 'Times-BoldItalic' | 'Courier' | 'Courier-Bold' | 'Courier-Oblique' | 'Courier-BoldOblique' | 'Symbol' | 'ZapfDingbats';
3
+ /**
4
+ * The 14 Standard Type 1 fonts, guaranteed available in every conforming PDF
5
+ * reader and never embedded.
6
+ */
2
7
  export declare const BUILTIN_FONTS: ReadonlyArray<BuiltinFontName>;
@@ -1,15 +1,37 @@
1
1
  import { ParsedTtf } from '../core/font/index.js';
2
2
  import { PdfRef } from './objects.js';
3
3
  import { PdfDocument } from './writer.js';
4
+ /** Options for {@link embedTtfFont}. */
4
5
  export interface EmbedTtfOptions {
6
+ /** The glyph ids actually used; given, the font is subset to just these (plus their closure). */
5
7
  readonly usedGids?: Iterable<number>;
8
+ /**
9
+ * Emit a `/CIDSet` in the font descriptor (required by PDF/A-1; omitted
10
+ * otherwise, since PDF/A-2/3 only constrain it when present).
11
+ */
6
12
  readonly cidSet?: boolean;
7
13
  }
14
+ /** The result of {@link embedTtfFont}: the Type 0 font reference plus measurement/encoding helpers. */
8
15
  export interface EmbeddedFont {
16
+ /** Indirect reference to the `/Type0` font dictionary, for page resource `/Font` entries. */
9
17
  readonly fontRef: PdfRef;
18
+ /** The parsed source font. */
10
19
  readonly parsed: ParsedTtf;
20
+ /** Glyph advance width in PDF text-space units (1000/em) for a given glyph id. */
11
21
  readonly pdfWidthForGid: (gid: number) => number;
22
+ /** Measured width of `text` at `fontSize`, in points. */
12
23
  readonly textWidthPt: (text: string, fontSize: number) => number;
24
+ /** Encode `text` as the hex CID string used inside a `Tj`/`TJ` show operator (Identity-H). */
13
25
  readonly encodeTextAsCidHex: (text: string) => string;
14
26
  }
27
+ /**
28
+ * Embed a TrueType font as a composite (Type 0) font with a CIDFontType2
29
+ * descendant (ISO 32000-1 §9.7), optionally subsetting it to the used glyphs.
30
+ * Adds the `/FontFile2`, `/FontDescriptor`, `/CIDFontType2` and `/Type0` objects
31
+ * (plus a `/ToUnicode` CMap and an optional `/CIDSet`) to `doc`.
32
+ *
33
+ * @param parsed The parsed TrueType font.
34
+ * @param options Subset glyph set and/or PDF/A-1 `/CIDSet` emission.
35
+ * @returns The font reference and measurement/encoding helpers ({@link EmbeddedFont}).
36
+ */
15
37
  export declare function embedTtfFont(doc: PdfDocument, parsed: ParsedTtf, options?: EmbedTtfOptions): EmbeddedFont;
@@ -3,6 +3,16 @@ import { createFontMeasure } from "../core/font/measure.js";
3
3
  import { dict, name, ref, stream } from "./objects.js";
4
4
  //#region src/pdf/cid-font.ts
5
5
  var encoder = new TextEncoder();
6
+ /**
7
+ * Embed a TrueType font as a composite (Type 0) font with a CIDFontType2
8
+ * descendant (ISO 32000-1 §9.7), optionally subsetting it to the used glyphs.
9
+ * Adds the `/FontFile2`, `/FontDescriptor`, `/CIDFontType2` and `/Type0` objects
10
+ * (plus a `/ToUnicode` CMap and an optional `/CIDSet`) to `doc`.
11
+ *
12
+ * @param parsed The parsed TrueType font.
13
+ * @param options Subset glyph set and/or PDF/A-1 `/CIDSet` emission.
14
+ * @returns The font reference and measurement/encoding helpers ({@link EmbeddedFont}).
15
+ */
6
16
  function embedTtfFont(doc, parsed, options = {}) {
7
17
  const scale = 1e3 / parsed.unitsPerEm;
8
18
  const toPdfUnits = (v) => Math.round(v * scale);
@@ -1,11 +1,27 @@
1
1
  import { PdfRef } from './objects.js';
2
2
  import { PdfDocument } from './writer.js';
3
+ /** How an embedded file relates to the document (`/AFRelationship`, ISO 32000-2 §14.13). */
3
4
  export type AFRelationship = 'Source' | 'Data' | 'Alternative' | 'Supplement' | 'Unspecified';
5
+ /** One file to embed as a PDF/A-3 associated file (see {@link embedAssociatedFile}). */
4
6
  export interface AttachedFile {
7
+ /** File name as shown to the user, e.g. `"source.docx"`. ASCII recommended. */
5
8
  readonly name: string;
6
9
  readonly bytes: Uint8Array;
10
+ /**
11
+ * MIME type for the `/EmbeddedFile` `/Subtype`, e.g.
12
+ * `"application/vnd.openxmlformats-officedocument.wordprocessingml.document"`.
13
+ */
7
14
  readonly mimeType: string;
8
15
  readonly relationship?: AFRelationship;
9
16
  readonly description?: string;
10
17
  }
18
+ /**
19
+ * Embed `file` as an `/EmbeddedFile` stream wrapped in a `/Filespec` (ISO 32000-1
20
+ * §7.11, ISO 19005-3 §6.8). The MIME type becomes a `Name` (the serializer
21
+ * hex-escapes the `/`), which readers decode back.
22
+ *
23
+ * @param file The file bytes plus its name, MIME type and relationship.
24
+ * @returns A reference to the `/Filespec`, to place in the catalog `/AF` array
25
+ * and the `/Names` `/EmbeddedFiles` name tree.
26
+ */
11
27
  export declare function embedAssociatedFile(doc: PdfDocument, file: AttachedFile): PdfRef;
@@ -1,5 +1,14 @@
1
1
  import { dict, name, ref, stream, unicodeString } from "./objects.js";
2
2
  //#region src/pdf/embedded-file.ts
3
+ /**
4
+ * Embed `file` as an `/EmbeddedFile` stream wrapped in a `/Filespec` (ISO 32000-1
5
+ * §7.11, ISO 19005-3 §6.8). The MIME type becomes a `Name` (the serializer
6
+ * hex-escapes the `/`), which readers decode back.
7
+ *
8
+ * @param file The file bytes plus its name, MIME type and relationship.
9
+ * @returns A reference to the `/Filespec`, to place in the catalog `/AF` array
10
+ * and the `/Names` `/EmbeddedFiles` name tree.
11
+ */
3
12
  function embedAssociatedFile(doc, file) {
4
13
  const efRef = doc.add(stream({
5
14
  Type: name("EmbeddedFile"),