@wirabyte/w-pdfmaker 0.0.0-stage → 1.0.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 (142) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/LICENSE +22 -0
  3. package/NOTICE.md +39 -0
  4. package/README.md +106 -2
  5. package/build/fonts/Roboto/Roboto-Italic.ttf +0 -0
  6. package/build/fonts/Roboto/Roboto-Medium.ttf +0 -0
  7. package/build/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  8. package/build/fonts/Roboto/Roboto-Regular.ttf +0 -0
  9. package/build/fonts/Roboto.js +27 -0
  10. package/build/pdfmake.js +103161 -0
  11. package/build/pdfmake.js.map +1 -0
  12. package/build/pdfmake.min.js +3 -0
  13. package/build/pdfmake.min.js.map +1 -0
  14. package/build/standard-fonts/Courier.js +9 -0
  15. package/build/standard-fonts/Helvetica.js +9 -0
  16. package/build/standard-fonts/Symbol.js +9 -0
  17. package/build/standard-fonts/Times.js +9 -0
  18. package/build/standard-fonts/ZapfDingbats.js +9 -0
  19. package/build/vfs_fonts.js +6 -0
  20. package/build-vfs.js +44 -0
  21. package/fonts/Roboto/Roboto-Italic.ttf +0 -0
  22. package/fonts/Roboto/Roboto-Medium.ttf +0 -0
  23. package/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  24. package/fonts/Roboto/Roboto-Regular.ttf +0 -0
  25. package/fonts/Roboto.js +8 -0
  26. package/fonts/THSarabunIT9/LICENSE.txt +7 -0
  27. package/fonts/THSarabunIT9/THSarabunIT9-Bold.ttf +0 -0
  28. package/fonts/THSarabunIT9/THSarabunIT9-BoldItalic.ttf +0 -0
  29. package/fonts/THSarabunIT9/THSarabunIT9-Italic.ttf +0 -0
  30. package/fonts/THSarabunIT9/THSarabunIT9.ttf +0 -0
  31. package/fonts/THSarabunNew/COPYING.GPLv2 +339 -0
  32. package/fonts/THSarabunNew/LICENSE.txt +13 -0
  33. package/fonts/THSarabunNew/THSarabunNew-Bold.ttf +0 -0
  34. package/fonts/THSarabunNew/THSarabunNew-BoldItalic.ttf +0 -0
  35. package/fonts/THSarabunNew/THSarabunNew-Italic.ttf +0 -0
  36. package/fonts/THSarabunNew/THSarabunNew.ttf +0 -0
  37. package/index.d.ts +167 -0
  38. package/interfaces.d.ts +2779 -0
  39. package/js/DocMeasure.js +695 -0
  40. package/js/DocPreprocessor.js +263 -0
  41. package/js/DocumentContext.js +563 -0
  42. package/js/ElementWriter.js +488 -0
  43. package/js/LayoutBuilder.js +1525 -0
  44. package/js/Line.js +105 -0
  45. package/js/OutputDocument.js +73 -0
  46. package/js/OutputDocumentServer.js +34 -0
  47. package/js/PDFDocument.js +322 -0
  48. package/js/PageElementWriter.js +302 -0
  49. package/js/PageSize.js +74 -0
  50. package/js/Printer.js +275 -0
  51. package/js/Renderer.js +439 -0
  52. package/js/SVGMeasure.js +94 -0
  53. package/js/StyleContextStack.js +191 -0
  54. package/js/TableProcessor.js +658 -0
  55. package/js/TextBreaker.js +164 -0
  56. package/js/TextDecorator.js +164 -0
  57. package/js/TextInlines.js +212 -0
  58. package/js/URLResolver.js +122 -0
  59. package/js/base.js +125 -0
  60. package/js/browser-extensions/OutputDocumentBrowser.js +82 -0
  61. package/js/browser-extensions/fonts/Roboto.js +38 -0
  62. package/js/browser-extensions/fonts/thai.js +28 -0
  63. package/js/browser-extensions/index.js +88 -0
  64. package/js/browser-extensions/pageUrls.js +79 -0
  65. package/js/browser-extensions/pdfMake.js +3 -0
  66. package/js/browser-extensions/standard-fonts/Courier.js +20 -0
  67. package/js/browser-extensions/standard-fonts/Helvetica.js +20 -0
  68. package/js/browser-extensions/standard-fonts/Symbol.js +17 -0
  69. package/js/browser-extensions/standard-fonts/Times.js +20 -0
  70. package/js/browser-extensions/standard-fonts/ZapfDingbats.js +17 -0
  71. package/js/browser-extensions/virtual-fs-cjs.js +3 -0
  72. package/js/columnCalculator.js +159 -0
  73. package/js/helpers/node.js +122 -0
  74. package/js/helpers/tools.js +46 -0
  75. package/js/helpers/variableType.js +59 -0
  76. package/js/imageFallback.js +23 -0
  77. package/js/index.js +45 -0
  78. package/js/mergeStamp.js +194 -0
  79. package/js/pageNumbering.js +48 -0
  80. package/js/qrEnc.js +721 -0
  81. package/js/standardPageSizes.js +56 -0
  82. package/js/tableLayouts.js +98 -0
  83. package/js/thai.js +201 -0
  84. package/js/virtual-fs.js +82 -0
  85. package/package.json +93 -4
  86. package/skills/w-pdfmaker/SKILL.md +171 -0
  87. package/skills/w-pdfmaker/references/browser.md +36 -0
  88. package/skills/w-pdfmaker/references/document-definition.md +241 -0
  89. package/skills/w-pdfmaker/references/images.md +90 -0
  90. package/skills/w-pdfmaker/references/merge-stamp.md +94 -0
  91. package/skills/w-pdfmaker/references/thai.md +67 -0
  92. package/src/DocMeasure.js +780 -0
  93. package/src/DocPreprocessor.js +293 -0
  94. package/src/DocumentContext.js +605 -0
  95. package/src/ElementWriter.js +550 -0
  96. package/src/LayoutBuilder.js +1689 -0
  97. package/src/Line.js +114 -0
  98. package/src/OutputDocument.js +75 -0
  99. package/src/OutputDocumentServer.js +38 -0
  100. package/src/PDFDocument.js +352 -0
  101. package/src/PageElementWriter.js +343 -0
  102. package/src/PageSize.js +53 -0
  103. package/src/Printer.js +289 -0
  104. package/src/Renderer.js +468 -0
  105. package/src/SVGMeasure.js +109 -0
  106. package/src/StyleContextStack.js +208 -0
  107. package/src/TableProcessor.js +719 -0
  108. package/src/TextBreaker.js +166 -0
  109. package/src/TextDecorator.js +191 -0
  110. package/src/TextInlines.js +229 -0
  111. package/src/URLResolver.js +122 -0
  112. package/src/base.js +143 -0
  113. package/src/browser-extensions/OutputDocumentBrowser.js +80 -0
  114. package/src/browser-extensions/fonts/Roboto.js +27 -0
  115. package/src/browser-extensions/fonts/thai.js +23 -0
  116. package/src/browser-extensions/index.js +91 -0
  117. package/src/browser-extensions/pageUrls.js +67 -0
  118. package/src/browser-extensions/pdfMake.js +1 -0
  119. package/src/browser-extensions/standard-fonts/Courier.js +25 -0
  120. package/src/browser-extensions/standard-fonts/Helvetica.js +25 -0
  121. package/src/browser-extensions/standard-fonts/Symbol.js +17 -0
  122. package/src/browser-extensions/standard-fonts/Times.js +25 -0
  123. package/src/browser-extensions/standard-fonts/ZapfDingbats.js +17 -0
  124. package/src/browser-extensions/virtual-fs-cjs.js +1 -0
  125. package/src/columnCalculator.js +160 -0
  126. package/src/helpers/node.js +134 -0
  127. package/src/helpers/tools.js +44 -0
  128. package/src/helpers/variableType.js +50 -0
  129. package/src/imageFallback.js +18 -0
  130. package/src/index.js +45 -0
  131. package/src/mergeStamp.js +132 -0
  132. package/src/pageNumbering.js +45 -0
  133. package/src/qrEnc.js +796 -0
  134. package/src/standardPageSizes.js +52 -0
  135. package/src/tableLayouts.js +100 -0
  136. package/src/thai.js +170 -0
  137. package/src/virtual-fs.js +92 -0
  138. package/standard-fonts/Courier.js +8 -0
  139. package/standard-fonts/Helvetica.js +8 -0
  140. package/standard-fonts/Symbol.js +5 -0
  141. package/standard-fonts/Times.js +8 -0
  142. package/standard-fonts/ZapfDingbats.js +5 -0
@@ -0,0 +1,67 @@
1
+ # Thai text
2
+
3
+ ## Fonts
4
+
5
+ Registered in both Node and the browser, no `setFonts` or `vfs_fonts.js` needed:
6
+
7
+ | Name | Use | Styles |
8
+ |---|---|---|
9
+ | `THSarabunNew` | default when no font is set | normal, `bold`, `italics`, both |
10
+ | `THSarabunIT9` | TH SarabunIT๙: draws `0–9` as Thai numerals (๐–๙) | normal, `bold`, `italics`, both |
11
+
12
+ - Both default to **16pt** when the document sets no `fontSize` (pdfmake's default is 12). Thai official documents
13
+ use 16pt body text; titles such as "บันทึกข้อความ" are often 29pt bold.
14
+ - `THSarabunIT9` changes only the drawing: the text is still `0–9`, so copying, searching and screen readers see
15
+ Arabic digits. If the real characters must be Thai numerals, convert the string itself (`๐๑๒๓๔๕๖๗๘๙`), which any
16
+ Thai font draws.
17
+ - A TH Sarabun line is about 1.3× the font size tall (16pt → ~21pt). Adjust with `lineHeight` (a multiplier).
18
+ - Fonts are subset when embedded, so only used glyphs add to the file size.
19
+
20
+ Mixing fonts:
21
+
22
+ ```js
23
+ pdfmake.addFonts({
24
+ Kanit: { normal: '/abs/fonts/Kanit-Regular.ttf', bold: '/abs/fonts/Kanit-Bold.ttf' },
25
+ });
26
+ pdfmake.addFonts(require('@wirabyte/w-pdfmaker/fonts/Roboto')); // Roboto for Latin text (Node)
27
+ // then { text: 'Hello', font: 'Roboto' } or defaultStyle: { font: 'Roboto' }
28
+ ```
29
+
30
+ Use `addFonts`, which keeps the Thai fonts. `setFonts` replaces the whole set; if `THSarabunNew` is missing from it,
31
+ documents without a font get pdfmake's own defaults (Roboto, 12pt), which has no Thai glyphs.
32
+ `clearFonts()` removes all fonts. A style without its file (e.g. `italics` missing from a custom font) throws when
33
+ used.
34
+
35
+ ## Line breaking
36
+
37
+ Thai has no spaces between words, so pdfmake alone would treat a Thai sentence as one unbreakable word.
38
+ w-pdfmaker breaks Thai text between words using the platform's `Intl.Segmenter` (dictionary-based, Node 20+ and
39
+ current browsers). Do not insert zero-width spaces, run wordcut, or patch the line breaker: older projects did this,
40
+ and it is now redundant.
41
+
42
+ `noWrap: true` keeps a text on one line; `wordBreak: 'break-all'` allows breaking anywhere (e.g. long IDs).
43
+
44
+ ## Alignment
45
+
46
+ | `alignment` | Spreads extra space | Use for |
47
+ |---|---|---|
48
+ | `'distribute'` | between characters (grapheme clusters), like Word's "Thai Distributed" | justified Thai paragraphs |
49
+ | `'justify'` | between words (break points) | English / Latin text |
50
+ | `left`, `center`, `right` | none | as usual |
51
+
52
+ `'justify'` on Thai text leaves visible gaps, because every Thai word boundary counts as a break point. The last
53
+ line of a paragraph and lines ending in a forced newline are not spread (same as `justify`). Vowels and tone marks
54
+ stay on their consonant.
55
+
56
+ Typical Thai paragraph:
57
+
58
+ ```js
59
+ { text: paragraph, alignment: 'distribute', leadingIndent: 70.9 } // first line indented 2.5 cm
60
+ ```
61
+
62
+ ## Copying and searching ำ (SARA AM)
63
+
64
+ Fonts draw ำ as two glyphs (ํ + า), which made PDF viewers copy and search "ํา" instead of "ำ". w-pdfmaker
65
+ writes the original text alongside the glyphs (PDF `ActualText`), so copy and search work in Chrome, Acrobat and
66
+ MuPDF. This applies to `createPdf` and to text drawn by `stamp`. Text already inside a PDF passed to `merge` or
67
+ `stamp` is left as it is.