@patrickdk77/xfa-flatten 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/LICENSE-APACHE-2.0 +202 -0
  3. package/NOTICE +14 -0
  4. package/README.md +112 -2
  5. package/dist/barcode-paint.d.ts +11 -0
  6. package/dist/barcode-paint.js +135 -0
  7. package/dist/barcode.d.ts +45 -0
  8. package/dist/barcode.js +750 -0
  9. package/dist/canvas.d.ts +59 -0
  10. package/dist/canvas.js +179 -0
  11. package/dist/cli.d.ts +2 -0
  12. package/dist/cli.js +34 -0
  13. package/dist/css.d.ts +48 -0
  14. package/dist/css.js +288 -0
  15. package/dist/deadline.d.ts +6 -0
  16. package/dist/deadline.js +18 -0
  17. package/dist/filters.d.ts +21 -0
  18. package/dist/filters.js +296 -0
  19. package/dist/flatten.d.ts +25 -0
  20. package/dist/flatten.js +319 -0
  21. package/dist/font-metrics.d.ts +9 -0
  22. package/dist/font-metrics.js +215 -0
  23. package/dist/fonts.d.ts +36 -0
  24. package/dist/fonts.js +144 -0
  25. package/dist/images.d.ts +23 -0
  26. package/dist/images.js +519 -0
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.js +5 -0
  29. package/dist/index.mjs +3 -0
  30. package/dist/layout.d.ts +64 -0
  31. package/dist/layout.js +779 -0
  32. package/dist/limits.d.ts +2 -0
  33. package/dist/limits.js +6 -0
  34. package/dist/locale.d.ts +29 -0
  35. package/dist/locale.js +97 -0
  36. package/dist/paint.d.ts +15 -0
  37. package/dist/paint.js +533 -0
  38. package/dist/pdf-crypt.d.ts +35 -0
  39. package/dist/pdf-crypt.js +261 -0
  40. package/dist/pdf-read.d.ts +140 -0
  41. package/dist/pdf-read.js +1026 -0
  42. package/dist/pdf417-table.d.ts +2 -0
  43. package/dist/pdf417-table.js +146 -0
  44. package/dist/pdfjs-repair.d.ts +13 -0
  45. package/dist/pdfjs-repair.js +257 -0
  46. package/dist/pdfjs.d.ts +16 -0
  47. package/dist/pdfjs.js +62 -0
  48. package/dist/picture.d.ts +40 -0
  49. package/dist/picture.js +678 -0
  50. package/dist/saslprep.d.ts +11 -0
  51. package/dist/saslprep.js +178 -0
  52. package/dist/style.d.ts +29 -0
  53. package/dist/style.js +178 -0
  54. package/dist/text.d.ts +44 -0
  55. package/dist/text.js +199 -0
  56. package/dist/tiff.d.ts +3 -0
  57. package/dist/tiff.js +270 -0
  58. package/dist/tree.d.ts +23 -0
  59. package/dist/tree.js +54 -0
  60. package/dist/types.d.ts +31 -0
  61. package/dist/types.js +2 -0
  62. package/dist/writer.d.ts +38 -0
  63. package/dist/writer.js +145 -0
  64. package/dist/xfa-apply.d.ts +49 -0
  65. package/dist/xfa-apply.js +617 -0
  66. package/dist/xfa-model.d.ts +42 -0
  67. package/dist/xfa-model.js +227 -0
  68. package/dist/xfa-paint.d.ts +24 -0
  69. package/dist/xfa-paint.js +275 -0
  70. package/dist/xfa-spec.d.ts +47 -0
  71. package/dist/xfa-spec.js +3 -0
  72. package/dist/xml.d.ts +30 -0
  73. package/dist/xml.js +211 -0
  74. package/package.json +83 -4
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ // Generated by scripts/make-font-metrics.js from Adobe Core14 AFM files. Do not edit.
3
+ // Widths are in 1/1000 em. Text fonts are indexed by WinAnsiEncoding code; ZapfDingbats by its built-in code.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.FONT_METRICS = void 0;
6
+ exports.FONT_METRICS = {
7
+ Helvetica: {
8
+ widths: [
9
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556,
10
+ 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667,
11
+ 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 350,
12
+ 556, 350, 222, 556, 333, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 222, 222, 333, 333, 350, 556, 1000, 333, 1000, 500, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556,
13
+ 260, 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 556, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667,
14
+ 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556,
15
+ 556, 556, 556, 556, 584, 611, 556, 556, 556, 556, 500, 556, 500,
16
+ ],
17
+ ascender: 718,
18
+ descender: -207,
19
+ capHeight: 718,
20
+ underlinePosition: -100,
21
+ underlineThickness: 50,
22
+ },
23
+ 'Helvetica-Bold': {
24
+ widths: [
25
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556,
26
+ 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667,
27
+ 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 350, 556,
28
+ 350, 278, 556, 500, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 278, 278, 500, 500, 350, 556, 1000, 333, 1000, 556, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556, 280,
29
+ 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 611, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278,
30
+ 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611,
31
+ 611, 611, 611, 584, 611, 611, 611, 611, 611, 556, 611, 556,
32
+ ],
33
+ ascender: 718,
34
+ descender: -207,
35
+ capHeight: 718,
36
+ underlinePosition: -100,
37
+ underlineThickness: 50,
38
+ },
39
+ 'Helvetica-Oblique': {
40
+ widths: [
41
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556,
42
+ 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667,
43
+ 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584, 350,
44
+ 556, 350, 222, 556, 333, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 222, 222, 333, 333, 350, 556, 1000, 333, 1000, 500, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556,
45
+ 260, 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 556, 537, 278, 333, 333, 365, 556, 834, 834, 834, 611, 667, 667, 667, 667, 667, 667, 1000, 722, 667, 667, 667, 667,
46
+ 278, 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 500, 556, 556, 556, 556, 278, 278, 278, 278, 556, 556, 556,
47
+ 556, 556, 556, 556, 584, 611, 556, 556, 556, 556, 500, 556, 500,
48
+ ],
49
+ ascender: 718,
50
+ descender: -207,
51
+ capHeight: 718,
52
+ underlinePosition: -100,
53
+ underlineThickness: 50,
54
+ },
55
+ 'Helvetica-BoldOblique': {
56
+ widths: [
57
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556,
58
+ 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667,
59
+ 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584, 350, 556,
60
+ 350, 278, 556, 500, 1000, 556, 556, 333, 1000, 667, 333, 1000, 350, 611, 350, 350, 278, 278, 500, 500, 350, 556, 1000, 333, 1000, 556, 333, 944, 350, 500, 667, 278, 333, 556, 556, 556, 556, 280,
61
+ 556, 333, 737, 370, 556, 584, 333, 737, 333, 400, 584, 333, 333, 333, 611, 556, 278, 333, 333, 365, 556, 834, 834, 834, 611, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667, 278,
62
+ 278, 278, 278, 722, 722, 778, 778, 778, 778, 778, 584, 778, 722, 722, 722, 722, 667, 667, 611, 556, 556, 556, 556, 556, 556, 889, 556, 556, 556, 556, 556, 278, 278, 278, 278, 611, 611, 611, 611,
63
+ 611, 611, 611, 584, 611, 611, 611, 611, 611, 556, 611, 556,
64
+ ],
65
+ ascender: 718,
66
+ descender: -207,
67
+ capHeight: 718,
68
+ underlinePosition: -100,
69
+ underlineThickness: 50,
70
+ },
71
+ 'Times-Roman': {
72
+ widths: [
73
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 408, 500, 500, 833, 778, 180, 333, 333, 500, 564, 250, 333, 250, 278, 500, 500, 500,
74
+ 500, 500, 500, 500, 500, 500, 500, 278, 278, 564, 564, 564, 444, 921, 722, 667, 667, 722, 611, 556, 722, 722, 333, 389, 722, 611, 889, 722, 722, 556, 722, 667, 556, 611, 722, 722, 944, 722, 722,
75
+ 611, 333, 278, 333, 469, 500, 333, 444, 500, 444, 500, 444, 333, 500, 500, 278, 278, 500, 278, 778, 500, 500, 500, 500, 333, 389, 278, 500, 500, 722, 500, 500, 444, 480, 200, 480, 541, 350, 500,
76
+ 350, 333, 500, 444, 1000, 500, 500, 333, 1000, 556, 333, 889, 350, 611, 350, 350, 333, 333, 444, 444, 350, 500, 1000, 333, 980, 389, 333, 722, 350, 444, 722, 250, 333, 500, 500, 500, 500, 200,
77
+ 500, 333, 760, 276, 500, 564, 333, 760, 333, 400, 564, 300, 300, 333, 500, 453, 250, 333, 300, 310, 500, 750, 750, 750, 444, 722, 722, 722, 722, 722, 722, 889, 667, 611, 611, 611, 611, 333, 333,
78
+ 333, 333, 722, 722, 722, 722, 722, 722, 722, 564, 722, 722, 722, 722, 722, 722, 556, 500, 444, 444, 444, 444, 444, 444, 667, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500,
79
+ 500, 500, 564, 500, 500, 500, 500, 500, 500, 500, 500,
80
+ ],
81
+ ascender: 683,
82
+ descender: -217,
83
+ capHeight: 662,
84
+ underlinePosition: -100,
85
+ underlineThickness: 50,
86
+ },
87
+ 'Times-Bold': {
88
+ widths: [
89
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 555, 500, 500, 1000, 833, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500,
90
+ 500, 500, 500, 500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 930, 722, 667, 722, 722, 667, 611, 778, 778, 389, 500, 778, 667, 944, 722, 778, 611, 778, 722, 556, 667, 722, 722, 1000, 722,
91
+ 722, 667, 333, 278, 333, 581, 500, 333, 500, 556, 444, 556, 444, 333, 500, 556, 278, 333, 556, 278, 833, 556, 500, 556, 556, 444, 389, 333, 556, 500, 722, 500, 500, 444, 394, 220, 394, 520, 350,
92
+ 500, 350, 333, 500, 500, 1000, 500, 500, 333, 1000, 556, 333, 1000, 350, 667, 350, 350, 333, 333, 500, 500, 350, 500, 1000, 333, 1000, 389, 333, 722, 350, 444, 722, 250, 333, 500, 500, 500, 500,
93
+ 220, 500, 333, 747, 300, 500, 570, 333, 747, 333, 400, 570, 300, 300, 333, 556, 540, 250, 333, 300, 330, 500, 750, 750, 750, 500, 722, 722, 722, 722, 722, 722, 1000, 722, 667, 667, 667, 667,
94
+ 389, 389, 389, 389, 722, 722, 778, 778, 778, 778, 778, 570, 778, 722, 722, 722, 722, 722, 611, 556, 500, 500, 500, 500, 500, 500, 722, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 556, 500,
95
+ 500, 500, 500, 500, 570, 500, 556, 556, 556, 556, 500, 556, 500,
96
+ ],
97
+ ascender: 683,
98
+ descender: -217,
99
+ capHeight: 676,
100
+ underlinePosition: -100,
101
+ underlineThickness: 50,
102
+ },
103
+ 'Times-Italic': {
104
+ widths: [
105
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 333, 420, 500, 500, 833, 778, 214, 333, 333, 500, 675, 250, 333, 250, 278, 500, 500, 500,
106
+ 500, 500, 500, 500, 500, 500, 500, 333, 333, 675, 675, 675, 500, 920, 611, 611, 667, 722, 611, 611, 722, 722, 333, 444, 667, 556, 833, 667, 722, 611, 722, 611, 500, 556, 722, 611, 833, 611, 556,
107
+ 556, 389, 278, 389, 422, 500, 333, 500, 500, 444, 500, 444, 278, 500, 500, 278, 278, 444, 278, 722, 500, 500, 500, 500, 389, 389, 278, 500, 444, 667, 444, 444, 389, 400, 275, 400, 541, 350, 500,
108
+ 350, 333, 500, 556, 889, 500, 500, 333, 1000, 500, 333, 944, 350, 556, 350, 350, 333, 333, 556, 556, 350, 500, 889, 333, 980, 389, 333, 667, 350, 389, 556, 250, 389, 500, 500, 500, 500, 275,
109
+ 500, 333, 760, 276, 500, 675, 333, 760, 333, 400, 675, 300, 300, 333, 500, 523, 250, 333, 300, 310, 500, 750, 750, 750, 500, 611, 611, 611, 611, 611, 611, 889, 667, 611, 611, 611, 611, 333, 333,
110
+ 333, 333, 722, 667, 722, 722, 722, 722, 722, 675, 722, 722, 722, 722, 722, 556, 611, 500, 500, 500, 500, 500, 500, 500, 667, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 500, 500, 500, 500,
111
+ 500, 500, 675, 500, 500, 500, 500, 500, 444, 500, 444,
112
+ ],
113
+ ascender: 683,
114
+ descender: -217,
115
+ capHeight: 653,
116
+ underlinePosition: -100,
117
+ underlineThickness: 50,
118
+ },
119
+ 'Times-BoldItalic': {
120
+ widths: [
121
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 389, 555, 500, 500, 833, 778, 278, 333, 333, 500, 570, 250, 333, 250, 278, 500, 500, 500,
122
+ 500, 500, 500, 500, 500, 500, 500, 333, 333, 570, 570, 570, 500, 832, 667, 667, 667, 722, 667, 667, 722, 778, 389, 500, 667, 611, 889, 722, 722, 611, 722, 667, 556, 611, 722, 667, 889, 667, 611,
123
+ 611, 333, 278, 333, 570, 500, 333, 500, 500, 444, 500, 444, 333, 500, 556, 278, 278, 500, 278, 778, 556, 500, 500, 500, 389, 389, 278, 556, 444, 667, 500, 444, 389, 348, 220, 348, 570, 350, 500,
124
+ 350, 333, 500, 500, 1000, 500, 500, 333, 1000, 556, 333, 944, 350, 611, 350, 350, 333, 333, 500, 500, 350, 500, 1000, 333, 1000, 389, 333, 722, 350, 389, 611, 250, 389, 500, 500, 500, 500, 220,
125
+ 500, 333, 747, 266, 500, 606, 333, 747, 333, 400, 570, 300, 300, 333, 576, 500, 250, 333, 300, 300, 500, 750, 750, 750, 500, 667, 667, 667, 667, 667, 667, 944, 667, 667, 667, 667, 667, 389, 389,
126
+ 389, 389, 722, 722, 722, 722, 722, 722, 722, 570, 722, 722, 722, 722, 722, 611, 611, 500, 500, 500, 500, 500, 500, 500, 722, 444, 444, 444, 444, 444, 278, 278, 278, 278, 500, 556, 500, 500, 500,
127
+ 500, 500, 570, 500, 556, 556, 556, 556, 444, 500, 444,
128
+ ],
129
+ ascender: 683,
130
+ descender: -217,
131
+ capHeight: 669,
132
+ underlinePosition: -100,
133
+ underlineThickness: 50,
134
+ },
135
+ Courier: {
136
+ widths: [
137
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
138
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
139
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
140
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
141
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
142
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
143
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
144
+ ],
145
+ ascender: 629,
146
+ descender: -157,
147
+ capHeight: 562,
148
+ underlinePosition: -100,
149
+ underlineThickness: 50,
150
+ },
151
+ 'Courier-Bold': {
152
+ widths: [
153
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
154
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
155
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
156
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
157
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
158
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
159
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
160
+ ],
161
+ ascender: 629,
162
+ descender: -157,
163
+ capHeight: 562,
164
+ underlinePosition: -100,
165
+ underlineThickness: 50,
166
+ },
167
+ 'Courier-Oblique': {
168
+ widths: [
169
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
170
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
171
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
172
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
173
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
174
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
175
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
176
+ ],
177
+ ascender: 629,
178
+ descender: -157,
179
+ capHeight: 562,
180
+ underlinePosition: -100,
181
+ underlineThickness: 50,
182
+ },
183
+ 'Courier-BoldOblique': {
184
+ widths: [
185
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
186
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
187
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
188
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
189
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
190
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
191
+ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600,
192
+ ],
193
+ ascender: 629,
194
+ descender: -157,
195
+ capHeight: 562,
196
+ underlinePosition: -100,
197
+ underlineThickness: 50,
198
+ },
199
+ ZapfDingbats: {
200
+ widths: [
201
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 278, 974, 961, 974, 980, 719, 789, 790, 791, 690, 960, 939, 549, 855, 911, 933, 911, 945, 974,
202
+ 755, 846, 762, 761, 571, 677, 763, 760, 759, 754, 494, 552, 537, 577, 692, 786, 788, 788, 790, 793, 794, 816, 823, 789, 841, 823, 833, 816, 831, 923, 744, 723, 749, 790, 792, 695, 776, 768, 792,
203
+ 759, 707, 708, 682, 701, 826, 815, 789, 789, 707, 687, 696, 689, 786, 787, 713, 791, 785, 791, 873, 761, 762, 762, 759, 759, 892, 892, 788, 784, 438, 138, 277, 415, 392, 392, 668, 668, 0, 390,
204
+ 390, 317, 317, 276, 276, 509, 509, 410, 410, 234, 234, 334, 334, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 732, 544, 544, 910, 667, 760, 760, 776, 595, 694, 626, 788, 788, 788,
205
+ 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 788, 894, 838,
206
+ 1016, 458, 748, 924, 748, 918, 927, 928, 928, 834, 873, 828, 924, 924, 917, 930, 931, 463, 883, 836, 836, 867, 867, 696, 696, 874, 0, 874, 760, 946, 771, 865, 771, 888, 967, 888, 831, 873, 927,
207
+ 970, 918, 0,
208
+ ],
209
+ ascender: 0,
210
+ descender: 0,
211
+ capHeight: 0,
212
+ underlinePosition: -100,
213
+ underlineThickness: 50,
214
+ },
215
+ };
@@ -0,0 +1,36 @@
1
+ import { type FontMetrics } from './font-metrics';
2
+ export type FontName = 'Helvetica' | 'Helvetica-Bold' | 'Helvetica-Oblique' | 'Helvetica-BoldOblique' | 'Times-Roman' | 'Times-Bold' | 'Times-Italic' | 'Times-BoldItalic' | 'Courier' | 'Courier-Bold' | 'Courier-Oblique' | 'Courier-BoldOblique' | 'ZapfDingbats';
3
+ /** Font face as CSS describes it. */
4
+ export interface FaceSpec {
5
+ family: string;
6
+ bold: boolean;
7
+ italic: boolean;
8
+ }
9
+ /** Picks the standard 14 font for a CSS font family, weight and style. */
10
+ export declare function pickFont(spec: FaceSpec): FontName;
11
+ export declare function metricsOf(font: FontName): FontMetrics;
12
+ /**
13
+ * Ascent and descent a browser would use for the line box, as a fraction of the font size. These follow the
14
+ * fonts a browser substitutes (Arial, Times New Roman, Courier New), not the AFM values, so that text sits where
15
+ * pdf.js's layout expects it.
16
+ */
17
+ export declare function lineMetrics(font: FontName): {
18
+ ascent: number;
19
+ descent: number;
20
+ };
21
+ /** Encodes a string as WinAnsi bytes. Characters WinAnsi cannot encode become '?' and are reported. */
22
+ export declare function encodeWinAnsi(s: string): {
23
+ bytes: number[];
24
+ unencodable: string[];
25
+ };
26
+ /** Width in text space units (1/1000 em) of WinAnsi bytes. */
27
+ export declare function bytesWidth(font: FontName, bytes: readonly number[]): number;
28
+ /** Width in points of a string at a size, with letter spacing added after every character. */
29
+ export declare function textWidth(font: FontName, s: string, size: number, letterSpacing?: number): number;
30
+ /**
31
+ * How wide a family's text runs compared with Helvetica. pdf.js measures XFA text with the form's own font, or
32
+ * with its metric tables for Myriad Pro, Calibri and Segoe UI; drawing Helvetica narrowed by this factor keeps
33
+ * line breaks and fits close to pdf.js's layout. The factors are averages over ordinary English text, taken from
34
+ * pdf.js's per-glyph width factors.
35
+ */
36
+ export declare function familyScale(cssFamily: string, bold: boolean): number;
package/dist/fonts.js ADDED
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ // The standard 14 fonts: choosing one for a CSS font, encoding text as WinAnsi, and measuring it.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.pickFont = pickFont;
5
+ exports.metricsOf = metricsOf;
6
+ exports.lineMetrics = lineMetrics;
7
+ exports.encodeWinAnsi = encodeWinAnsi;
8
+ exports.bytesWidth = bytesWidth;
9
+ exports.textWidth = textWidth;
10
+ exports.familyScale = familyScale;
11
+ const font_metrics_1 = require("./font-metrics");
12
+ function familyOf(cssFamily) {
13
+ const f = cssFamily.toLowerCase().replace(/-pdfjs-xfa/g, '');
14
+ if (/courier|mono|consol|lucida console|fixed|typewriter|ocr/.test(f))
15
+ return 'mono';
16
+ if (/times|serif|garamond|georgia|minion|palatino|book antiqua|cambria|century|bodoni|baskerville/.test(f) && !/sans/.test(f))
17
+ return 'serif';
18
+ return 'sans';
19
+ }
20
+ /** Picks the standard 14 font for a CSS font family, weight and style. */
21
+ function pickFont(spec) {
22
+ const fam = familyOf(spec.family);
23
+ const b = spec.bold;
24
+ const i = spec.italic;
25
+ switch (fam) {
26
+ case 'serif':
27
+ return b && i ? 'Times-BoldItalic' : b ? 'Times-Bold' : i ? 'Times-Italic' : 'Times-Roman';
28
+ case 'mono':
29
+ return b && i ? 'Courier-BoldOblique' : b ? 'Courier-Bold' : i ? 'Courier-Oblique' : 'Courier';
30
+ default:
31
+ return b && i ? 'Helvetica-BoldOblique' : b ? 'Helvetica-Bold' : i ? 'Helvetica-Oblique' : 'Helvetica';
32
+ }
33
+ }
34
+ function metricsOf(font) {
35
+ return font_metrics_1.FONT_METRICS[font];
36
+ }
37
+ /**
38
+ * Ascent and descent a browser would use for the line box, as a fraction of the font size. These follow the
39
+ * fonts a browser substitutes (Arial, Times New Roman, Courier New), not the AFM values, so that text sits where
40
+ * pdf.js's layout expects it.
41
+ */
42
+ function lineMetrics(font) {
43
+ if (font.startsWith('Times'))
44
+ return { ascent: 0.891, descent: 0.216 };
45
+ if (font.startsWith('Courier'))
46
+ return { ascent: 0.833, descent: 0.3 };
47
+ return { ascent: 0.905, descent: 0.212 };
48
+ }
49
+ // Unicode code points for WinAnsi codes 0x80 to 0x9F; 0 where the code is unused.
50
+ const HIGH = [
51
+ 0x20ac, 0, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, 0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0, 0x017d, 0, 0, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x02dc, 0x2122, 0x0161,
52
+ 0x203a, 0x0153, 0, 0x017e, 0x0178,
53
+ ];
54
+ const TO_WIN_ANSI = new Map();
55
+ for (let c = 0x20; c <= 0x7e; c++)
56
+ TO_WIN_ANSI.set(c, c);
57
+ for (let c = 0xa0; c <= 0xff; c++)
58
+ TO_WIN_ANSI.set(c, c);
59
+ HIGH.forEach((u, i) => {
60
+ if (u)
61
+ TO_WIN_ANSI.set(u, 0x80 + i);
62
+ });
63
+ // Characters that have a close WinAnsi stand-in.
64
+ const STAND_INS = new Map([
65
+ [0x09, 0x20],
66
+ [0x2007, 0x20],
67
+ [0x2002, 0x20],
68
+ [0x2003, 0x20],
69
+ [0x2009, 0x20],
70
+ [0x200a, 0x20],
71
+ [0x202f, 0x20],
72
+ [0x2010, 0x2d],
73
+ [0x2011, 0x2d],
74
+ [0x2012, 0x96],
75
+ [0x2015, 0x97],
76
+ [0x2212, 0x2d],
77
+ [0x2032, 0x27],
78
+ [0x2033, 0x22],
79
+ [0x25cf, 0x95],
80
+ [0x25e6, 0x95],
81
+ [0x2219, 0x95],
82
+ [0x00ad, 0x2d],
83
+ ]);
84
+ /** Characters that take no space and draw nothing. */
85
+ const INVISIBLE = new Set([0x200b, 0x200c, 0x200d, 0x2060, 0xfeff]);
86
+ /** Encodes a string as WinAnsi bytes. Characters WinAnsi cannot encode become '?' and are reported. */
87
+ function encodeWinAnsi(s) {
88
+ const bytes = [];
89
+ const unencodable = [];
90
+ for (const ch of s) {
91
+ const cp = ch.codePointAt(0) ?? 0x3f;
92
+ if (INVISIBLE.has(cp))
93
+ continue;
94
+ const direct = TO_WIN_ANSI.get(cp);
95
+ if (direct !== undefined) {
96
+ bytes.push(direct);
97
+ continue;
98
+ }
99
+ const stand = STAND_INS.get(cp);
100
+ if (stand !== undefined) {
101
+ bytes.push(stand);
102
+ continue;
103
+ }
104
+ const decomposed = ch.normalize('NFD').codePointAt(0) ?? 0;
105
+ const base = TO_WIN_ANSI.get(decomposed);
106
+ if (base !== undefined && decomposed !== cp) {
107
+ bytes.push(base);
108
+ unencodable.push(ch);
109
+ continue;
110
+ }
111
+ bytes.push(0x3f);
112
+ unencodable.push(ch);
113
+ }
114
+ return { bytes, unencodable };
115
+ }
116
+ /** Width in text space units (1/1000 em) of WinAnsi bytes. */
117
+ function bytesWidth(font, bytes) {
118
+ const w = font_metrics_1.FONT_METRICS[font].widths;
119
+ let total = 0;
120
+ for (const b of bytes)
121
+ total += w[b] ?? 0;
122
+ return total;
123
+ }
124
+ /** Width in points of a string at a size, with letter spacing added after every character. */
125
+ function textWidth(font, s, size, letterSpacing = 0) {
126
+ const { bytes } = encodeWinAnsi(s);
127
+ return (bytesWidth(font, bytes) * size) / 1000 + letterSpacing * bytes.length;
128
+ }
129
+ /**
130
+ * How wide a family's text runs compared with Helvetica. pdf.js measures XFA text with the form's own font, or
131
+ * with its metric tables for Myriad Pro, Calibri and Segoe UI; drawing Helvetica narrowed by this factor keeps
132
+ * line breaks and fits close to pdf.js's layout. The factors are averages over ordinary English text, taken from
133
+ * pdf.js's per-glyph width factors.
134
+ */
135
+ function familyScale(cssFamily, bold) {
136
+ const f = cssFamily.toLowerCase();
137
+ if (/myriad/.test(f))
138
+ return bold ? 0.935 : 0.942;
139
+ if (/calibri/.test(f))
140
+ return bold ? 0.893 : 0.937;
141
+ if (/narrow|condensed/.test(f))
142
+ return 0.82;
143
+ return 1;
144
+ }
@@ -0,0 +1,23 @@
1
+ export interface DecodedImage {
2
+ width: number;
3
+ height: number;
4
+ colorSpace: 'DeviceGray' | 'DeviceRGB' | 'DeviceCMYK';
5
+ /** Samples, 8 bits per component, unless dct is set. */
6
+ data: Uint8Array;
7
+ /** The data is a JPEG stream to write with DCTDecode. */
8
+ dct: boolean;
9
+ /** Decode array for Adobe CMYK JPEGs, which store inverted samples. */
10
+ decode?: number[];
11
+ /** 8-bit alpha, one byte per pixel. */
12
+ alpha?: Uint8Array;
13
+ }
14
+ export type ImageResult = {
15
+ ok: true;
16
+ image: DecodedImage;
17
+ } | {
18
+ ok: false;
19
+ format: string;
20
+ reason: string;
21
+ };
22
+ export declare function sniffImage(b: Uint8Array): string;
23
+ export declare function decodeImage(bytes: Uint8Array): ImageResult;