postext-pdf 1.63.1 → 1.63.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/dist/__bench__/arabicShaping.bench.test.js +1 -1
  2. package/dist/__bench__/arabicShaping.bench.test.js.map +1 -1
  3. package/dist/__tests__/accessibility.test.js +1 -1
  4. package/dist/__tests__/accessibility.test.js.map +1 -1
  5. package/dist/__tests__/boxBorderInside.test.js +1 -1
  6. package/dist/__tests__/boxBorderInside.test.js.map +1 -1
  7. package/dist/__tests__/boxShape.test.js +2 -2
  8. package/dist/__tests__/boxShape.test.js.map +1 -1
  9. package/dist/__tests__/canvasShaping.test.d.ts +1 -1
  10. package/dist/__tests__/canvasShaping.test.d.ts.map +1 -1
  11. package/dist/__tests__/canvasShaping.test.js +1 -1
  12. package/dist/__tests__/canvasShaping.test.js.map +1 -1
  13. package/dist/__tests__/comic.test.js +1 -1
  14. package/dist/__tests__/comic.test.js.map +1 -1
  15. package/dist/__tests__/comicMarkPairs.test.js +1 -1
  16. package/dist/__tests__/comicMarkPairs.test.js.map +1 -1
  17. package/dist/__tests__/composedDecorationImages.test.js +1 -1
  18. package/dist/__tests__/composedDecorationImages.test.js.map +1 -1
  19. package/dist/__tests__/composedFrameBoxes.test.js +1 -1
  20. package/dist/__tests__/composedFrameBoxes.test.js.map +1 -1
  21. package/dist/__tests__/composedPage.test.js +2 -2
  22. package/dist/__tests__/composedPage.test.js.map +1 -1
  23. package/dist/__tests__/declaredFiles.test.js +1 -1
  24. package/dist/__tests__/declaredFiles.test.js.map +1 -1
  25. package/dist/__tests__/dottedText.test.js +3 -3
  26. package/dist/__tests__/dottedText.test.js.map +1 -1
  27. package/dist/__tests__/headerFooter.test.js +2 -2
  28. package/dist/__tests__/headerFooter.test.js.map +1 -1
  29. package/dist/__tests__/pathBlock.test.js +2 -2
  30. package/dist/__tests__/pathBlock.test.js.map +1 -1
  31. package/dist/__tests__/printMaster.test.js +1 -1
  32. package/dist/__tests__/printMaster.test.js.map +1 -1
  33. package/dist/__tests__/rtlPdf.test.js +1 -1
  34. package/dist/__tests__/rtlPdf.test.js.map +1 -1
  35. package/dist/__tests__/shapingLanguage.test.js +1 -1
  36. package/dist/__tests__/shapingLanguage.test.js.map +1 -1
  37. package/dist/__tests__/shapingLanguageRuns.test.js +1 -1
  38. package/dist/__tests__/shapingLanguageRuns.test.js.map +1 -1
  39. package/dist/__tests__/shapingLanguageRunsDocument.test.js +1 -1
  40. package/dist/__tests__/shapingLanguageRunsDocument.test.js.map +1 -1
  41. package/dist/__tests__/sharedGlyphReadback.test.d.ts +1 -1
  42. package/dist/__tests__/sharedGlyphReadback.test.d.ts.map +1 -1
  43. package/dist/__tests__/sharedGlyphReadback.test.js +1 -1
  44. package/dist/__tests__/sharedGlyphReadback.test.js.map +1 -1
  45. package/dist/__tests__/svgVector.test.js +2 -2
  46. package/dist/__tests__/svgVector.test.js.map +1 -1
  47. package/dist/faceFiles.js +1 -1
  48. package/dist/faceFiles.js.map +1 -1
  49. package/dist/fontCache/fontFiles.d.ts +172 -0
  50. package/dist/fontCache/fontFiles.d.ts.map +1 -0
  51. package/dist/fontCache/fontFiles.js +81 -0
  52. package/dist/fontCache/fontFiles.js.map +1 -0
  53. package/dist/fontCache/glyphTables.d.ts +38 -0
  54. package/dist/fontCache/glyphTables.d.ts.map +1 -0
  55. package/dist/fontCache/glyphTables.js +107 -0
  56. package/dist/fontCache/glyphTables.js.map +1 -0
  57. package/dist/fontCache.d.ts +5 -189
  58. package/dist/fontCache.d.ts.map +1 -1
  59. package/dist/fontCache.js +5 -184
  60. package/dist/fontCache.js.map +1 -1
  61. package/dist/index.d.ts +2 -2
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +2 -2
  64. package/dist/index.js.map +1 -1
  65. package/dist/pdf-backend/blocks/blockRender/lineText.d.ts +23 -0
  66. package/dist/pdf-backend/blocks/blockRender/lineText.d.ts.map +1 -0
  67. package/dist/pdf-backend/blocks/blockRender/lineText.js +200 -0
  68. package/dist/pdf-backend/blocks/blockRender/lineText.js.map +1 -0
  69. package/dist/pdf-backend/blocks/blockRender/markers.d.ts +23 -0
  70. package/dist/pdf-backend/blocks/blockRender/markers.d.ts.map +1 -0
  71. package/dist/pdf-backend/blocks/blockRender/markers.js +140 -0
  72. package/dist/pdf-backend/blocks/blockRender/markers.js.map +1 -0
  73. package/dist/pdf-backend/blocks/blockRender/segments.d.ts +74 -0
  74. package/dist/pdf-backend/blocks/blockRender/segments.d.ts.map +1 -0
  75. package/dist/pdf-backend/blocks/blockRender/segments.js +409 -0
  76. package/dist/pdf-backend/blocks/blockRender/segments.js.map +1 -0
  77. package/dist/pdf-backend/{blockRender.d.ts → blocks/blockRender.d.ts} +7 -10
  78. package/dist/pdf-backend/blocks/blockRender.d.ts.map +1 -0
  79. package/dist/pdf-backend/blocks/blockRender.js +146 -0
  80. package/dist/pdf-backend/blocks/blockRender.js.map +1 -0
  81. package/dist/pdf-backend/{chip.d.ts → blocks/chip.d.ts} +3 -3
  82. package/dist/pdf-backend/blocks/chip.d.ts.map +1 -0
  83. package/dist/pdf-backend/{chip.js → blocks/chip.js} +5 -5
  84. package/dist/pdf-backend/blocks/chip.js.map +1 -0
  85. package/dist/pdf-backend/{inlineIcon.d.ts → blocks/inlineIcon.d.ts} +3 -3
  86. package/dist/pdf-backend/blocks/inlineIcon.d.ts.map +1 -0
  87. package/dist/pdf-backend/{inlineIcon.js → blocks/inlineIcon.js} +3 -3
  88. package/dist/pdf-backend/blocks/inlineIcon.js.map +1 -0
  89. package/dist/pdf-backend/blocks/renderResourceBlock/lines.d.ts +37 -0
  90. package/dist/pdf-backend/blocks/renderResourceBlock/lines.d.ts.map +1 -0
  91. package/dist/pdf-backend/blocks/renderResourceBlock/lines.js +271 -0
  92. package/dist/pdf-backend/blocks/renderResourceBlock/lines.js.map +1 -0
  93. package/dist/pdf-backend/blocks/renderResourceBlock/overlays.d.ts +21 -0
  94. package/dist/pdf-backend/blocks/renderResourceBlock/overlays.d.ts.map +1 -0
  95. package/dist/pdf-backend/blocks/renderResourceBlock/overlays.js +164 -0
  96. package/dist/pdf-backend/blocks/renderResourceBlock/overlays.js.map +1 -0
  97. package/dist/pdf-backend/blocks/renderResourceBlock/preload.d.ts +27 -0
  98. package/dist/pdf-backend/blocks/renderResourceBlock/preload.d.ts.map +1 -0
  99. package/dist/pdf-backend/blocks/renderResourceBlock/preload.js +330 -0
  100. package/dist/pdf-backend/blocks/renderResourceBlock/preload.js.map +1 -0
  101. package/dist/pdf-backend/blocks/renderResourceBlock/rasterize.d.ts +38 -0
  102. package/dist/pdf-backend/blocks/renderResourceBlock/rasterize.d.ts.map +1 -0
  103. package/dist/pdf-backend/blocks/renderResourceBlock/rasterize.js +218 -0
  104. package/dist/pdf-backend/blocks/renderResourceBlock/rasterize.js.map +1 -0
  105. package/dist/pdf-backend/blocks/renderResourceBlock/table.d.ts +17 -0
  106. package/dist/pdf-backend/blocks/renderResourceBlock/table.d.ts.map +1 -0
  107. package/dist/pdf-backend/blocks/renderResourceBlock/table.js +203 -0
  108. package/dist/pdf-backend/blocks/renderResourceBlock/table.js.map +1 -0
  109. package/dist/pdf-backend/blocks/renderResourceBlock.d.ts +59 -0
  110. package/dist/pdf-backend/blocks/renderResourceBlock.d.ts.map +1 -0
  111. package/dist/pdf-backend/blocks/renderResourceBlock.js +201 -0
  112. package/dist/pdf-backend/blocks/renderResourceBlock.js.map +1 -0
  113. package/dist/pdf-backend/{scoreRender.d.ts → blocks/scoreRender.d.ts} +2 -2
  114. package/dist/pdf-backend/blocks/scoreRender.d.ts.map +1 -0
  115. package/dist/pdf-backend/{scoreRender.js → blocks/scoreRender.js} +2 -2
  116. package/dist/pdf-backend/blocks/scoreRender.js.map +1 -0
  117. package/dist/pdf-backend/{taskBox.d.ts → blocks/taskBox.d.ts} +1 -1
  118. package/dist/pdf-backend/blocks/taskBox.d.ts.map +1 -0
  119. package/dist/pdf-backend/{taskBox.js → blocks/taskBox.js} +1 -1
  120. package/dist/pdf-backend/blocks/taskBox.js.map +1 -0
  121. package/dist/pdf-backend/index.d.ts +8 -114
  122. package/dist/pdf-backend/index.d.ts.map +1 -1
  123. package/dist/pdf-backend/index.js +16 -614
  124. package/dist/pdf-backend/index.js.map +1 -1
  125. package/dist/pdf-backend/{comic.d.ts → page/comic.d.ts} +6 -6
  126. package/dist/pdf-backend/page/comic.d.ts.map +1 -0
  127. package/dist/pdf-backend/{comic.js → page/comic.js} +4 -4
  128. package/dist/pdf-backend/page/comic.js.map +1 -0
  129. package/dist/pdf-backend/{headerFooter.d.ts → page/headerFooter.d.ts} +4 -4
  130. package/dist/pdf-backend/page/headerFooter.d.ts.map +1 -0
  131. package/dist/pdf-backend/{headerFooter.js → page/headerFooter.js} +8 -8
  132. package/dist/pdf-backend/page/headerFooter.js.map +1 -0
  133. package/dist/pdf-backend/{pageDecorations.d.ts → page/pageDecorations.d.ts} +1 -1
  134. package/dist/pdf-backend/page/pageDecorations.d.ts.map +1 -0
  135. package/dist/pdf-backend/{pageDecorations.js → page/pageDecorations.js} +1 -1
  136. package/dist/pdf-backend/page/pageDecorations.js.map +1 -0
  137. package/dist/pdf-backend/page/pageLabels.d.ts.map +1 -0
  138. package/dist/pdf-backend/page/pageLabels.js.map +1 -0
  139. package/dist/pdf-backend/primitives/actualText.d.ts +91 -0
  140. package/dist/pdf-backend/primitives/actualText.d.ts.map +1 -0
  141. package/dist/pdf-backend/primitives/actualText.js +154 -0
  142. package/dist/pdf-backend/primitives/actualText.js.map +1 -0
  143. package/dist/pdf-backend/primitives/color.d.ts +22 -0
  144. package/dist/pdf-backend/primitives/color.d.ts.map +1 -0
  145. package/dist/pdf-backend/primitives/color.js +116 -0
  146. package/dist/pdf-backend/primitives/color.js.map +1 -0
  147. package/dist/pdf-backend/primitives/matrix.d.ts +55 -0
  148. package/dist/pdf-backend/primitives/matrix.d.ts.map +1 -0
  149. package/dist/pdf-backend/primitives/matrix.js +124 -0
  150. package/dist/pdf-backend/primitives/matrix.js.map +1 -0
  151. package/dist/pdf-backend/primitives/measuredText.d.ts +61 -0
  152. package/dist/pdf-backend/primitives/measuredText.d.ts.map +1 -0
  153. package/dist/pdf-backend/primitives/measuredText.js +142 -0
  154. package/dist/pdf-backend/primitives/measuredText.js.map +1 -0
  155. package/dist/pdf-backend/primitives/shapedRuns.d.ts +49 -0
  156. package/dist/pdf-backend/primitives/shapedRuns.d.ts.map +1 -0
  157. package/dist/pdf-backend/primitives/shapedRuns.js +367 -0
  158. package/dist/pdf-backend/primitives/shapedRuns.js.map +1 -0
  159. package/dist/pdf-backend/primitives/shapes.d.ts +35 -0
  160. package/dist/pdf-backend/primitives/shapes.d.ts.map +1 -0
  161. package/dist/pdf-backend/primitives/shapes.js +166 -0
  162. package/dist/pdf-backend/primitives/shapes.js.map +1 -0
  163. package/dist/pdf-backend/primitives/textShows.d.ts +90 -0
  164. package/dist/pdf-backend/primitives/textShows.d.ts.map +1 -0
  165. package/dist/pdf-backend/primitives/textShows.js +167 -0
  166. package/dist/pdf-backend/primitives/textShows.js.map +1 -0
  167. package/dist/pdf-backend/primitives.d.ts +16 -308
  168. package/dist/pdf-backend/primitives.d.ts.map +1 -1
  169. package/dist/pdf-backend/primitives.js +15 -1195
  170. package/dist/pdf-backend/primitives.js.map +1 -1
  171. package/dist/pdf-backend/renderToPdf/composedFrames.d.ts +19 -0
  172. package/dist/pdf-backend/renderToPdf/composedFrames.d.ts.map +1 -0
  173. package/dist/pdf-backend/renderToPdf/composedFrames.js +156 -0
  174. package/dist/pdf-backend/renderToPdf/composedFrames.js.map +1 -0
  175. package/dist/pdf-backend/renderToPdf/metadata.d.ts +31 -0
  176. package/dist/pdf-backend/renderToPdf/metadata.d.ts.map +1 -0
  177. package/dist/pdf-backend/renderToPdf/metadata.js +85 -0
  178. package/dist/pdf-backend/renderToPdf/metadata.js.map +1 -0
  179. package/dist/pdf-backend/renderToPdf/paintPage.d.ts +16 -0
  180. package/dist/pdf-backend/renderToPdf/paintPage.d.ts.map +1 -0
  181. package/dist/pdf-backend/renderToPdf/paintPage.js +348 -0
  182. package/dist/pdf-backend/renderToPdf/paintPage.js.map +1 -0
  183. package/dist/pdf-backend/renderToPdf/warnings.d.ts +114 -0
  184. package/dist/pdf-backend/renderToPdf/warnings.d.ts.map +1 -0
  185. package/dist/pdf-backend/renderToPdf/warnings.js +35 -0
  186. package/dist/pdf-backend/renderToPdf/warnings.js.map +1 -0
  187. package/dist/pdf-backend/structure/links.d.ts.map +1 -0
  188. package/dist/pdf-backend/structure/links.js.map +1 -0
  189. package/dist/pdf-backend/structure/outlines.d.ts.map +1 -0
  190. package/dist/pdf-backend/structure/outlines.js.map +1 -0
  191. package/dist/pdf-backend/structure/structureFlow.d.ts.map +1 -0
  192. package/dist/pdf-backend/structure/structureFlow.js.map +1 -0
  193. package/dist/pdf-backend/{tagging.d.ts → structure/tagging.d.ts} +1 -1
  194. package/dist/pdf-backend/structure/tagging.d.ts.map +1 -0
  195. package/dist/pdf-backend/structure/tagging.js.map +1 -0
  196. package/dist/pdf-backend/{annotations.d.ts → text/annotations.d.ts} +3 -3
  197. package/dist/pdf-backend/text/annotations.d.ts.map +1 -0
  198. package/dist/pdf-backend/{annotations.js → text/annotations.js} +3 -3
  199. package/dist/pdf-backend/text/annotations.js.map +1 -0
  200. package/dist/pdf-backend/{directedLine.d.ts → text/directedLine.d.ts} +1 -1
  201. package/dist/pdf-backend/text/directedLine.d.ts.map +1 -0
  202. package/dist/pdf-backend/{directedLine.js → text/directedLine.js} +1 -1
  203. package/dist/pdf-backend/text/directedLine.js.map +1 -0
  204. package/dist/pdf-backend/text/fallbackSpaces.d.ts.map +1 -0
  205. package/dist/pdf-backend/text/fallbackSpaces.js.map +1 -0
  206. package/dist/pdf-backend/text/fontHelpers.d.ts.map +1 -0
  207. package/dist/pdf-backend/text/fontHelpers.js.map +1 -0
  208. package/dist/pdf-backend/text/inkScale.d.ts.map +1 -0
  209. package/dist/pdf-backend/text/inkScale.js.map +1 -0
  210. package/dist/pdf-backend/{rtlRun.d.ts → text/rtlRun.d.ts} +1 -1
  211. package/dist/pdf-backend/text/rtlRun.d.ts.map +1 -0
  212. package/dist/pdf-backend/{rtlRun.js → text/rtlRun.js} +2 -2
  213. package/dist/pdf-backend/text/rtlRun.js.map +1 -0
  214. package/dist/pdf-backend/text/shapedText/shaping.d.ts +70 -0
  215. package/dist/pdf-backend/text/shapedText/shaping.d.ts.map +1 -0
  216. package/dist/pdf-backend/text/shapedText/shaping.js +380 -0
  217. package/dist/pdf-backend/text/shapedText/shaping.js.map +1 -0
  218. package/dist/pdf-backend/{shapedText.d.ts → text/shapedText.d.ts} +2 -2
  219. package/dist/pdf-backend/text/shapedText.d.ts.map +1 -0
  220. package/dist/pdf-backend/text/shapedText.js +311 -0
  221. package/dist/pdf-backend/text/shapedText.js.map +1 -0
  222. package/dist/pdf-backend/{verticalText.d.ts → text/verticalText.d.ts} +1 -1
  223. package/dist/pdf-backend/text/verticalText.d.ts.map +1 -0
  224. package/dist/pdf-backend/{verticalText.js → text/verticalText.js} +4 -4
  225. package/dist/pdf-backend/text/verticalText.js.map +1 -0
  226. package/dist/pdf-backend/text/wordPieces.d.ts.map +1 -0
  227. package/dist/pdf-backend/{wordPieces.js → text/wordPieces.js} +1 -1
  228. package/dist/pdf-backend/text/wordPieces.js.map +1 -0
  229. package/dist/pdf-backend/{pathBlock.d.ts → vector/pathBlock.d.ts} +1 -1
  230. package/dist/pdf-backend/vector/pathBlock.d.ts.map +1 -0
  231. package/dist/pdf-backend/{pathBlock.js → vector/pathBlock.js} +1 -1
  232. package/dist/pdf-backend/vector/pathBlock.js.map +1 -0
  233. package/dist/pdf-backend/vector/svgVector/emit.d.ts +11 -0
  234. package/dist/pdf-backend/vector/svgVector/emit.d.ts.map +1 -0
  235. package/dist/pdf-backend/vector/svgVector/emit.js +281 -0
  236. package/dist/pdf-backend/vector/svgVector/emit.js.map +1 -0
  237. package/dist/pdf-backend/vector/svgVector/geometry.d.ts +18 -0
  238. package/dist/pdf-backend/vector/svgVector/geometry.d.ts.map +1 -0
  239. package/dist/pdf-backend/vector/svgVector/geometry.js +382 -0
  240. package/dist/pdf-backend/vector/svgVector/geometry.js.map +1 -0
  241. package/dist/pdf-backend/vector/svgVector/style.d.ts +37 -0
  242. package/dist/pdf-backend/vector/svgVector/style.d.ts.map +1 -0
  243. package/dist/pdf-backend/vector/svgVector/style.js +314 -0
  244. package/dist/pdf-backend/vector/svgVector/style.js.map +1 -0
  245. package/dist/pdf-backend/vector/svgVector/walk.d.ts +15 -0
  246. package/dist/pdf-backend/vector/svgVector/walk.d.ts.map +1 -0
  247. package/dist/pdf-backend/vector/svgVector/walk.js +405 -0
  248. package/dist/pdf-backend/vector/svgVector/walk.js.map +1 -0
  249. package/dist/pdf-backend/vector/svgVector/xml.d.ts +20 -0
  250. package/dist/pdf-backend/vector/svgVector/xml.d.ts.map +1 -0
  251. package/dist/pdf-backend/vector/svgVector/xml.js +160 -0
  252. package/dist/pdf-backend/vector/svgVector/xml.js.map +1 -0
  253. package/dist/pdf-backend/{svgVector.d.ts → vector/svgVector.d.ts} +2 -12
  254. package/dist/pdf-backend/vector/svgVector.d.ts.map +1 -0
  255. package/dist/pdf-backend/vector/svgVector.js +95 -0
  256. package/dist/pdf-backend/vector/svgVector.js.map +1 -0
  257. package/dist/pdf-backend/vector/tint.d.ts.map +1 -0
  258. package/dist/pdf-backend/{tint.js → vector/tint.js} +1 -1
  259. package/dist/pdf-backend/vector/tint.js.map +1 -0
  260. package/dist/worker/client.d.ts +1 -1
  261. package/dist/worker/client.d.ts.map +1 -1
  262. package/dist/worker/client.js +1 -1
  263. package/dist/worker/client.js.map +1 -1
  264. package/package.json +3 -3
  265. package/dist/pdf-backend/annotations.d.ts.map +0 -1
  266. package/dist/pdf-backend/annotations.js.map +0 -1
  267. package/dist/pdf-backend/blockRender.d.ts.map +0 -1
  268. package/dist/pdf-backend/blockRender.js +0 -866
  269. package/dist/pdf-backend/blockRender.js.map +0 -1
  270. package/dist/pdf-backend/chip.d.ts.map +0 -1
  271. package/dist/pdf-backend/chip.js.map +0 -1
  272. package/dist/pdf-backend/comic.d.ts.map +0 -1
  273. package/dist/pdf-backend/comic.js.map +0 -1
  274. package/dist/pdf-backend/directedLine.d.ts.map +0 -1
  275. package/dist/pdf-backend/directedLine.js.map +0 -1
  276. package/dist/pdf-backend/fallbackSpaces.d.ts.map +0 -1
  277. package/dist/pdf-backend/fallbackSpaces.js.map +0 -1
  278. package/dist/pdf-backend/fontHelpers.d.ts.map +0 -1
  279. package/dist/pdf-backend/fontHelpers.js.map +0 -1
  280. package/dist/pdf-backend/headerFooter.d.ts.map +0 -1
  281. package/dist/pdf-backend/headerFooter.js.map +0 -1
  282. package/dist/pdf-backend/inkScale.d.ts.map +0 -1
  283. package/dist/pdf-backend/inkScale.js.map +0 -1
  284. package/dist/pdf-backend/inlineIcon.d.ts.map +0 -1
  285. package/dist/pdf-backend/inlineIcon.js.map +0 -1
  286. package/dist/pdf-backend/links.d.ts.map +0 -1
  287. package/dist/pdf-backend/links.js.map +0 -1
  288. package/dist/pdf-backend/outlines.d.ts.map +0 -1
  289. package/dist/pdf-backend/outlines.js.map +0 -1
  290. package/dist/pdf-backend/pageDecorations.d.ts.map +0 -1
  291. package/dist/pdf-backend/pageDecorations.js.map +0 -1
  292. package/dist/pdf-backend/pageLabels.d.ts.map +0 -1
  293. package/dist/pdf-backend/pageLabels.js.map +0 -1
  294. package/dist/pdf-backend/pathBlock.d.ts.map +0 -1
  295. package/dist/pdf-backend/pathBlock.js.map +0 -1
  296. package/dist/pdf-backend/renderResourceBlock.d.ts +0 -120
  297. package/dist/pdf-backend/renderResourceBlock.d.ts.map +0 -1
  298. package/dist/pdf-backend/renderResourceBlock.js +0 -1351
  299. package/dist/pdf-backend/renderResourceBlock.js.map +0 -1
  300. package/dist/pdf-backend/rtlRun.d.ts.map +0 -1
  301. package/dist/pdf-backend/rtlRun.js.map +0 -1
  302. package/dist/pdf-backend/scoreRender.d.ts.map +0 -1
  303. package/dist/pdf-backend/scoreRender.js.map +0 -1
  304. package/dist/pdf-backend/shapedText.d.ts.map +0 -1
  305. package/dist/pdf-backend/shapedText.js +0 -682
  306. package/dist/pdf-backend/shapedText.js.map +0 -1
  307. package/dist/pdf-backend/structureFlow.d.ts.map +0 -1
  308. package/dist/pdf-backend/structureFlow.js.map +0 -1
  309. package/dist/pdf-backend/svgVector.d.ts.map +0 -1
  310. package/dist/pdf-backend/svgVector.js +0 -1610
  311. package/dist/pdf-backend/svgVector.js.map +0 -1
  312. package/dist/pdf-backend/tagging.d.ts.map +0 -1
  313. package/dist/pdf-backend/tagging.js.map +0 -1
  314. package/dist/pdf-backend/taskBox.d.ts.map +0 -1
  315. package/dist/pdf-backend/taskBox.js.map +0 -1
  316. package/dist/pdf-backend/tint.d.ts.map +0 -1
  317. package/dist/pdf-backend/tint.js.map +0 -1
  318. package/dist/pdf-backend/verticalText.d.ts.map +0 -1
  319. package/dist/pdf-backend/verticalText.js.map +0 -1
  320. package/dist/pdf-backend/wordPieces.d.ts.map +0 -1
  321. package/dist/pdf-backend/wordPieces.js.map +0 -1
  322. /package/dist/pdf-backend/{pageLabels.d.ts → page/pageLabels.d.ts} +0 -0
  323. /package/dist/pdf-backend/{pageLabels.js → page/pageLabels.js} +0 -0
  324. /package/dist/pdf-backend/{links.d.ts → structure/links.d.ts} +0 -0
  325. /package/dist/pdf-backend/{links.js → structure/links.js} +0 -0
  326. /package/dist/pdf-backend/{outlines.d.ts → structure/outlines.d.ts} +0 -0
  327. /package/dist/pdf-backend/{outlines.js → structure/outlines.js} +0 -0
  328. /package/dist/pdf-backend/{structureFlow.d.ts → structure/structureFlow.d.ts} +0 -0
  329. /package/dist/pdf-backend/{structureFlow.js → structure/structureFlow.js} +0 -0
  330. /package/dist/pdf-backend/{tagging.js → structure/tagging.js} +0 -0
  331. /package/dist/pdf-backend/{fallbackSpaces.d.ts → text/fallbackSpaces.d.ts} +0 -0
  332. /package/dist/pdf-backend/{fallbackSpaces.js → text/fallbackSpaces.js} +0 -0
  333. /package/dist/pdf-backend/{fontHelpers.d.ts → text/fontHelpers.d.ts} +0 -0
  334. /package/dist/pdf-backend/{fontHelpers.js → text/fontHelpers.js} +0 -0
  335. /package/dist/pdf-backend/{inkScale.d.ts → text/inkScale.d.ts} +0 -0
  336. /package/dist/pdf-backend/{inkScale.js → text/inkScale.js} +0 -0
  337. /package/dist/pdf-backend/{wordPieces.d.ts → text/wordPieces.d.ts} +0 -0
  338. /package/dist/pdf-backend/{tint.d.ts → vector/tint.d.ts} +0 -0
@@ -1,30 +1,24 @@
1
- import { PDFDocument, PDFName, BlendMode, ReadingDirection, } from 'pdf-lib';
1
+ import './text/shapedText.js';
2
+ import './text/verticalText.js';
3
+ import { PDFDocument, ReadingDirection, PDFName } from 'pdf-lib';
4
+ import { preloadResourceImages } from './blocks/renderResourceBlock.js';
2
5
  import fontkit from '@pdf-lib/fontkit';
3
- import { authoredCmykColors, loadOutputProfile, outputProfileInfo, parseIccProfile, resolvePrintConfig } from 'postext';
6
+ import { shapingLanguageOf, resolvePrintConfig, outputProfileInfo, parseIccProfile, loadOutputProfile, authoredCmykColors } from 'postext';
4
7
  import { createPrintColorMode } from '../print/colorMode.js';
5
8
  import { runPagePrintPass } from '../print/printPass.js';
6
9
  import { writePdfX } from '../print/pdfx.js';
7
- import { canonicalLocaleTag, cjkGridCells, comicBlockOnSheet, columnClipRect, comicFramePaintOrder, comicHoldsText, comicPaintsUnderText, composedFrameBlockIds, composedPaintOrder, composedSheetClip, computePageTextExtent, decorationOver, decorationUnder, dimensionToPx, frameClips, frameContentRect, frameMatrix, pageColumnRule, shapingLanguageOf, verticalFlowOf, composedSheetClipOnSheet } from 'postext';
8
- import { FontCache, withBareFiles } from '../fontCache.js';
9
- import { colorFromHex, fillRectPx, makeScale, popClip, popFrame, pushClipRect, pushFrame, quarterTurnMatrix, mirrorMatrix, whiteColor, } from './primitives.js';
10
- // Register the painters of vertical and of complex-script text with the
11
- // primitives.
12
- import './verticalText.js';
13
- import './shapedText.js';
10
+ import { withBareFiles, FontCache } from '../fontCache.js';
14
11
  import { codePointNeedsComplexShaping, loadComplexShaper } from '../complexShaping.js';
15
- import { collectFontText } from './fontHelpers.js';
16
- import { computeContentArea, renderBaselineGrid, renderCharacterGrid, renderColumnRule, renderFootnoteRules, renderCutLines, } from './pageDecorations.js';
17
- import { renderBlock, renderStripCaption } from './blockRender.js';
18
- import { renderHeaderFooterSlot } from './headerFooter.js';
19
- import { pushClipPolygon, renderComicLetteringPdf, renderComicPage, renderComicPanelsPdf, sheetMatrixToPdf } from './comic.js';
20
- import { addOutlines, numberedHeadingText } from './outlines.js';
21
- import { addPageLabels } from './pageLabels.js';
22
- import { preloadResourceImages, } from './renderResourceBlock.js';
23
- import { preloadScoreDrawings } from './scoreRender.js';
24
- import { anchorDestination, LinkRegistry } from './links.js';
25
- import { StructTree, tagArtifact } from './tagging.js';
26
- import { StructureFlow } from './structureFlow.js';
27
- import { withDocumentLanguage } from '../shapingLanguage.js';
12
+ import { collectFontText } from './text/fontHelpers.js';
13
+ import { addOutlines } from './structure/outlines.js';
14
+ import { addPageLabels } from './page/pageLabels.js';
15
+ import { preloadScoreDrawings } from './blocks/scoreRender.js';
16
+ import { LinkRegistry } from './structure/links.js';
17
+ import { StructTree } from './structure/tagging.js';
18
+ import { StructureFlow } from './structure/structureFlow.js';
19
+ import { metadataString, documentTitle, languageTag } from './renderToPdf/metadata.js';
20
+ import { renderPage } from './renderToPdf/paintPage.js';
21
+ import { fontFallbackWarning, fileIssueWarning, missingGlyphWarning } from './renderToPdf/warnings.js';
28
22
  /** `RenderToPdfOptions.date` as a date, or a throw that names the option. */
29
23
  function checkedDate(date) {
30
24
  const out = new Date(date);
@@ -33,599 +27,7 @@ function checkedDate(date) {
33
27
  }
34
28
  return out;
35
29
  }
36
- const faceName = (weight, style) => `${weight}${style === 'italic' ? ' italic' : ''}`;
37
- /** The warning of a face set in another cut of its family. */
38
- function fontFallbackWarning(f) {
39
- return {
40
- kind: 'fontFallback',
41
- ...f,
42
- message: `postext-pdf: "${f.family}" ${faceName(f.weight, f.style)} is not available from the font provider (${f.reason}); using ${faceName(f.fallback.weight, f.fallback.style)} instead`,
43
- };
44
- }
45
- /** How many characters a missing-glyph message lists. */
46
- const LISTED_CHARACTERS = 12;
47
- function missingGlyphWarning(m) {
48
- const shown = m.characters.slice(0, LISTED_CHARACTERS).join(' ');
49
- const more = m.characters.length > LISTED_CHARACTERS ? ` and ${m.characters.length - LISTED_CHARACTERS} more` : '';
50
- const count = m.characters.length === 1 ? '1 character' : `${m.characters.length} characters`;
51
- return {
52
- kind: 'missingGlyph',
53
- ...m,
54
- message: `postext-pdf: "${m.family}" ${faceName(m.weight, m.style)} has no glyph for ${count} (${shown}${more}); the PDF draws them as the font's .notdef glyph`,
55
- };
56
- }
57
- function fileIssueWarning(issue) {
58
- const face = `"${issue.family}" ${faceName(issue.weight, issue.style)}`;
59
- if (issue.kind === 'variableFontDefaultInstance') {
60
- return {
61
- ...issue,
62
- message: `postext-pdf: ${face} is a variable font; the PDF embeds its default instance, so this text prints at weight ${issue.defaultWeight}. Provide a static ${issue.weight} file.`,
63
- };
64
- }
65
- return {
66
- ...issue,
67
- message: `postext-pdf: ${face} is a CFF (.otf) font of ${(issue.bytes / (1024 * 1024)).toFixed(1)} MB, embedded whole; a TrueType build of the face would be subset to the glyphs used.`,
68
- };
69
- }
70
30
  export { declaredFontFile } from '../fontCache.js';
71
- /** BCP 47 tag of a document (`/Lang`): its `locale` (`'zh-Hant-TW'`,
72
- * script and region kept), else the tag its hyphenation was asked for
73
- * (`'es-ES'`, `'sv'`) when the patterns are another locale's, else the
74
- * patterns' own (`'en-us'` → `'en-US'`). */
75
- function languageTag(config) {
76
- const declared = canonicalLocaleTag(config?.locale);
77
- if (declared)
78
- return declared;
79
- const hyphenation = config?.bodyText?.hyphenation;
80
- const locale = hyphenation?.tag?.trim() || hyphenation?.locale;
81
- if (!locale)
82
- return undefined;
83
- // Canonical case: language lower, a two-letter region upper, the script
84
- // and variant subtags as given.
85
- return locale.replace(/_/g, '-').split('-')
86
- .map((sub, i) => (i === 0 ? sub.toLowerCase() : sub.length === 2 ? sub.toUpperCase() : sub))
87
- .join('-');
88
- }
89
- /** A metadata value as PDF text. The engine hands the printed fields over
90
- * as strings; a VDT from elsewhere may still carry typed YAML values
91
- * (`title: 1984` is a number, a date a `Date`, `author: [A, B]` a list),
92
- * which pdf-lib rejects — coerce them rather than throw. */
93
- function metadataString(value) {
94
- if (typeof value === 'string')
95
- return value;
96
- if (typeof value === 'number')
97
- return Number.isFinite(value) ? String(value) : undefined;
98
- if (typeof value === 'boolean')
99
- return String(value);
100
- if (value instanceof Date)
101
- return Number.isNaN(value.getTime()) ? undefined : value.toISOString().slice(0, 10);
102
- if (Array.isArray(value)) {
103
- const items = value.map(metadataString).filter((v) => !!v);
104
- return items.length > 0 ? items.join(', ') : undefined;
105
- }
106
- return undefined;
107
- }
108
- /** Title of the document for the PDF metadata: the declared title, else the
109
- * first heading (PDF/UA-1 §7.1 requires one). */
110
- function documentTitle(docs) {
111
- const declared = metadataString(docs[0]?.metadata?.title)?.trim();
112
- if (declared)
113
- return declared;
114
- let best;
115
- for (const doc of docs) {
116
- for (const block of doc.blocks) {
117
- if (block.type !== 'heading')
118
- continue;
119
- if (!best || (block.headingLevel ?? 1) < (best.headingLevel ?? 1))
120
- best = block;
121
- if ((best.headingLevel ?? 1) === 1)
122
- break;
123
- }
124
- if (best && (best.headingLevel ?? 1) === 1)
125
- break;
126
- }
127
- return (best && numberedHeadingText(best)) || 'Document';
128
- }
129
- /** The heading element an opener band's text belongs to: the part title on
130
- * a part-divider page, else the `span: 'page'` heading the band replaced
131
- * (hidden in its column, its lines still set — a structural `hidden`
132
- * heading, whose lines have no height, prints nothing at all), else a
133
- * plain paragraph. */
134
- function openerTextElem(page, structure) {
135
- let elem;
136
- return () => {
137
- if (elem)
138
- return elem;
139
- if (page.partInfo)
140
- return (elem = structure.partHeading());
141
- for (const col of page.columns) {
142
- for (const block of col.blocks) {
143
- if (block.hidden && block.type === 'heading' && (block.lines[0]?.bbox.height ?? 0) > 0)
144
- return (elem = structure.blockElem(block));
145
- }
146
- }
147
- return (elem = structure.tree.root.child('P'));
148
- };
149
- }
150
- /** Paint one page, its text shaped in its document's language, the one
151
- * the layout measured it in (`shapingLanguage.ts`, #764). A document that
152
- * keeps the host's language (`bodyText.shapingLanguage: 'host'`) is
153
- * shaped as it always was: `JAN ` for Japanese, the font's default for
154
- * any other. */
155
- function renderPage(...args) {
156
- const config = args[2].config;
157
- withDocumentLanguage(shapingLanguageOf(config), languageTag(config), () => paintPage(...args));
158
- }
159
- function paintPage(pdfDoc, vdtPage, doc, fontCache, pageNegative, colorSpace, resourceCtx, tree, onMissingImage, characterGrid = false) {
160
- const scale = makeScale(doc.config.page.dpi);
161
- const pageWidthPt = vdtPage.width * scale;
162
- const pageHeightPt = vdtPage.height * scale;
163
- const page = pdfDoc.addPage([pageWidthPt, pageHeightPt]);
164
- // With cut lines the sheet carries the bleed and the marks: say where the
165
- // page is trimmed and how far its art runs, for imposition and preflight.
166
- if (doc.config.page.cutLines.enabled) {
167
- const trimPt = doc.trimOffset * scale;
168
- const bleedPt = Math.max(0, doc.trimOffset - dimensionToPx(doc.config.page.cutLines.bleed, doc.config.page.dpi)) * scale;
169
- page.setTrimBox(trimPt, trimPt, pageWidthPt - 2 * trimPt, pageHeightPt - 2 * trimPt);
170
- page.setBleedBox(bleedPt, bleedPt, pageWidthPt - 2 * bleedPt, pageHeightPt - 2 * bleedPt);
171
- }
172
- const ctx = {
173
- page, pageHeightPt, scale, colorSpace, tags: tree?.beginPage(page), ...(onMissingImage ? { onMissingImage } : {}), images: resourceCtx.images,
174
- frameCjk: { region: doc.config.cjk?.region ?? 'mainland', uprightDigits: doc.config.cjk?.uprightDigits ?? 2 },
175
- };
176
- const structure = resourceCtx.structure;
177
- // Background: full page white first (cut-mark area stays white), then the
178
- // trim+bleed area filled with the configured page background colour.
179
- tagArtifact(ctx, { type: 'Background' });
180
- fillRectPx(ctx, 0, 0, vdtPage.width, vdtPage.height, whiteColor(colorSpace));
181
- // A part's or a styled section's palette may give the page its own paper.
182
- const bgHex = vdtPage.background ?? doc.config.page.backgroundColor.hex;
183
- const trimOff = doc.trimOffset;
184
- const bleedPx = trimOff > 0
185
- ? dimensionToPx(doc.config.page.cutLines.bleed, doc.config.page.dpi)
186
- : 0;
187
- if (bgHex && bgHex !== 'transparent') {
188
- fillRectPx(ctx, trimOff - bleedPx, trimOff - bleedPx, vdtPage.width - (trimOff - bleedPx) * 2, vdtPage.height - (trimOff - bleedPx) * 2, colorFromHex(bgHex, colorSpace));
189
- }
190
- // With cut lines the sheet also carries the slug, where only the marks
191
- // print: everything the page paints is clipped to the bleed box, as a
192
- // DTP export clips it (EF-133). The marks are drawn after the clip ends.
193
- const bleedClip = trimOff > 0;
194
- if (bleedClip) {
195
- const inset = Math.max(0, trimOff - bleedPx);
196
- pushClipRect(ctx, inset, inset, vdtPage.width - inset * 2, vdtPage.height - inset * 2);
197
- }
198
- // A vertical page (`VDTPage.flow`) paints its flow through the page's
199
- // frame, a quarter turn clockwise (the `'cw'` resource matrix with its
200
- // origin at the sheet's right edge), and maps the rects that live outside
201
- // the content stream through it (`pushFrame`): link annotations of the
202
- // text, contents rows, `:ref`s and page links, the named destinations of
203
- // resources and notes, structure bounding boxes. Its text is set down the
204
- // column (`verticalText.ts`): characters upright through the fonts'
205
- // vertical twins, Latin words and long numbers sideways. Running heads,
206
- // folios and the marks stay on the sheet.
207
- // A right-to-left page (`VDTMirroredFlowFrame`) paints its flow through
208
- // its mirror the same way, with `ctx.mirror` on: each text object and
209
- // picture is turned back about its own box (`pushTextObject`,
210
- // `counterFlipPx`), so the geometry lands mirrored and the text reads as
211
- // written. Link and structure rects map through the frame too.
212
- // A comic page with text panels (#885): its panels first, the text over
213
- // them with the floats, its lettering after the flow.
214
- const comicUnder = comicPaintsUnderText(vdtPage) ? vdtPage.comic : undefined;
215
- const comicTags = comicUnder ? renderComicPanelsPdf(ctx, comicUnder, resourceCtx.images, structure) : undefined;
216
- let flowMatrix;
217
- const vflow = verticalFlowOf(vdtPage);
218
- if (vflow)
219
- flowMatrix = quarterTurnMatrix(vflow.rotation, scale, pageHeightPt);
220
- else if (vdtPage.flow?.writingMode === 'horizontal-tb')
221
- flowMatrix = mirrorMatrix(vdtPage.flow.mirror.originX, scale);
222
- const enterFlow = () => {
223
- if (!flowMatrix)
224
- return;
225
- pushFrame(ctx, flowMatrix);
226
- if (vflow) {
227
- ctx.vertical = {
228
- region: doc.config.cjk?.region ?? 'mainland',
229
- uprightDigits: doc.config.cjk?.uprightDigits ?? 2,
230
- ...(vflow.centralBaselines ? { axes: vflow.centralBaselines } : {}),
231
- };
232
- }
233
- else
234
- ctx.mirror = true;
235
- };
236
- const leaveFlow = () => {
237
- if (!flowMatrix)
238
- return;
239
- popFrame(ctx);
240
- delete ctx.vertical;
241
- delete ctx.mirror;
242
- };
243
- enterFlow();
244
- tagArtifact(ctx, { type: 'Layout' });
245
- if (doc.config.page.baselineGrid.enabled) {
246
- // Bound the grid to the page's actual text: from the first text line to
247
- // the last (mirrors the canvas backend). Pages with no text draw no grid.
248
- const textExtent = computePageTextExtent(vdtPage);
249
- if (textExtent) {
250
- const contentArea = computeContentArea(vdtPage, doc);
251
- const gridLineWidthPx = dimensionToPx(doc.config.page.baselineGrid.lineWidth, doc.config.page.dpi);
252
- renderBaselineGrid(ctx, contentArea, doc.baselineGrid, doc.config.page.baselineGrid.color.hex, gridLineWidthPx, textExtent);
253
- }
254
- }
255
- // The character grid, only when the render asks for it.
256
- if (characterGrid && doc.config.cjk?.grid?.show) {
257
- const cells = cjkGridCells(doc.config, vdtPage.contentArea ?? computeContentArea(vdtPage, doc), doc.baselineGrid, vdtPage.columns, vdtPage.flow);
258
- if (cells)
259
- renderCharacterGrid(ctx, cells);
260
- }
261
- // The page's own rule on a styled section's pages, else the document's
262
- // (mirrors the canvas backend via `pageColumnRule`).
263
- const columnRule = pageColumnRule(vdtPage, doc);
264
- if (columnRule.enabled && vdtPage.columns.length > 1) {
265
- renderColumnRule(ctx, vdtPage.columns, columnRule.color, columnRule.lineWidthPx, vdtPage.footnoteAreas);
266
- }
267
- // Opener / part bands go under the columns so their backgrounds sit
268
- // beneath the body text (mirrors the canvas backend). Their text is the
269
- // chapter / part heading; the rest of the band is decoration.
270
- if (vdtPage.openerBand) {
271
- renderHeaderFooterSlot(ctx, vdtPage.openerBand, fontCache, resourceCtx.images, structure
272
- ? {
273
- text: openerTextElem(vdtPage, structure),
274
- artifact: { type: 'Layout' },
275
- figure: (alt, attributes, after) => structure.designFigure(alt, attributes, after),
276
- }
277
- : undefined);
278
- }
279
- // The anchors of the page (#264): where cross-references jump to, and
280
- // named destinations (`file.pdf#nameddest=id`).
281
- for (const anchor of doc.anchors ?? []) {
282
- if (anchor.pageIndex !== vdtPage.index)
283
- continue;
284
- const at = [anchor.x * scale, pageHeightPt - anchor.y * scale, anchor.x * scale, pageHeightPt - anchor.y * scale];
285
- const [left, , , top] = ctx.mapRectPt ? ctx.mapRectPt(at) : at;
286
- resourceCtx.linkRegistry.addDestination(anchorDestination(anchor.id), ctx.page, left, top, anchor.id);
287
- }
288
- // Clip to column bounds, widened for glyph ink and for design overlays
289
- // that hang past the column on purpose — the same rectangle the canvas
290
- // backend clips to (see `columnClipRect`). Only a document that hangs
291
- // marks (`cjk.hangingPunctuation`) has lines whose marks reach past it.
292
- const hanging = doc.config.cjk?.hangingPunctuation !== 'none';
293
- // Strips (`:::strip`) met in the columns and floats: tagged in place,
294
- // painted on the sheet after the flow frame closes.
295
- const strips = [];
296
- /** A strip's `Div` and its caption (#590), read where the strip stands:
297
- * the caption is painted in the flow now, tagged as the `Div`'s
298
- * `Caption`; the picture joins the `Div` when painted on the sheet. */
299
- const readStrip = (block) => {
300
- const div = structure ? structure.comicStrip(block) : undefined;
301
- const caption = div && block.stripCaption ? div.child('Caption') : undefined;
302
- renderStripCaption(ctx, block, fontCache, resourceCtx.linkRegistry, caption);
303
- return { block, ...(div ? { div } : {}), ...(caption ? { caption } : {}) };
304
- };
305
- for (const col of vdtPage.columns) {
306
- const clip = columnClipRect(col, doc.config.page.dpi, hanging);
307
- pushClipRect(ctx, clip.x, clip.y, clip.width, clip.height);
308
- for (const block of col.blocks) {
309
- if (block.tocPart && block.designOverlay) {
310
- // Painted below, but read in its place among the contents rows.
311
- // (A repeated head row of a cut block is an artifact, #850.)
312
- if (structure && !block.hidden && !block.tocPart.continued && block.designOverlay.blocks.some((b) => b.kind === 'text')) {
313
- structure.blockElem(block);
314
- }
315
- continue;
316
- }
317
- // A strip is painted on the sheet below, but read here.
318
- if (block.comic) {
319
- if (!block.hidden)
320
- strips.push(readStrip(block));
321
- continue;
322
- }
323
- renderBlock(ctx, block, col.bbox.width, col.bbox.x, fontCache, resourceCtx);
324
- }
325
- popClip(ctx);
326
- // A part row of the contents carries a design of its own, which may
327
- // run past the column (a band reaching beyond the page numbers): it
328
- // is drawn outside the column clip, like a float.
329
- for (const block of col.blocks) {
330
- if (!block.tocPart || !block.designOverlay)
331
- continue;
332
- const paint = () => renderBlock(ctx, block, col.bbox.width, col.bbox.x, fontCache, resourceCtx);
333
- if (structure)
334
- structure.aside(paint);
335
- else
336
- paint();
337
- }
338
- }
339
- // Floated resources sit outside the column clip (a `span: 'page'` float can
340
- // cross the gutter); they carry an absolute bbox positioned at build time.
341
- // A tagged render reads each one after the text that cites it (EF-146).
342
- // A composed page's frames (#855) are floats painted with their frames.
343
- const frameIds = composedFrameBlockIds(vdtPage);
344
- if (vdtPage.floats) {
345
- const floats = vdtPage.floats.filter((fb) => !frameIds.has(fb.id));
346
- for (let i = 0; i < floats.length; i++) {
347
- const fb = floats[i];
348
- if (fb.comic) {
349
- // A floated strip: read after the text that comes before it,
350
- // painted on the sheet below.
351
- if (fb.hidden)
352
- continue;
353
- if (structure)
354
- structure.readFloat(fb, () => { strips.push(readStrip(fb)); });
355
- else
356
- strips.push(readStrip(fb));
357
- continue;
358
- }
359
- // The blocks a floated (or fixed) box sets on the page are read as
360
- // one float, anchored by its first block (#893), so a list in it
361
- // stays one list, as in a composed frame (#862).
362
- let end = i + 1;
363
- if (fb.containerId !== undefined) {
364
- while (end < floats.length && floats[end].containerId === fb.containerId && !floats[end].comic)
365
- end++;
366
- }
367
- const group = floats.slice(i, end);
368
- i = end - 1;
369
- const paint = () => {
370
- for (const b of group)
371
- renderBlock(ctx, b, b.bbox.width, b.bbox.x, fontCache, resourceCtx);
372
- };
373
- if (structure)
374
- structure.readFloat(fb, paint);
375
- else
376
- paint();
377
- }
378
- }
379
- // A page painted through a flow frame paints its decoration on the
380
- // sheet, after the flow.
381
- const decorationMark = structure
382
- ? { artifact: { type: 'Layout' }, figure: (alt, attributes, after) => structure.designFigure(alt, attributes, after) }
383
- : undefined;
384
- if (vdtPage.composed && flowMatrix) {
385
- // The decoration stands on the sheet, so the flow frame is left for
386
- // it, between the frames under layer 0 and the others: a title frame
387
- // on a band reads over the band on a right-to-left or vertical page
388
- // as on any other.
389
- paintComposedFrames(ctx, vdtPage, fontCache, resourceCtx, undefined, false, 'below');
390
- leaveFlow();
391
- if (vdtPage.composed.decoration) {
392
- // On a page of a spread (#861), its share of the sheet only (the
393
- // clip, in flow coordinates, mapped to the sheet, #926).
394
- const sheet = composedSheetClipOnSheet(vdtPage);
395
- if (sheet)
396
- pushClipRect(ctx, sheet.x, sheet.y, sheet.width, sheet.height);
397
- renderHeaderFooterSlot(ctx, decorationUnder(vdtPage.composed.decoration), fontCache, resourceCtx.images, decorationMark);
398
- if (sheet)
399
- popClip(ctx);
400
- }
401
- enterFlow();
402
- paintComposedFrames(ctx, vdtPage, fontCache, resourceCtx, undefined, false, 'above');
403
- // Connectors painted over the frames (#1076), on the sheet too: Layout
404
- // artifacts, as the rest of the decoration.
405
- const over = decorationOver(vdtPage.composed.decoration);
406
- if (over) {
407
- leaveFlow();
408
- const sheet = composedSheetClipOnSheet(vdtPage);
409
- if (sheet)
410
- pushClipRect(ctx, sheet.x, sheet.y, sheet.width, sheet.height);
411
- renderHeaderFooterSlot(ctx, over, fontCache, resourceCtx.images, decorationMark);
412
- if (sheet)
413
- popClip(ctx);
414
- enterFlow();
415
- }
416
- }
417
- else if (vdtPage.composed)
418
- paintComposedFrames(ctx, vdtPage, fontCache, resourceCtx, decorationMark, true);
419
- if (comicUnder)
420
- paintComicTextFrames(ctx, vdtPage, fontCache, resourceCtx, comicTags);
421
- // The footnote separators are layout.
422
- if (vdtPage.footnoteAreas?.some((a) => a.rule)) {
423
- tagArtifact(ctx, { type: 'Layout' });
424
- renderFootnoteRules(ctx, vdtPage);
425
- }
426
- leaveFlow();
427
- // A comic page's panels and lettering (or its half of a spread), then
428
- // the strips the page holds, on the sheet (never through the flow
429
- // frame), under the running heads.
430
- if (comicUnder)
431
- renderComicLetteringPdf(ctx, comicUnder, fontCache, comicTags);
432
- else if (vdtPage.comic)
433
- renderComicPage(ctx, vdtPage.comic, fontCache, resourceCtx.images, structure);
434
- for (const strip of strips) {
435
- const sheetComic = comicBlockOnSheet(vdtPage, strip.block);
436
- if (comicHoldsText(sheetComic)) {
437
- // A strip with text panels (#959): its panels, the text in the flow
438
- // frame over them (read in the panel's place), then its lettering.
439
- const tags = renderComicPanelsPdf(ctx, sheetComic, resourceCtx.images, structure, strip.div);
440
- enterFlow();
441
- paintComicTextFrames(ctx, vdtPage, fontCache, resourceCtx, tags, sheetComic);
442
- leaveFlow();
443
- renderComicLetteringPdf(ctx, sheetComic, fontCache, tags);
444
- }
445
- else
446
- renderComicPage(ctx, sheetComic, fontCache, resourceCtx.images, structure, strip.div);
447
- // A caption set under the strip is read after its panels.
448
- if (strip.div && strip.caption && strip.block.stripCaption?.position !== 'above') {
449
- const kids = strip.div.kids;
450
- const at = kids.findIndex((k) => k.kind === 'elem' && k.elem === strip.caption);
451
- if (at >= 0)
452
- kids.push(...kids.splice(at, 1));
453
- }
454
- }
455
- // Running headers and footers are pagination artifacts.
456
- const pagination = (subtype) => structure ? { artifact: { type: 'Pagination', subtype } } : undefined;
457
- // Line numbers (#621): layout artifacts in a tagged PDF, and each set
458
- // under an empty `/ActualText`, so text extraction and copying run from
459
- // line to line without them.
460
- if (vdtPage.lineNumbers) {
461
- renderHeaderFooterSlot(ctx, vdtPage.lineNumbers, fontCache, resourceCtx.images, structure ? { artifact: { type: 'Layout' } } : undefined, { silent: true });
462
- }
463
- if (vdtPage.header)
464
- renderHeaderFooterSlot(ctx, vdtPage.header, fontCache, resourceCtx.images, pagination('Header'));
465
- if (vdtPage.footer)
466
- renderHeaderFooterSlot(ctx, vdtPage.footer, fontCache, resourceCtx.images, pagination('Footer'));
467
- if (bleedClip)
468
- popClip(ctx);
469
- // Page negative: overlay white rect with Difference blend across trim+bleed.
470
- // Crop marks remain un-inverted (drawn afterwards).
471
- tagArtifact(ctx, { type: 'Page' });
472
- if (pageNegative) {
473
- const invX = trimOff - bleedPx;
474
- const invY = trimOff - bleedPx;
475
- const invW = vdtPage.width - (trimOff - bleedPx) * 2;
476
- const invH = vdtPage.height - (trimOff - bleedPx) * 2;
477
- fillRectPx(ctx, invX, invY, invW, invH, whiteColor(colorSpace), BlendMode.Difference);
478
- }
479
- renderCutLines(ctx, vdtPage, doc);
480
- ctx.tags?.close();
481
- }
482
- /**
483
- * Paint a composed page's frames (#855) in layer order, the template's
484
- * decoration at layer 0 (when `withDecoration`): each frame's blocks as
485
- * floats are painted, turned by the frame's matrix and clipped to its box
486
- * when its content overflows. Tagged, each frame is read in Markdown order
487
- * (the lowest content index of its blocks), not in the order the layers
488
- * paint it: `readFloat`'s `readAt`.
489
- */
490
- function paintComposedFrames(ctx, vdtPage, fontCache, resourceCtx, mark, withDecoration, part) {
491
- const structure = resourceCtx.structure;
492
- // On a page of a spread (#861) the frames and the decoration show the
493
- // page's share of the sheet only.
494
- const sheet = composedSheetClip(vdtPage);
495
- if (sheet)
496
- pushClipRect(ctx, sheet.x, sheet.y, sheet.width, sheet.height);
497
- try {
498
- paintComposedItems(ctx, vdtPage, fontCache, resourceCtx, mark, withDecoration, structure, part);
499
- }
500
- finally {
501
- if (sheet)
502
- popClip(ctx);
503
- }
504
- }
505
- function paintComposedItems(ctx, vdtPage, fontCache, resourceCtx, mark, withDecoration, structure, part) {
506
- for (const item of composedPaintOrder(vdtPage, part)) {
507
- if (item.kind === 'decoration' || item.kind === 'over') {
508
- // The decoration at layer 0, and its connectors over the frames
509
- // (#1076) after them.
510
- const decoration = item.kind === 'over' ? decorationOver(vdtPage.composed?.decoration) : decorationUnder(vdtPage.composed?.decoration);
511
- if (withDecoration && decoration)
512
- renderHeaderFooterSlot(ctx, decoration, fontCache, resourceCtx.images, mark);
513
- continue;
514
- }
515
- paintFrameItem(ctx, item, fontCache, resourceCtx, structure);
516
- }
517
- }
518
- /** The text frames of a comic page (`::panel{text}`, #885), over its
519
- * panels: each read as one float, as a composed page's frame is. */
520
- function paintComicTextFrames(ctx, vdtPage, fontCache, resourceCtx, tags, comic = vdtPage.comic) {
521
- for (const item of comicFramePaintOrder(vdtPage, comic)) {
522
- if (item.kind !== 'frame')
523
- continue;
524
- // Read in the comic's `Div`, in its panel's place (#909).
525
- const panel = item.frame.panel !== undefined ? comic?.panels.find((q) => q.index === item.frame.panel)?.index : undefined;
526
- const into = panel !== undefined ? tags?.texts[panel] : undefined;
527
- paintFrameItem(ctx, item, fontCache, resourceCtx, resourceCtx.structure, into);
528
- }
529
- }
530
- /** One frame of a paint order: its blocks, turned (and scaled) by its
531
- * matrix, clipped to its box when its content overflows and to its
532
- * outline when it has one (a comic panel cut by a slanted line, #885). */
533
- function paintFrameItem(ctx, item, fontCache, resourceCtx, structure, into) {
534
- // A vertical frame of a right-to-left page (#960) is placed by a matrix
535
- // that includes the page's mirror: its text is not turned back again.
536
- if (item.frame.unmirrorX === undefined || !ctx.mirror) {
537
- paintFrameItemIn(ctx, item, fontCache, resourceCtx, structure, into);
538
- return;
539
- }
540
- delete ctx.mirror;
541
- try {
542
- paintFrameItemIn(ctx, item, fontCache, resourceCtx, structure, into);
543
- }
544
- finally {
545
- ctx.mirror = true;
546
- }
547
- }
548
- function paintFrameItemIn(ctx, item, fontCache, resourceCtx, structure, into) {
549
- const { frame, blocks } = item;
550
- if (blocks.length === 0)
551
- return;
552
- // A frame set in its own writing mode (#944): its text is painted as a
553
- // page of that mode paints its flow, set vertically (or not).
554
- if (frame.writingMode) {
555
- const outer = ctx.vertical;
556
- if (frame.writingMode === 'vertical-rl') {
557
- const cjk = ctx.frameCjk ?? { region: 'mainland', uprightDigits: 2 };
558
- ctx.vertical = { region: cjk.region, uprightDigits: cjk.uprightDigits, ...(frame.centralBaselines ? { axes: frame.centralBaselines } : {}) };
559
- }
560
- else
561
- delete ctx.vertical;
562
- try {
563
- paintFrameBlocks(ctx, item, fontCache, resourceCtx, structure, into);
564
- }
565
- finally {
566
- if (outer)
567
- ctx.vertical = outer;
568
- else
569
- delete ctx.vertical;
570
- }
571
- return;
572
- }
573
- paintFrameBlocks(ctx, item, fontCache, resourceCtx, structure, into);
574
- }
575
- function paintFrameBlocks(ctx, item, fontCache, resourceCtx, structure, into) {
576
- const { frame, blocks } = item;
577
- let readAt;
578
- for (const b of blocks)
579
- if (b.contentIndex !== undefined && (readAt === undefined || b.contentIndex < readAt))
580
- readAt = b.contentIndex;
581
- // Text carried in from another chapter (#943) is read at its page.
582
- if (frame.readIndex !== undefined)
583
- readAt = frame.readIndex;
584
- const m = frameMatrix(frame);
585
- const clips = frameClips(frame);
586
- const outline = frame.polygon && frame.polygon.length >= 3 ? frame.polygon : undefined;
587
- if (outline)
588
- pushClipPolygon(ctx, outline);
589
- if (m)
590
- pushFrame(ctx, sheetMatrixToPdf(m, ctx.scale, ctx.pageHeightPt));
591
- // The clip is in the blocks' own frame (larger than the box when the
592
- // frame's text is scaled, #858).
593
- const box = frameContentRect(frame);
594
- if (clips)
595
- pushClipRect(ctx, box.x, box.y, box.width, box.height);
596
- try {
597
- if (item.facing) {
598
- // The facing page's half of a frame across a spread's spine: its
599
- // text is read on the other page, so here it is an artifact.
600
- tagArtifact(ctx, { type: 'Layout' });
601
- const untagged = { ...resourceCtx, structure: undefined };
602
- for (const fb of blocks)
603
- renderBlock(ctx, fb, fb.bbox.width, fb.bbox.x, fontCache, untagged);
604
- }
605
- else {
606
- // A frame's blocks are read as one float (#862), so a list in it
607
- // stays one list.
608
- const paint = () => {
609
- for (const fb of blocks)
610
- renderBlock(ctx, fb, fb.bbox.width, fb.bbox.x, fontCache, resourceCtx);
611
- };
612
- if (structure && into)
613
- structure.readInto(into, paint);
614
- else if (structure)
615
- structure.readFloat(blocks[0], paint, readAt);
616
- else
617
- paint();
618
- }
619
- }
620
- finally {
621
- if (clips)
622
- popClip(ctx);
623
- if (m)
624
- popFrame(ctx);
625
- if (outline)
626
- popClip(ctx);
627
- }
628
- }
629
31
  /** The output settings of a render: each one from `options` when given,
630
32
  * else from the document's `config.pdfGeneration` (a colour space only
631
33
  * while its `forceColorSpace` is on), else the default — RGB, bookmarks