pdfkit 0.11.0 → 0.12.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 (41) hide show
  1. package/CHANGELOG.md +61 -39
  2. package/LICENSE +7 -7
  3. package/README.md +182 -181
  4. package/js/data/Courier-Bold.afm +342 -342
  5. package/js/data/Courier-BoldOblique.afm +342 -342
  6. package/js/data/Courier-Oblique.afm +342 -342
  7. package/js/data/Courier.afm +342 -342
  8. package/js/data/Helvetica-Bold.afm +2827 -2827
  9. package/js/data/Helvetica-BoldOblique.afm +2827 -2827
  10. package/js/data/Helvetica-Oblique.afm +3051 -3051
  11. package/js/data/Helvetica.afm +3051 -3051
  12. package/js/data/Symbol.afm +213 -213
  13. package/js/data/Times-Bold.afm +2588 -2588
  14. package/js/data/Times-BoldItalic.afm +2384 -2384
  15. package/js/data/Times-Italic.afm +2667 -2667
  16. package/js/data/Times-Roman.afm +2419 -2419
  17. package/js/data/ZapfDingbats.afm +225 -225
  18. package/js/font/data/Courier-Bold.afm +342 -0
  19. package/js/font/data/Courier-BoldOblique.afm +342 -0
  20. package/js/font/data/Courier-Oblique.afm +342 -0
  21. package/js/font/data/Courier.afm +342 -0
  22. package/js/font/data/Helvetica-Bold.afm +2827 -0
  23. package/js/font/data/Helvetica-BoldOblique.afm +2827 -0
  24. package/js/font/data/Helvetica-Oblique.afm +3051 -0
  25. package/js/font/data/Helvetica.afm +3051 -0
  26. package/js/font/data/Symbol.afm +213 -0
  27. package/js/font/data/Times-Bold.afm +2588 -0
  28. package/js/font/data/Times-BoldItalic.afm +2384 -0
  29. package/js/font/data/Times-Italic.afm +2667 -0
  30. package/js/font/data/Times-Roman.afm +2419 -0
  31. package/js/font/data/ZapfDingbats.afm +225 -0
  32. package/js/pdfkit.es5.js +1277 -490
  33. package/js/pdfkit.es5.js.map +1 -1
  34. package/js/pdfkit.esnext.js +951 -190
  35. package/js/pdfkit.esnext.js.map +1 -1
  36. package/js/pdfkit.js +933 -189
  37. package/js/pdfkit.js.map +1 -1
  38. package/js/pdfkit.standalone.js +2894 -2011
  39. package/js/pdfkit.standalone.orig.js +68494 -0
  40. package/js/virtual-fs.js +3 -5
  41. package/package.json +93 -84
package/js/pdfkit.es5.js CHANGED
@@ -29,6 +29,55 @@ function _createClass(Constructor, protoProps, staticProps) {
29
29
  return Constructor;
30
30
  }
31
31
 
32
+ function _defineProperty(obj, key, value) {
33
+ if (key in obj) {
34
+ Object.defineProperty(obj, key, {
35
+ value: value,
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true
39
+ });
40
+ } else {
41
+ obj[key] = value;
42
+ }
43
+
44
+ return obj;
45
+ }
46
+
47
+ function ownKeys(object, enumerableOnly) {
48
+ var keys = Object.keys(object);
49
+
50
+ if (Object.getOwnPropertySymbols) {
51
+ var symbols = Object.getOwnPropertySymbols(object);
52
+ if (enumerableOnly) symbols = symbols.filter(function (sym) {
53
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
54
+ });
55
+ keys.push.apply(keys, symbols);
56
+ }
57
+
58
+ return keys;
59
+ }
60
+
61
+ function _objectSpread2(target) {
62
+ for (var i = 1; i < arguments.length; i++) {
63
+ var source = arguments[i] != null ? arguments[i] : {};
64
+
65
+ if (i % 2) {
66
+ ownKeys(Object(source), true).forEach(function (key) {
67
+ _defineProperty(target, key, source[key]);
68
+ });
69
+ } else if (Object.getOwnPropertyDescriptors) {
70
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
71
+ } else {
72
+ ownKeys(Object(source)).forEach(function (key) {
73
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
74
+ });
75
+ }
76
+ }
77
+
78
+ return target;
79
+ }
80
+
32
81
  function _inherits(subClass, superClass) {
33
82
  if (typeof superClass !== "function" && superClass !== null) {
34
83
  throw new TypeError("Super expression must either be null or a function");
@@ -60,6 +109,19 @@ function _setPrototypeOf(o, p) {
60
109
  return _setPrototypeOf(o, p);
61
110
  }
62
111
 
112
+ function _isNativeReflectConstruct() {
113
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
114
+ if (Reflect.construct.sham) return false;
115
+ if (typeof Proxy === "function") return true;
116
+
117
+ try {
118
+ Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
119
+ return true;
120
+ } catch (e) {
121
+ return false;
122
+ }
123
+ }
124
+
63
125
  function _assertThisInitialized(self) {
64
126
  if (self === void 0) {
65
127
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -76,20 +138,35 @@ function _possibleConstructorReturn(self, call) {
76
138
  return _assertThisInitialized(self);
77
139
  }
78
140
 
141
+ function _createSuper(Derived) {
142
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
143
+
144
+ return function _createSuperInternal() {
145
+ var Super = _getPrototypeOf(Derived),
146
+ result;
147
+
148
+ if (hasNativeReflectConstruct) {
149
+ var NewTarget = _getPrototypeOf(this).constructor;
150
+
151
+ result = Reflect.construct(Super, arguments, NewTarget);
152
+ } else {
153
+ result = Super.apply(this, arguments);
154
+ }
155
+
156
+ return _possibleConstructorReturn(this, result);
157
+ };
158
+ }
159
+
79
160
  function _slicedToArray(arr, i) {
80
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
161
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
81
162
  }
82
163
 
83
164
  function _toConsumableArray(arr) {
84
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
165
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
85
166
  }
86
167
 
87
168
  function _arrayWithoutHoles(arr) {
88
- if (Array.isArray(arr)) {
89
- for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
90
-
91
- return arr2;
92
- }
169
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
93
170
  }
94
171
 
95
172
  function _arrayWithHoles(arr) {
@@ -97,14 +174,11 @@ function _arrayWithHoles(arr) {
97
174
  }
98
175
 
99
176
  function _iterableToArray(iter) {
100
- if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
177
+ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
101
178
  }
102
179
 
103
180
  function _iterableToArrayLimit(arr, i) {
104
- if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
105
- return;
106
- }
107
-
181
+ if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
108
182
  var _arr = [];
109
183
  var _n = true;
110
184
  var _d = false;
@@ -130,20 +204,92 @@ function _iterableToArrayLimit(arr, i) {
130
204
  return _arr;
131
205
  }
132
206
 
207
+ function _unsupportedIterableToArray(o, minLen) {
208
+ if (!o) return;
209
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
210
+ var n = Object.prototype.toString.call(o).slice(8, -1);
211
+ if (n === "Object" && o.constructor) n = o.constructor.name;
212
+ if (n === "Map" || n === "Set") return Array.from(o);
213
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
214
+ }
215
+
216
+ function _arrayLikeToArray(arr, len) {
217
+ if (len == null || len > arr.length) len = arr.length;
218
+
219
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
220
+
221
+ return arr2;
222
+ }
223
+
133
224
  function _nonIterableSpread() {
134
- throw new TypeError("Invalid attempt to spread non-iterable instance");
225
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
135
226
  }
136
227
 
137
228
  function _nonIterableRest() {
138
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
229
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
230
+ }
231
+
232
+ function _createForOfIteratorHelper(o, allowArrayLike) {
233
+ var it;
234
+
235
+ if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
236
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
237
+ if (it) o = it;
238
+ var i = 0;
239
+
240
+ var F = function () {};
241
+
242
+ return {
243
+ s: F,
244
+ n: function () {
245
+ if (i >= o.length) return {
246
+ done: true
247
+ };
248
+ return {
249
+ done: false,
250
+ value: o[i++]
251
+ };
252
+ },
253
+ e: function (e) {
254
+ throw e;
255
+ },
256
+ f: F
257
+ };
258
+ }
259
+
260
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
261
+ }
262
+
263
+ var normalCompletion = true,
264
+ didErr = false,
265
+ err;
266
+ return {
267
+ s: function () {
268
+ it = o[Symbol.iterator]();
269
+ },
270
+ n: function () {
271
+ var step = it.next();
272
+ normalCompletion = step.done;
273
+ return step;
274
+ },
275
+ e: function (e) {
276
+ didErr = true;
277
+ err = e;
278
+ },
279
+ f: function () {
280
+ try {
281
+ if (!normalCompletion && it.return != null) it.return();
282
+ } finally {
283
+ if (didErr) throw err;
284
+ }
285
+ }
286
+ };
139
287
  }
140
288
 
141
- /*
142
- PDFAbstractReference - abstract class for PDF reference
289
+ /*
290
+ PDFAbstractReference - abstract class for PDF reference
143
291
  */
144
- var PDFAbstractReference =
145
- /*#__PURE__*/
146
- function () {
292
+ var PDFAbstractReference = /*#__PURE__*/function () {
147
293
  function PDFAbstractReference() {
148
294
  _classCallCheck(this, PDFAbstractReference);
149
295
  }
@@ -158,16 +304,18 @@ function () {
158
304
  return PDFAbstractReference;
159
305
  }();
160
306
 
161
- var PDFNameTree =
162
- /*#__PURE__*/
163
- function () {
164
- function PDFNameTree() {
165
- _classCallCheck(this, PDFNameTree);
307
+ var PDFTree = /*#__PURE__*/function () {
308
+ function PDFTree() {
309
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
310
+
311
+ _classCallCheck(this, PDFTree);
166
312
 
167
- this._items = {};
313
+ this._items = {}; // disable /Limits output for this tree
314
+
315
+ this.limits = typeof options.limits === 'boolean' ? options.limits : true;
168
316
  }
169
317
 
170
- _createClass(PDFNameTree, [{
318
+ _createClass(PDFTree, [{
171
319
  key: "add",
172
320
  value: function add(key, val) {
173
321
  return this._items[key] = val;
@@ -180,57 +328,69 @@ function () {
180
328
  }, {
181
329
  key: "toString",
182
330
  value: function toString() {
331
+ var _this = this;
332
+
183
333
  // Needs to be sorted by key
184
334
  var sortedKeys = Object.keys(this._items).sort(function (a, b) {
185
- return a.localeCompare(b);
335
+ return _this._compareKeys(a, b);
186
336
  });
187
337
  var out = ['<<'];
188
338
 
189
- if (sortedKeys.length > 1) {
339
+ if (this.limits && sortedKeys.length > 1) {
190
340
  var first = sortedKeys[0],
191
341
  last = sortedKeys[sortedKeys.length - 1];
192
- out.push(" /Limits ".concat(PDFObject.convert([new String(first), new String(last)])));
342
+ out.push(" /Limits ".concat(PDFObject.convert([this._dataForKey(first), this._dataForKey(last)])));
193
343
  }
194
344
 
195
- out.push(' /Names [');
196
- var _iteratorNormalCompletion = true;
197
- var _didIteratorError = false;
198
- var _iteratorError = undefined;
345
+ out.push(" /".concat(this._keysName(), " ["));
346
+
347
+ var _iterator = _createForOfIteratorHelper(sortedKeys),
348
+ _step;
199
349
 
200
350
  try {
201
- for (var _iterator = sortedKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
351
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
202
352
  var key = _step.value;
203
- out.push(" ".concat(PDFObject.convert(new String(key)), " ").concat(PDFObject.convert(this._items[key])));
353
+ out.push(" ".concat(PDFObject.convert(this._dataForKey(key)), " ").concat(PDFObject.convert(this._items[key])));
204
354
  }
205
355
  } catch (err) {
206
- _didIteratorError = true;
207
- _iteratorError = err;
356
+ _iterator.e(err);
208
357
  } finally {
209
- try {
210
- if (!_iteratorNormalCompletion && _iterator.return != null) {
211
- _iterator.return();
212
- }
213
- } finally {
214
- if (_didIteratorError) {
215
- throw _iteratorError;
216
- }
217
- }
358
+ _iterator.f();
218
359
  }
219
360
 
220
361
  out.push(']');
221
362
  out.push('>>');
222
363
  return out.join('\n');
223
364
  }
365
+ }, {
366
+ key: "_compareKeys",
367
+ value: function _compareKeys()
368
+ /*a, b*/
369
+ {
370
+ throw new Error('Must be implemented by subclasses');
371
+ }
372
+ }, {
373
+ key: "_keysName",
374
+ value: function _keysName() {
375
+ throw new Error('Must be implemented by subclasses');
376
+ }
377
+ }, {
378
+ key: "_dataForKey",
379
+ value: function _dataForKey()
380
+ /*k*/
381
+ {
382
+ throw new Error('Must be implemented by subclasses');
383
+ }
224
384
  }]);
225
385
 
226
- return PDFNameTree;
386
+ return PDFTree;
227
387
  }();
228
388
 
229
389
  var pad = function pad(str, length) {
230
390
  return (Array(length + 1).join('0') + str).slice(-length);
231
391
  };
232
392
 
233
- var escapableRe = /[\n\r\t\b\f\(\)\\]/g;
393
+ var escapableRe = /[\n\r\t\b\f()\\]/g;
234
394
  var escapable = {
235
395
  '\n': '\\n',
236
396
  '\r': '\\r',
@@ -258,9 +418,7 @@ var swapBytes = function swapBytes(buff) {
258
418
  return buff;
259
419
  };
260
420
 
261
- var PDFObject =
262
- /*#__PURE__*/
263
- function () {
421
+ var PDFObject = /*#__PURE__*/function () {
264
422
  function PDFObject() {
265
423
  _classCallCheck(this, PDFObject);
266
424
  }
@@ -308,14 +466,14 @@ function () {
308
466
  return "(".concat(string, ")"); // Buffers are converted to PDF hex strings
309
467
  } else if (Buffer.isBuffer(object)) {
310
468
  return "<".concat(object.toString('hex'), ">");
311
- } else if (object instanceof PDFAbstractReference || object instanceof PDFNameTree) {
469
+ } else if (object instanceof PDFAbstractReference || object instanceof PDFTree) {
312
470
  return object.toString();
313
471
  } else if (object instanceof Date) {
314
472
  var _string = "D:".concat(pad(object.getUTCFullYear(), 4)) + pad(object.getUTCMonth() + 1, 2) + pad(object.getUTCDate(), 2) + pad(object.getUTCHours(), 2) + pad(object.getUTCMinutes(), 2) + pad(object.getUTCSeconds(), 2) + 'Z'; // Encrypt the string when necessary
315
473
 
316
474
 
317
475
  if (encryptFn) {
318
- _string = encryptFn(new Buffer(_string, 'ascii')).toString('binary'); // Escape characters as required by the spec
476
+ _string = encryptFn(Buffer.from(_string, 'ascii')).toString('binary'); // Escape characters as required by the spec
319
477
 
320
478
  _string = _string.replace(escapableRe, function (c) {
321
479
  return escapable[c];
@@ -358,11 +516,11 @@ function () {
358
516
  return PDFObject;
359
517
  }();
360
518
 
361
- var PDFReference =
362
- /*#__PURE__*/
363
- function (_PDFAbstractReference) {
519
+ var PDFReference = /*#__PURE__*/function (_PDFAbstractReference) {
364
520
  _inherits(PDFReference, _PDFAbstractReference);
365
521
 
522
+ var _super = _createSuper(PDFReference);
523
+
366
524
  function PDFReference(document, id) {
367
525
  var _this;
368
526
 
@@ -370,7 +528,7 @@ function (_PDFAbstractReference) {
370
528
 
371
529
  _classCallCheck(this, PDFReference);
372
530
 
373
- _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFReference).call(this));
531
+ _this = _super.call(this);
374
532
  _this.document = document;
375
533
  _this.id = id;
376
534
  _this.data = data;
@@ -385,7 +543,7 @@ function (_PDFAbstractReference) {
385
543
  key: "write",
386
544
  value: function write(chunk) {
387
545
  if (!Buffer.isBuffer(chunk)) {
388
- chunk = new Buffer(chunk + '\n', 'binary');
546
+ chunk = Buffer.from(chunk + '\n', 'binary');
389
547
  }
390
548
 
391
549
  this.uncompressedLength += chunk.length;
@@ -458,9 +616,9 @@ function (_PDFAbstractReference) {
458
616
  return PDFReference;
459
617
  }(PDFAbstractReference);
460
618
 
461
- /*
462
- PDFPage - represents a single page in the PDF document
463
- By Devon Govett
619
+ /*
620
+ PDFPage - represents a single page in the PDF document
621
+ By Devon Govett
464
622
  */
465
623
  var DEFAULT_MARGINS = {
466
624
  top: 72,
@@ -521,9 +679,7 @@ var SIZES = {
521
679
  TABLOID: [792.0, 1224.0]
522
680
  };
523
681
 
524
- var PDFPage =
525
- /*#__PURE__*/
526
- function () {
682
+ var PDFPage = /*#__PURE__*/function () {
527
683
  function PDFPage(document) {
528
684
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
529
685
 
@@ -561,7 +717,8 @@ function () {
561
717
  Contents: this.content,
562
718
  Resources: this.resources
563
719
  });
564
- } // Lazily create these dictionaries
720
+ this.markings = [];
721
+ } // Lazily create these objects
565
722
 
566
723
 
567
724
  _createClass(PDFPage, [{
@@ -611,16 +768,53 @@ function () {
611
768
  var data = this.dictionary.data;
612
769
  return data.Annots != null ? data.Annots : data.Annots = [];
613
770
  }
771
+ }, {
772
+ key: "structParentTreeKey",
773
+ get: function get() {
774
+ var data = this.dictionary.data;
775
+ return data.StructParents != null ? data.StructParents : data.StructParents = this.document.createStructParentTreeNextKey();
776
+ }
614
777
  }]);
615
778
 
616
779
  return PDFPage;
617
780
  }();
618
781
 
619
- /**
620
- * Check if value is in a range group.
621
- * @param {number} value
622
- * @param {number[]} rangeGroup
623
- * @returns {boolean}
782
+ var PDFNameTree = /*#__PURE__*/function (_PDFTree) {
783
+ _inherits(PDFNameTree, _PDFTree);
784
+
785
+ var _super = _createSuper(PDFNameTree);
786
+
787
+ function PDFNameTree() {
788
+ _classCallCheck(this, PDFNameTree);
789
+
790
+ return _super.apply(this, arguments);
791
+ }
792
+
793
+ _createClass(PDFNameTree, [{
794
+ key: "_compareKeys",
795
+ value: function _compareKeys(a, b) {
796
+ return a.localeCompare(b);
797
+ }
798
+ }, {
799
+ key: "_keysName",
800
+ value: function _keysName() {
801
+ return "Names";
802
+ }
803
+ }, {
804
+ key: "_dataForKey",
805
+ value: function _dataForKey(k) {
806
+ return new String(k);
807
+ }
808
+ }]);
809
+
810
+ return PDFNameTree;
811
+ }(PDFTree);
812
+
813
+ /**
814
+ * Check if value is in a range group.
815
+ * @param {number} value
816
+ * @param {number[]} rangeGroup
817
+ * @returns {boolean}
624
818
  */
625
819
  function inRange(value, rangeGroup) {
626
820
  if (value < rangeGroup[0]) return false;
@@ -648,38 +842,32 @@ function inRange(value, rangeGroup) {
648
842
  return false;
649
843
  }
650
844
 
651
- /* eslint-disable prettier/prettier */
652
-
653
- /**
654
- * A.1 Unassigned code points in Unicode 3.2
655
- * @link https://tools.ietf.org/html/rfc3454#appendix-A.1
845
+ /**
846
+ * A.1 Unassigned code points in Unicode 3.2
847
+ * @link https://tools.ietf.org/html/rfc3454#appendix-A.1
656
848
  */
657
849
 
658
- var unassigned_code_points = [0x0221, 0x0221, 0x0234, 0x024f, 0x02ae, 0x02af, 0x02ef, 0x02ff, 0x0350, 0x035f, 0x0370, 0x0373, 0x0376, 0x0379, 0x037b, 0x037d, 0x037f, 0x0383, 0x038b, 0x038b, 0x038d, 0x038d, 0x03a2, 0x03a2, 0x03cf, 0x03cf, 0x03f7, 0x03ff, 0x0487, 0x0487, 0x04cf, 0x04cf, 0x04f6, 0x04f7, 0x04fa, 0x04ff, 0x0510, 0x0530, 0x0557, 0x0558, 0x0560, 0x0560, 0x0588, 0x0588, 0x058b, 0x0590, 0x05a2, 0x05a2, 0x05ba, 0x05ba, 0x05c5, 0x05cf, 0x05eb, 0x05ef, 0x05f5, 0x060b, 0x060d, 0x061a, 0x061c, 0x061e, 0x0620, 0x0620, 0x063b, 0x063f, 0x0656, 0x065f, 0x06ee, 0x06ef, 0x06ff, 0x06ff, 0x070e, 0x070e, 0x072d, 0x072f, 0x074b, 0x077f, 0x07b2, 0x0900, 0x0904, 0x0904, 0x093a, 0x093b, 0x094e, 0x094f, 0x0955, 0x0957, 0x0971, 0x0980, 0x0984, 0x0984, 0x098d, 0x098e, 0x0991, 0x0992, 0x09a9, 0x09a9, 0x09b1, 0x09b1, 0x09b3, 0x09b5, 0x09ba, 0x09bb, 0x09bd, 0x09bd, 0x09c5, 0x09c6, 0x09c9, 0x09ca, 0x09ce, 0x09d6, 0x09d8, 0x09db, 0x09de, 0x09de, 0x09e4, 0x09e5, 0x09fb, 0x0a01, 0x0a03, 0x0a04, 0x0a0b, 0x0a0e, 0x0a11, 0x0a12, 0x0a29, 0x0a29, 0x0a31, 0x0a31, 0x0a34, 0x0a34, 0x0a37, 0x0a37, 0x0a3a, 0x0a3b, 0x0a3d, 0x0a3d, 0x0a43, 0x0a46, 0x0a49, 0x0a4a, 0x0a4e, 0x0a58, 0x0a5d, 0x0a5d, 0x0a5f, 0x0a65, 0x0a75, 0x0a80, 0x0a84, 0x0a84, 0x0a8c, 0x0a8c, 0x0a8e, 0x0a8e, 0x0a92, 0x0a92, 0x0aa9, 0x0aa9, 0x0ab1, 0x0ab1, 0x0ab4, 0x0ab4, 0x0aba, 0x0abb, 0x0ac6, 0x0ac6, 0x0aca, 0x0aca, 0x0ace, 0x0acf, 0x0ad1, 0x0adf, 0x0ae1, 0x0ae5, 0x0af0, 0x0b00, 0x0b04, 0x0b04, 0x0b0d, 0x0b0e, 0x0b11, 0x0b12, 0x0b29, 0x0b29, 0x0b31, 0x0b31, 0x0b34, 0x0b35, 0x0b3a, 0x0b3b, 0x0b44, 0x0b46, 0x0b49, 0x0b4a, 0x0b4e, 0x0b55, 0x0b58, 0x0b5b, 0x0b5e, 0x0b5e, 0x0b62, 0x0b65, 0x0b71, 0x0b81, 0x0b84, 0x0b84, 0x0b8b, 0x0b8d, 0x0b91, 0x0b91, 0x0b96, 0x0b98, 0x0b9b, 0x0b9b, 0x0b9d, 0x0b9d, 0x0ba0, 0x0ba2, 0x0ba5, 0x0ba7, 0x0bab, 0x0bad, 0x0bb6, 0x0bb6, 0x0bba, 0x0bbd, 0x0bc3, 0x0bc5, 0x0bc9, 0x0bc9, 0x0bce, 0x0bd6, 0x0bd8, 0x0be6, 0x0bf3, 0x0c00, 0x0c04, 0x0c04, 0x0c0d, 0x0c0d, 0x0c11, 0x0c11, 0x0c29, 0x0c29, 0x0c34, 0x0c34, 0x0c3a, 0x0c3d, 0x0c45, 0x0c45, 0x0c49, 0x0c49, 0x0c4e, 0x0c54, 0x0c57, 0x0c5f, 0x0c62, 0x0c65, 0x0c70, 0x0c81, 0x0c84, 0x0c84, 0x0c8d, 0x0c8d, 0x0c91, 0x0c91, 0x0ca9, 0x0ca9, 0x0cb4, 0x0cb4, 0x0cba, 0x0cbd, 0x0cc5, 0x0cc5, 0x0cc9, 0x0cc9, 0x0cce, 0x0cd4, 0x0cd7, 0x0cdd, 0x0cdf, 0x0cdf, 0x0ce2, 0x0ce5, 0x0cf0, 0x0d01, 0x0d04, 0x0d04, 0x0d0d, 0x0d0d, 0x0d11, 0x0d11, 0x0d29, 0x0d29, 0x0d3a, 0x0d3d, 0x0d44, 0x0d45, 0x0d49, 0x0d49, 0x0d4e, 0x0d56, 0x0d58, 0x0d5f, 0x0d62, 0x0d65, 0x0d70, 0x0d81, 0x0d84, 0x0d84, 0x0d97, 0x0d99, 0x0db2, 0x0db2, 0x0dbc, 0x0dbc, 0x0dbe, 0x0dbf, 0x0dc7, 0x0dc9, 0x0dcb, 0x0dce, 0x0dd5, 0x0dd5, 0x0dd7, 0x0dd7, 0x0de0, 0x0df1, 0x0df5, 0x0e00, 0x0e3b, 0x0e3e, 0x0e5c, 0x0e80, 0x0e83, 0x0e83, 0x0e85, 0x0e86, 0x0e89, 0x0e89, 0x0e8b, 0x0e8c, 0x0e8e, 0x0e93, 0x0e98, 0x0e98, 0x0ea0, 0x0ea0, 0x0ea4, 0x0ea4, 0x0ea6, 0x0ea6, 0x0ea8, 0x0ea9, 0x0eac, 0x0eac, 0x0eba, 0x0eba, 0x0ebe, 0x0ebf, 0x0ec5, 0x0ec5, 0x0ec7, 0x0ec7, 0x0ece, 0x0ecf, 0x0eda, 0x0edb, 0x0ede, 0x0eff, 0x0f48, 0x0f48, 0x0f6b, 0x0f70, 0x0f8c, 0x0f8f, 0x0f98, 0x0f98, 0x0fbd, 0x0fbd, 0x0fcd, 0x0fce, 0x0fd0, 0x0fff, 0x1022, 0x1022, 0x1028, 0x1028, 0x102b, 0x102b, 0x1033, 0x1035, 0x103a, 0x103f, 0x105a, 0x109f, 0x10c6, 0x10cf, 0x10f9, 0x10fa, 0x10fc, 0x10ff, 0x115a, 0x115e, 0x11a3, 0x11a7, 0x11fa, 0x11ff, 0x1207, 0x1207, 0x1247, 0x1247, 0x1249, 0x1249, 0x124e, 0x124f, 0x1257, 0x1257, 0x1259, 0x1259, 0x125e, 0x125f, 0x1287, 0x1287, 0x1289, 0x1289, 0x128e, 0x128f, 0x12af, 0x12af, 0x12b1, 0x12b1, 0x12b6, 0x12b7, 0x12bf, 0x12bf, 0x12c1, 0x12c1, 0x12c6, 0x12c7, 0x12cf, 0x12cf, 0x12d7, 0x12d7, 0x12ef, 0x12ef, 0x130f, 0x130f, 0x1311, 0x1311, 0x1316, 0x1317, 0x131f, 0x131f, 0x1347, 0x1347, 0x135b, 0x1360, 0x137d, 0x139f, 0x13f5, 0x1400, 0x1677, 0x167f, 0x169d, 0x169f, 0x16f1, 0x16ff, 0x170d, 0x170d, 0x1715, 0x171f, 0x1737, 0x173f, 0x1754, 0x175f, 0x176d, 0x176d, 0x1771, 0x1771, 0x1774, 0x177f, 0x17dd, 0x17df, 0x17ea, 0x17ff, 0x180f, 0x180f, 0x181a, 0x181f, 0x1878, 0x187f, 0x18aa, 0x1dff, 0x1e9c, 0x1e9f, 0x1efa, 0x1eff, 0x1f16, 0x1f17, 0x1f1e, 0x1f1f, 0x1f46, 0x1f47, 0x1f4e, 0x1f4f, 0x1f58, 0x1f58, 0x1f5a, 0x1f5a, 0x1f5c, 0x1f5c, 0x1f5e, 0x1f5e, 0x1f7e, 0x1f7f, 0x1fb5, 0x1fb5, 0x1fc5, 0x1fc5, 0x1fd4, 0x1fd5, 0x1fdc, 0x1fdc, 0x1ff0, 0x1ff1, 0x1ff5, 0x1ff5, 0x1fff, 0x1fff, 0x2053, 0x2056, 0x2058, 0x205e, 0x2064, 0x2069, 0x2072, 0x2073, 0x208f, 0x209f, 0x20b2, 0x20cf, 0x20eb, 0x20ff, 0x213b, 0x213c, 0x214c, 0x2152, 0x2184, 0x218f, 0x23cf, 0x23ff, 0x2427, 0x243f, 0x244b, 0x245f, 0x24ff, 0x24ff, 0x2614, 0x2615, 0x2618, 0x2618, 0x267e, 0x267f, 0x268a, 0x2700, 0x2705, 0x2705, 0x270a, 0x270b, 0x2728, 0x2728, 0x274c, 0x274c, 0x274e, 0x274e, 0x2753, 0x2755, 0x2757, 0x2757, 0x275f, 0x2760, 0x2795, 0x2797, 0x27b0, 0x27b0, 0x27bf, 0x27cf, 0x27ec, 0x27ef, 0x2b00, 0x2e7f, 0x2e9a, 0x2e9a, 0x2ef4, 0x2eff, 0x2fd6, 0x2fef, 0x2ffc, 0x2fff, 0x3040, 0x3040, 0x3097, 0x3098, 0x3100, 0x3104, 0x312d, 0x3130, 0x318f, 0x318f, 0x31b8, 0x31ef, 0x321d, 0x321f, 0x3244, 0x3250, 0x327c, 0x327e, 0x32cc, 0x32cf, 0x32ff, 0x32ff, 0x3377, 0x337a, 0x33de, 0x33df, 0x33ff, 0x33ff, 0x4db6, 0x4dff, 0x9fa6, 0x9fff, 0xa48d, 0xa48f, 0xa4c7, 0xabff, 0xd7a4, 0xd7ff, 0xfa2e, 0xfa2f, 0xfa6b, 0xfaff, 0xfb07, 0xfb12, 0xfb18, 0xfb1c, 0xfb37, 0xfb37, 0xfb3d, 0xfb3d, 0xfb3f, 0xfb3f, 0xfb42, 0xfb42, 0xfb45, 0xfb45, 0xfbb2, 0xfbd2, 0xfd40, 0xfd4f, 0xfd90, 0xfd91, 0xfdc8, 0xfdcf, 0xfdfd, 0xfdff, 0xfe10, 0xfe1f, 0xfe24, 0xfe2f, 0xfe47, 0xfe48, 0xfe53, 0xfe53, 0xfe67, 0xfe67, 0xfe6c, 0xfe6f, 0xfe75, 0xfe75, 0xfefd, 0xfefe, 0xff00, 0xff00, 0xffbf, 0xffc1, 0xffc8, 0xffc9, 0xffd0, 0xffd1, 0xffd8, 0xffd9, 0xffdd, 0xffdf, 0xffe7, 0xffe7, 0xffef, 0xfff8, 0x10000, 0x102ff, 0x1031f, 0x1031f, 0x10324, 0x1032f, 0x1034b, 0x103ff, 0x10426, 0x10427, 0x1044e, 0x1cfff, 0x1d0f6, 0x1d0ff, 0x1d127, 0x1d129, 0x1d1de, 0x1d3ff, 0x1d455, 0x1d455, 0x1d49d, 0x1d49d, 0x1d4a0, 0x1d4a1, 0x1d4a3, 0x1d4a4, 0x1d4a7, 0x1d4a8, 0x1d4ad, 0x1d4ad, 0x1d4ba, 0x1d4ba, 0x1d4bc, 0x1d4bc, 0x1d4c1, 0x1d4c1, 0x1d4c4, 0x1d4c4, 0x1d506, 0x1d506, 0x1d50b, 0x1d50c, 0x1d515, 0x1d515, 0x1d51d, 0x1d51d, 0x1d53a, 0x1d53a, 0x1d53f, 0x1d53f, 0x1d545, 0x1d545, 0x1d547, 0x1d549, 0x1d551, 0x1d551, 0x1d6a4, 0x1d6a7, 0x1d7ca, 0x1d7cd, 0x1d800, 0x1fffd, 0x2a6d7, 0x2f7ff, 0x2fa1e, 0x2fffd, 0x30000, 0x3fffd, 0x40000, 0x4fffd, 0x50000, 0x5fffd, 0x60000, 0x6fffd, 0x70000, 0x7fffd, 0x80000, 0x8fffd, 0x90000, 0x9fffd, 0xa0000, 0xafffd, 0xb0000, 0xbfffd, 0xc0000, 0xcfffd, 0xd0000, 0xdfffd, 0xe0000, 0xe0000, 0xe0002, 0xe001f, 0xe0080, 0xefffd];
659
- /* eslint-enable */
850
+ var unassigned_code_points = [0x0221, 0x0221, 0x0234, 0x024f, 0x02ae, 0x02af, 0x02ef, 0x02ff, 0x0350, 0x035f, 0x0370, 0x0373, 0x0376, 0x0379, 0x037b, 0x037d, 0x037f, 0x0383, 0x038b, 0x038b, 0x038d, 0x038d, 0x03a2, 0x03a2, 0x03cf, 0x03cf, 0x03f7, 0x03ff, 0x0487, 0x0487, 0x04cf, 0x04cf, 0x04f6, 0x04f7, 0x04fa, 0x04ff, 0x0510, 0x0530, 0x0557, 0x0558, 0x0560, 0x0560, 0x0588, 0x0588, 0x058b, 0x0590, 0x05a2, 0x05a2, 0x05ba, 0x05ba, 0x05c5, 0x05cf, 0x05eb, 0x05ef, 0x05f5, 0x060b, 0x060d, 0x061a, 0x061c, 0x061e, 0x0620, 0x0620, 0x063b, 0x063f, 0x0656, 0x065f, 0x06ee, 0x06ef, 0x06ff, 0x06ff, 0x070e, 0x070e, 0x072d, 0x072f, 0x074b, 0x077f, 0x07b2, 0x0900, 0x0904, 0x0904, 0x093a, 0x093b, 0x094e, 0x094f, 0x0955, 0x0957, 0x0971, 0x0980, 0x0984, 0x0984, 0x098d, 0x098e, 0x0991, 0x0992, 0x09a9, 0x09a9, 0x09b1, 0x09b1, 0x09b3, 0x09b5, 0x09ba, 0x09bb, 0x09bd, 0x09bd, 0x09c5, 0x09c6, 0x09c9, 0x09ca, 0x09ce, 0x09d6, 0x09d8, 0x09db, 0x09de, 0x09de, 0x09e4, 0x09e5, 0x09fb, 0x0a01, 0x0a03, 0x0a04, 0x0a0b, 0x0a0e, 0x0a11, 0x0a12, 0x0a29, 0x0a29, 0x0a31, 0x0a31, 0x0a34, 0x0a34, 0x0a37, 0x0a37, 0x0a3a, 0x0a3b, 0x0a3d, 0x0a3d, 0x0a43, 0x0a46, 0x0a49, 0x0a4a, 0x0a4e, 0x0a58, 0x0a5d, 0x0a5d, 0x0a5f, 0x0a65, 0x0a75, 0x0a80, 0x0a84, 0x0a84, 0x0a8c, 0x0a8c, 0x0a8e, 0x0a8e, 0x0a92, 0x0a92, 0x0aa9, 0x0aa9, 0x0ab1, 0x0ab1, 0x0ab4, 0x0ab4, 0x0aba, 0x0abb, 0x0ac6, 0x0ac6, 0x0aca, 0x0aca, 0x0ace, 0x0acf, 0x0ad1, 0x0adf, 0x0ae1, 0x0ae5, 0x0af0, 0x0b00, 0x0b04, 0x0b04, 0x0b0d, 0x0b0e, 0x0b11, 0x0b12, 0x0b29, 0x0b29, 0x0b31, 0x0b31, 0x0b34, 0x0b35, 0x0b3a, 0x0b3b, 0x0b44, 0x0b46, 0x0b49, 0x0b4a, 0x0b4e, 0x0b55, 0x0b58, 0x0b5b, 0x0b5e, 0x0b5e, 0x0b62, 0x0b65, 0x0b71, 0x0b81, 0x0b84, 0x0b84, 0x0b8b, 0x0b8d, 0x0b91, 0x0b91, 0x0b96, 0x0b98, 0x0b9b, 0x0b9b, 0x0b9d, 0x0b9d, 0x0ba0, 0x0ba2, 0x0ba5, 0x0ba7, 0x0bab, 0x0bad, 0x0bb6, 0x0bb6, 0x0bba, 0x0bbd, 0x0bc3, 0x0bc5, 0x0bc9, 0x0bc9, 0x0bce, 0x0bd6, 0x0bd8, 0x0be6, 0x0bf3, 0x0c00, 0x0c04, 0x0c04, 0x0c0d, 0x0c0d, 0x0c11, 0x0c11, 0x0c29, 0x0c29, 0x0c34, 0x0c34, 0x0c3a, 0x0c3d, 0x0c45, 0x0c45, 0x0c49, 0x0c49, 0x0c4e, 0x0c54, 0x0c57, 0x0c5f, 0x0c62, 0x0c65, 0x0c70, 0x0c81, 0x0c84, 0x0c84, 0x0c8d, 0x0c8d, 0x0c91, 0x0c91, 0x0ca9, 0x0ca9, 0x0cb4, 0x0cb4, 0x0cba, 0x0cbd, 0x0cc5, 0x0cc5, 0x0cc9, 0x0cc9, 0x0cce, 0x0cd4, 0x0cd7, 0x0cdd, 0x0cdf, 0x0cdf, 0x0ce2, 0x0ce5, 0x0cf0, 0x0d01, 0x0d04, 0x0d04, 0x0d0d, 0x0d0d, 0x0d11, 0x0d11, 0x0d29, 0x0d29, 0x0d3a, 0x0d3d, 0x0d44, 0x0d45, 0x0d49, 0x0d49, 0x0d4e, 0x0d56, 0x0d58, 0x0d5f, 0x0d62, 0x0d65, 0x0d70, 0x0d81, 0x0d84, 0x0d84, 0x0d97, 0x0d99, 0x0db2, 0x0db2, 0x0dbc, 0x0dbc, 0x0dbe, 0x0dbf, 0x0dc7, 0x0dc9, 0x0dcb, 0x0dce, 0x0dd5, 0x0dd5, 0x0dd7, 0x0dd7, 0x0de0, 0x0df1, 0x0df5, 0x0e00, 0x0e3b, 0x0e3e, 0x0e5c, 0x0e80, 0x0e83, 0x0e83, 0x0e85, 0x0e86, 0x0e89, 0x0e89, 0x0e8b, 0x0e8c, 0x0e8e, 0x0e93, 0x0e98, 0x0e98, 0x0ea0, 0x0ea0, 0x0ea4, 0x0ea4, 0x0ea6, 0x0ea6, 0x0ea8, 0x0ea9, 0x0eac, 0x0eac, 0x0eba, 0x0eba, 0x0ebe, 0x0ebf, 0x0ec5, 0x0ec5, 0x0ec7, 0x0ec7, 0x0ece, 0x0ecf, 0x0eda, 0x0edb, 0x0ede, 0x0eff, 0x0f48, 0x0f48, 0x0f6b, 0x0f70, 0x0f8c, 0x0f8f, 0x0f98, 0x0f98, 0x0fbd, 0x0fbd, 0x0fcd, 0x0fce, 0x0fd0, 0x0fff, 0x1022, 0x1022, 0x1028, 0x1028, 0x102b, 0x102b, 0x1033, 0x1035, 0x103a, 0x103f, 0x105a, 0x109f, 0x10c6, 0x10cf, 0x10f9, 0x10fa, 0x10fc, 0x10ff, 0x115a, 0x115e, 0x11a3, 0x11a7, 0x11fa, 0x11ff, 0x1207, 0x1207, 0x1247, 0x1247, 0x1249, 0x1249, 0x124e, 0x124f, 0x1257, 0x1257, 0x1259, 0x1259, 0x125e, 0x125f, 0x1287, 0x1287, 0x1289, 0x1289, 0x128e, 0x128f, 0x12af, 0x12af, 0x12b1, 0x12b1, 0x12b6, 0x12b7, 0x12bf, 0x12bf, 0x12c1, 0x12c1, 0x12c6, 0x12c7, 0x12cf, 0x12cf, 0x12d7, 0x12d7, 0x12ef, 0x12ef, 0x130f, 0x130f, 0x1311, 0x1311, 0x1316, 0x1317, 0x131f, 0x131f, 0x1347, 0x1347, 0x135b, 0x1360, 0x137d, 0x139f, 0x13f5, 0x1400, 0x1677, 0x167f, 0x169d, 0x169f, 0x16f1, 0x16ff, 0x170d, 0x170d, 0x1715, 0x171f, 0x1737, 0x173f, 0x1754, 0x175f, 0x176d, 0x176d, 0x1771, 0x1771, 0x1774, 0x177f, 0x17dd, 0x17df, 0x17ea, 0x17ff, 0x180f, 0x180f, 0x181a, 0x181f, 0x1878, 0x187f, 0x18aa, 0x1dff, 0x1e9c, 0x1e9f, 0x1efa, 0x1eff, 0x1f16, 0x1f17, 0x1f1e, 0x1f1f, 0x1f46, 0x1f47, 0x1f4e, 0x1f4f, 0x1f58, 0x1f58, 0x1f5a, 0x1f5a, 0x1f5c, 0x1f5c, 0x1f5e, 0x1f5e, 0x1f7e, 0x1f7f, 0x1fb5, 0x1fb5, 0x1fc5, 0x1fc5, 0x1fd4, 0x1fd5, 0x1fdc, 0x1fdc, 0x1ff0, 0x1ff1, 0x1ff5, 0x1ff5, 0x1fff, 0x1fff, 0x2053, 0x2056, 0x2058, 0x205e, 0x2064, 0x2069, 0x2072, 0x2073, 0x208f, 0x209f, 0x20b2, 0x20cf, 0x20eb, 0x20ff, 0x213b, 0x213c, 0x214c, 0x2152, 0x2184, 0x218f, 0x23cf, 0x23ff, 0x2427, 0x243f, 0x244b, 0x245f, 0x24ff, 0x24ff, 0x2614, 0x2615, 0x2618, 0x2618, 0x267e, 0x267f, 0x268a, 0x2700, 0x2705, 0x2705, 0x270a, 0x270b, 0x2728, 0x2728, 0x274c, 0x274c, 0x274e, 0x274e, 0x2753, 0x2755, 0x2757, 0x2757, 0x275f, 0x2760, 0x2795, 0x2797, 0x27b0, 0x27b0, 0x27bf, 0x27cf, 0x27ec, 0x27ef, 0x2b00, 0x2e7f, 0x2e9a, 0x2e9a, 0x2ef4, 0x2eff, 0x2fd6, 0x2fef, 0x2ffc, 0x2fff, 0x3040, 0x3040, 0x3097, 0x3098, 0x3100, 0x3104, 0x312d, 0x3130, 0x318f, 0x318f, 0x31b8, 0x31ef, 0x321d, 0x321f, 0x3244, 0x3250, 0x327c, 0x327e, 0x32cc, 0x32cf, 0x32ff, 0x32ff, 0x3377, 0x337a, 0x33de, 0x33df, 0x33ff, 0x33ff, 0x4db6, 0x4dff, 0x9fa6, 0x9fff, 0xa48d, 0xa48f, 0xa4c7, 0xabff, 0xd7a4, 0xd7ff, 0xfa2e, 0xfa2f, 0xfa6b, 0xfaff, 0xfb07, 0xfb12, 0xfb18, 0xfb1c, 0xfb37, 0xfb37, 0xfb3d, 0xfb3d, 0xfb3f, 0xfb3f, 0xfb42, 0xfb42, 0xfb45, 0xfb45, 0xfbb2, 0xfbd2, 0xfd40, 0xfd4f, 0xfd90, 0xfd91, 0xfdc8, 0xfdcf, 0xfdfd, 0xfdff, 0xfe10, 0xfe1f, 0xfe24, 0xfe2f, 0xfe47, 0xfe48, 0xfe53, 0xfe53, 0xfe67, 0xfe67, 0xfe6c, 0xfe6f, 0xfe75, 0xfe75, 0xfefd, 0xfefe, 0xff00, 0xff00, 0xffbf, 0xffc1, 0xffc8, 0xffc9, 0xffd0, 0xffd1, 0xffd8, 0xffd9, 0xffdd, 0xffdf, 0xffe7, 0xffe7, 0xffef, 0xfff8, 0x10000, 0x102ff, 0x1031f, 0x1031f, 0x10324, 0x1032f, 0x1034b, 0x103ff, 0x10426, 0x10427, 0x1044e, 0x1cfff, 0x1d0f6, 0x1d0ff, 0x1d127, 0x1d129, 0x1d1de, 0x1d3ff, 0x1d455, 0x1d455, 0x1d49d, 0x1d49d, 0x1d4a0, 0x1d4a1, 0x1d4a3, 0x1d4a4, 0x1d4a7, 0x1d4a8, 0x1d4ad, 0x1d4ad, 0x1d4ba, 0x1d4ba, 0x1d4bc, 0x1d4bc, 0x1d4c1, 0x1d4c1, 0x1d4c4, 0x1d4c4, 0x1d506, 0x1d506, 0x1d50b, 0x1d50c, 0x1d515, 0x1d515, 0x1d51d, 0x1d51d, 0x1d53a, 0x1d53a, 0x1d53f, 0x1d53f, 0x1d545, 0x1d545, 0x1d547, 0x1d549, 0x1d551, 0x1d551, 0x1d6a4, 0x1d6a7, 0x1d7ca, 0x1d7cd, 0x1d800, 0x1fffd, 0x2a6d7, 0x2f7ff, 0x2fa1e, 0x2fffd, 0x30000, 0x3fffd, 0x40000, 0x4fffd, 0x50000, 0x5fffd, 0x60000, 0x6fffd, 0x70000, 0x7fffd, 0x80000, 0x8fffd, 0x90000, 0x9fffd, 0xa0000, 0xafffd, 0xb0000, 0xbfffd, 0xc0000, 0xcfffd, 0xd0000, 0xdfffd, 0xe0000, 0xe0000, 0xe0002, 0xe001f, 0xe0080, 0xefffd]; // prettier-ignore-end
660
851
 
661
852
  var isUnassignedCodePoint = function isUnassignedCodePoint(character) {
662
853
  return inRange(character, unassigned_code_points);
663
- };
664
- /* eslint-disable prettier/prettier */
854
+ }; // prettier-ignore-start
665
855
 
666
- /**
667
- * B.1 Commonly mapped to nothing
668
- * @link https://tools.ietf.org/html/rfc3454#appendix-B.1
856
+ /**
857
+ * B.1 Commonly mapped to nothing
858
+ * @link https://tools.ietf.org/html/rfc3454#appendix-B.1
669
859
  */
670
860
 
671
861
 
672
- var commonly_mapped_to_nothing = [0x00ad, 0x00ad, 0x034f, 0x034f, 0x1806, 0x1806, 0x180b, 0x180b, 0x180c, 0x180c, 0x180d, 0x180d, 0x200b, 0x200b, 0x200c, 0x200c, 0x200d, 0x200d, 0x2060, 0x2060, 0xfe00, 0xfe00, 0xfe01, 0xfe01, 0xfe02, 0xfe02, 0xfe03, 0xfe03, 0xfe04, 0xfe04, 0xfe05, 0xfe05, 0xfe06, 0xfe06, 0xfe07, 0xfe07, 0xfe08, 0xfe08, 0xfe09, 0xfe09, 0xfe0a, 0xfe0a, 0xfe0b, 0xfe0b, 0xfe0c, 0xfe0c, 0xfe0d, 0xfe0d, 0xfe0e, 0xfe0e, 0xfe0f, 0xfe0f, 0xfeff, 0xfeff];
673
- /* eslint-enable */
862
+ var commonly_mapped_to_nothing = [0x00ad, 0x00ad, 0x034f, 0x034f, 0x1806, 0x1806, 0x180b, 0x180b, 0x180c, 0x180c, 0x180d, 0x180d, 0x200b, 0x200b, 0x200c, 0x200c, 0x200d, 0x200d, 0x2060, 0x2060, 0xfe00, 0xfe00, 0xfe01, 0xfe01, 0xfe02, 0xfe02, 0xfe03, 0xfe03, 0xfe04, 0xfe04, 0xfe05, 0xfe05, 0xfe06, 0xfe06, 0xfe07, 0xfe07, 0xfe08, 0xfe08, 0xfe09, 0xfe09, 0xfe0a, 0xfe0a, 0xfe0b, 0xfe0b, 0xfe0c, 0xfe0c, 0xfe0d, 0xfe0d, 0xfe0e, 0xfe0e, 0xfe0f, 0xfe0f, 0xfeff, 0xfeff]; // prettier-ignore-end
674
863
 
675
864
  var isCommonlyMappedToNothing = function isCommonlyMappedToNothing(character) {
676
865
  return inRange(character, commonly_mapped_to_nothing);
677
- };
678
- /* eslint-disable prettier/prettier */
866
+ }; // prettier-ignore-start
679
867
 
680
- /**
681
- * C.1.2 Non-ASCII space characters
682
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.1.2
868
+ /**
869
+ * C.1.2 Non-ASCII space characters
870
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.1.2
683
871
  */
684
872
 
685
873
 
@@ -717,19 +905,17 @@ var non_ASCII_space_characters = [0x00a0, 0x00a0
717
905
  /* MEDIUM MATHEMATICAL SPACE */
718
906
  , 0x3000, 0x3000
719
907
  /* IDEOGRAPHIC SPACE */
720
- ];
721
- /* eslint-enable */
908
+ ]; // prettier-ignore-end
722
909
 
723
910
  var isNonASCIISpaceCharacter = function isNonASCIISpaceCharacter(character) {
724
911
  return inRange(character, non_ASCII_space_characters);
725
- };
726
- /* eslint-disable prettier/prettier */
912
+ }; // prettier-ignore-start
727
913
 
728
914
 
729
915
  var non_ASCII_controls_characters = [
730
- /**
731
- * C.2.2 Non-ASCII control characters
732
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.2
916
+ /**
917
+ * C.2.2 Non-ASCII control characters
918
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.2
733
919
  */
734
920
  0x0080, 0x009f
735
921
  /* [CONTROL CHARACTERS] */
@@ -765,9 +951,9 @@ var non_ASCII_controls_characters = [
765
951
  /* [MUSICAL CONTROL CHARACTERS] */
766
952
  ];
767
953
  var non_character_codepoints = [
768
- /**
769
- * C.4 Non-character code points
770
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.4
954
+ /**
955
+ * C.4 Non-character code points
956
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.4
771
957
  */
772
958
  0xfdd0, 0xfdef
773
959
  /* [NONCHARACTER CODE POINTS] */
@@ -804,23 +990,23 @@ var non_character_codepoints = [
804
990
  , 0x10fffe, 0x10ffff
805
991
  /* [NONCHARACTER CODE POINTS] */
806
992
  ];
807
- /**
808
- * 2.3. Prohibited Output
993
+ /**
994
+ * 2.3. Prohibited Output
809
995
  */
810
996
 
811
997
  var prohibited_characters = [
812
- /**
813
- * C.2.1 ASCII control characters
814
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.1
998
+ /**
999
+ * C.2.1 ASCII control characters
1000
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.1
815
1001
  */
816
1002
  0, 0x001f
817
1003
  /* [CONTROL CHARACTERS] */
818
1004
  , 0x007f, 0x007f
819
1005
  /* DELETE */
820
1006
  ,
821
- /**
822
- * C.8 Change display properties or are deprecated
823
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.8
1007
+ /**
1008
+ * C.8 Change display properties or are deprecated
1009
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.8
824
1010
  */
825
1011
  0x0340, 0x0340
826
1012
  /* COMBINING GRAVE TONE MARK */
@@ -853,28 +1039,28 @@ var prohibited_characters = [
853
1039
  , 0x206f, 0x206f
854
1040
  /* NOMINAL DIGIT SHAPES */
855
1041
  ,
856
- /**
857
- * C.7 Inappropriate for canonical representation
858
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.7
1042
+ /**
1043
+ * C.7 Inappropriate for canonical representation
1044
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.7
859
1045
  */
860
1046
  0x2ff0, 0x2ffb
861
1047
  /* [IDEOGRAPHIC DESCRIPTION CHARACTERS] */
862
1048
  ,
863
- /**
864
- * C.5 Surrogate codes
865
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.5
1049
+ /**
1050
+ * C.5 Surrogate codes
1051
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.5
866
1052
  */
867
1053
  0xd800, 0xdfff,
868
- /**
869
- * C.3 Private use
870
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.3
1054
+ /**
1055
+ * C.3 Private use
1056
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.3
871
1057
  */
872
1058
  0xe000, 0xf8ff
873
1059
  /* [PRIVATE USE, PLANE 0] */
874
1060
  ,
875
- /**
876
- * C.6 Inappropriate for plain text
877
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.6
1061
+ /**
1062
+ * C.6 Inappropriate for plain text
1063
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.6
878
1064
  */
879
1065
  0xfff9, 0xfff9
880
1066
  /* INTERLINEAR ANNOTATION ANCHOR */
@@ -887,67 +1073,62 @@ var prohibited_characters = [
887
1073
  , 0xfffd, 0xfffd
888
1074
  /* REPLACEMENT CHARACTER */
889
1075
  ,
890
- /**
891
- * C.9 Tagging characters
892
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.9
1076
+ /**
1077
+ * C.9 Tagging characters
1078
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.9
893
1079
  */
894
1080
  0xe0001, 0xe0001
895
1081
  /* LANGUAGE TAG */
896
1082
  , 0xe0020, 0xe007f
897
1083
  /* [TAGGING CHARACTERS] */
898
1084
  ,
899
- /**
900
- * C.3 Private use
901
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.3
1085
+ /**
1086
+ * C.3 Private use
1087
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.3
902
1088
  */
903
1089
  0xf0000, 0xffffd
904
1090
  /* [PRIVATE USE, PLANE 15] */
905
1091
  , 0x100000, 0x10fffd
906
1092
  /* [PRIVATE USE, PLANE 16] */
907
- ];
908
- /* eslint-enable */
1093
+ ]; // prettier-ignore-end
909
1094
 
910
1095
  var isProhibitedCharacter = function isProhibitedCharacter(character) {
911
1096
  return inRange(character, non_ASCII_space_characters) || inRange(character, prohibited_characters) || inRange(character, non_ASCII_controls_characters) || inRange(character, non_character_codepoints);
912
- };
913
- /* eslint-disable prettier/prettier */
1097
+ }; // prettier-ignore-start
914
1098
 
915
- /**
916
- * D.1 Characters with bidirectional property "R" or "AL"
917
- * @link https://tools.ietf.org/html/rfc3454#appendix-D.1
1099
+ /**
1100
+ * D.1 Characters with bidirectional property "R" or "AL"
1101
+ * @link https://tools.ietf.org/html/rfc3454#appendix-D.1
918
1102
  */
919
1103
 
920
1104
 
921
- var bidirectional_r_al = [0x05be, 0x05be, 0x05c0, 0x05c0, 0x05c3, 0x05c3, 0x05d0, 0x05ea, 0x05f0, 0x05f4, 0x061b, 0x061b, 0x061f, 0x061f, 0x0621, 0x063a, 0x0640, 0x064a, 0x066d, 0x066f, 0x0671, 0x06d5, 0x06dd, 0x06dd, 0x06e5, 0x06e6, 0x06fa, 0x06fe, 0x0700, 0x070d, 0x0710, 0x0710, 0x0712, 0x072c, 0x0780, 0x07a5, 0x07b1, 0x07b1, 0x200f, 0x200f, 0xfb1d, 0xfb1d, 0xfb1f, 0xfb28, 0xfb2a, 0xfb36, 0xfb38, 0xfb3c, 0xfb3e, 0xfb3e, 0xfb40, 0xfb41, 0xfb43, 0xfb44, 0xfb46, 0xfbb1, 0xfbd3, 0xfd3d, 0xfd50, 0xfd8f, 0xfd92, 0xfdc7, 0xfdf0, 0xfdfc, 0xfe70, 0xfe74, 0xfe76, 0xfefc];
922
- /* eslint-enable */
1105
+ var bidirectional_r_al = [0x05be, 0x05be, 0x05c0, 0x05c0, 0x05c3, 0x05c3, 0x05d0, 0x05ea, 0x05f0, 0x05f4, 0x061b, 0x061b, 0x061f, 0x061f, 0x0621, 0x063a, 0x0640, 0x064a, 0x066d, 0x066f, 0x0671, 0x06d5, 0x06dd, 0x06dd, 0x06e5, 0x06e6, 0x06fa, 0x06fe, 0x0700, 0x070d, 0x0710, 0x0710, 0x0712, 0x072c, 0x0780, 0x07a5, 0x07b1, 0x07b1, 0x200f, 0x200f, 0xfb1d, 0xfb1d, 0xfb1f, 0xfb28, 0xfb2a, 0xfb36, 0xfb38, 0xfb3c, 0xfb3e, 0xfb3e, 0xfb40, 0xfb41, 0xfb43, 0xfb44, 0xfb46, 0xfbb1, 0xfbd3, 0xfd3d, 0xfd50, 0xfd8f, 0xfd92, 0xfdc7, 0xfdf0, 0xfdfc, 0xfe70, 0xfe74, 0xfe76, 0xfefc]; // prettier-ignore-end
923
1106
 
924
1107
  var isBidirectionalRAL = function isBidirectionalRAL(character) {
925
1108
  return inRange(character, bidirectional_r_al);
926
- };
927
- /* eslint-disable prettier/prettier */
1109
+ }; // prettier-ignore-start
928
1110
 
929
- /**
930
- * D.2 Characters with bidirectional property "L"
931
- * @link https://tools.ietf.org/html/rfc3454#appendix-D.2
1111
+ /**
1112
+ * D.2 Characters with bidirectional property "L"
1113
+ * @link https://tools.ietf.org/html/rfc3454#appendix-D.2
932
1114
  */
933
1115
 
934
1116
 
935
- var bidirectional_l = [0x0041, 0x005a, 0x0061, 0x007a, 0x00aa, 0x00aa, 0x00b5, 0x00b5, 0x00ba, 0x00ba, 0x00c0, 0x00d6, 0x00d8, 0x00f6, 0x00f8, 0x0220, 0x0222, 0x0233, 0x0250, 0x02ad, 0x02b0, 0x02b8, 0x02bb, 0x02c1, 0x02d0, 0x02d1, 0x02e0, 0x02e4, 0x02ee, 0x02ee, 0x037a, 0x037a, 0x0386, 0x0386, 0x0388, 0x038a, 0x038c, 0x038c, 0x038e, 0x03a1, 0x03a3, 0x03ce, 0x03d0, 0x03f5, 0x0400, 0x0482, 0x048a, 0x04ce, 0x04d0, 0x04f5, 0x04f8, 0x04f9, 0x0500, 0x050f, 0x0531, 0x0556, 0x0559, 0x055f, 0x0561, 0x0587, 0x0589, 0x0589, 0x0903, 0x0903, 0x0905, 0x0939, 0x093d, 0x0940, 0x0949, 0x094c, 0x0950, 0x0950, 0x0958, 0x0961, 0x0964, 0x0970, 0x0982, 0x0983, 0x0985, 0x098c, 0x098f, 0x0990, 0x0993, 0x09a8, 0x09aa, 0x09b0, 0x09b2, 0x09b2, 0x09b6, 0x09b9, 0x09be, 0x09c0, 0x09c7, 0x09c8, 0x09cb, 0x09cc, 0x09d7, 0x09d7, 0x09dc, 0x09dd, 0x09df, 0x09e1, 0x09e6, 0x09f1, 0x09f4, 0x09fa, 0x0a05, 0x0a0a, 0x0a0f, 0x0a10, 0x0a13, 0x0a28, 0x0a2a, 0x0a30, 0x0a32, 0x0a33, 0x0a35, 0x0a36, 0x0a38, 0x0a39, 0x0a3e, 0x0a40, 0x0a59, 0x0a5c, 0x0a5e, 0x0a5e, 0x0a66, 0x0a6f, 0x0a72, 0x0a74, 0x0a83, 0x0a83, 0x0a85, 0x0a8b, 0x0a8d, 0x0a8d, 0x0a8f, 0x0a91, 0x0a93, 0x0aa8, 0x0aaa, 0x0ab0, 0x0ab2, 0x0ab3, 0x0ab5, 0x0ab9, 0x0abd, 0x0ac0, 0x0ac9, 0x0ac9, 0x0acb, 0x0acc, 0x0ad0, 0x0ad0, 0x0ae0, 0x0ae0, 0x0ae6, 0x0aef, 0x0b02, 0x0b03, 0x0b05, 0x0b0c, 0x0b0f, 0x0b10, 0x0b13, 0x0b28, 0x0b2a, 0x0b30, 0x0b32, 0x0b33, 0x0b36, 0x0b39, 0x0b3d, 0x0b3e, 0x0b40, 0x0b40, 0x0b47, 0x0b48, 0x0b4b, 0x0b4c, 0x0b57, 0x0b57, 0x0b5c, 0x0b5d, 0x0b5f, 0x0b61, 0x0b66, 0x0b70, 0x0b83, 0x0b83, 0x0b85, 0x0b8a, 0x0b8e, 0x0b90, 0x0b92, 0x0b95, 0x0b99, 0x0b9a, 0x0b9c, 0x0b9c, 0x0b9e, 0x0b9f, 0x0ba3, 0x0ba4, 0x0ba8, 0x0baa, 0x0bae, 0x0bb5, 0x0bb7, 0x0bb9, 0x0bbe, 0x0bbf, 0x0bc1, 0x0bc2, 0x0bc6, 0x0bc8, 0x0bca, 0x0bcc, 0x0bd7, 0x0bd7, 0x0be7, 0x0bf2, 0x0c01, 0x0c03, 0x0c05, 0x0c0c, 0x0c0e, 0x0c10, 0x0c12, 0x0c28, 0x0c2a, 0x0c33, 0x0c35, 0x0c39, 0x0c41, 0x0c44, 0x0c60, 0x0c61, 0x0c66, 0x0c6f, 0x0c82, 0x0c83, 0x0c85, 0x0c8c, 0x0c8e, 0x0c90, 0x0c92, 0x0ca8, 0x0caa, 0x0cb3, 0x0cb5, 0x0cb9, 0x0cbe, 0x0cbe, 0x0cc0, 0x0cc4, 0x0cc7, 0x0cc8, 0x0cca, 0x0ccb, 0x0cd5, 0x0cd6, 0x0cde, 0x0cde, 0x0ce0, 0x0ce1, 0x0ce6, 0x0cef, 0x0d02, 0x0d03, 0x0d05, 0x0d0c, 0x0d0e, 0x0d10, 0x0d12, 0x0d28, 0x0d2a, 0x0d39, 0x0d3e, 0x0d40, 0x0d46, 0x0d48, 0x0d4a, 0x0d4c, 0x0d57, 0x0d57, 0x0d60, 0x0d61, 0x0d66, 0x0d6f, 0x0d82, 0x0d83, 0x0d85, 0x0d96, 0x0d9a, 0x0db1, 0x0db3, 0x0dbb, 0x0dbd, 0x0dbd, 0x0dc0, 0x0dc6, 0x0dcf, 0x0dd1, 0x0dd8, 0x0ddf, 0x0df2, 0x0df4, 0x0e01, 0x0e30, 0x0e32, 0x0e33, 0x0e40, 0x0e46, 0x0e4f, 0x0e5b, 0x0e81, 0x0e82, 0x0e84, 0x0e84, 0x0e87, 0x0e88, 0x0e8a, 0x0e8a, 0x0e8d, 0x0e8d, 0x0e94, 0x0e97, 0x0e99, 0x0e9f, 0x0ea1, 0x0ea3, 0x0ea5, 0x0ea5, 0x0ea7, 0x0ea7, 0x0eaa, 0x0eab, 0x0ead, 0x0eb0, 0x0eb2, 0x0eb3, 0x0ebd, 0x0ebd, 0x0ec0, 0x0ec4, 0x0ec6, 0x0ec6, 0x0ed0, 0x0ed9, 0x0edc, 0x0edd, 0x0f00, 0x0f17, 0x0f1a, 0x0f34, 0x0f36, 0x0f36, 0x0f38, 0x0f38, 0x0f3e, 0x0f47, 0x0f49, 0x0f6a, 0x0f7f, 0x0f7f, 0x0f85, 0x0f85, 0x0f88, 0x0f8b, 0x0fbe, 0x0fc5, 0x0fc7, 0x0fcc, 0x0fcf, 0x0fcf, 0x1000, 0x1021, 0x1023, 0x1027, 0x1029, 0x102a, 0x102c, 0x102c, 0x1031, 0x1031, 0x1038, 0x1038, 0x1040, 0x1057, 0x10a0, 0x10c5, 0x10d0, 0x10f8, 0x10fb, 0x10fb, 0x1100, 0x1159, 0x115f, 0x11a2, 0x11a8, 0x11f9, 0x1200, 0x1206, 0x1208, 0x1246, 0x1248, 0x1248, 0x124a, 0x124d, 0x1250, 0x1256, 0x1258, 0x1258, 0x125a, 0x125d, 0x1260, 0x1286, 0x1288, 0x1288, 0x128a, 0x128d, 0x1290, 0x12ae, 0x12b0, 0x12b0, 0x12b2, 0x12b5, 0x12b8, 0x12be, 0x12c0, 0x12c0, 0x12c2, 0x12c5, 0x12c8, 0x12ce, 0x12d0, 0x12d6, 0x12d8, 0x12ee, 0x12f0, 0x130e, 0x1310, 0x1310, 0x1312, 0x1315, 0x1318, 0x131e, 0x1320, 0x1346, 0x1348, 0x135a, 0x1361, 0x137c, 0x13a0, 0x13f4, 0x1401, 0x1676, 0x1681, 0x169a, 0x16a0, 0x16f0, 0x1700, 0x170c, 0x170e, 0x1711, 0x1720, 0x1731, 0x1735, 0x1736, 0x1740, 0x1751, 0x1760, 0x176c, 0x176e, 0x1770, 0x1780, 0x17b6, 0x17be, 0x17c5, 0x17c7, 0x17c8, 0x17d4, 0x17da, 0x17dc, 0x17dc, 0x17e0, 0x17e9, 0x1810, 0x1819, 0x1820, 0x1877, 0x1880, 0x18a8, 0x1e00, 0x1e9b, 0x1ea0, 0x1ef9, 0x1f00, 0x1f15, 0x1f18, 0x1f1d, 0x1f20, 0x1f45, 0x1f48, 0x1f4d, 0x1f50, 0x1f57, 0x1f59, 0x1f59, 0x1f5b, 0x1f5b, 0x1f5d, 0x1f5d, 0x1f5f, 0x1f7d, 0x1f80, 0x1fb4, 0x1fb6, 0x1fbc, 0x1fbe, 0x1fbe, 0x1fc2, 0x1fc4, 0x1fc6, 0x1fcc, 0x1fd0, 0x1fd3, 0x1fd6, 0x1fdb, 0x1fe0, 0x1fec, 0x1ff2, 0x1ff4, 0x1ff6, 0x1ffc, 0x200e, 0x200e, 0x2071, 0x2071, 0x207f, 0x207f, 0x2102, 0x2102, 0x2107, 0x2107, 0x210a, 0x2113, 0x2115, 0x2115, 0x2119, 0x211d, 0x2124, 0x2124, 0x2126, 0x2126, 0x2128, 0x2128, 0x212a, 0x212d, 0x212f, 0x2131, 0x2133, 0x2139, 0x213d, 0x213f, 0x2145, 0x2149, 0x2160, 0x2183, 0x2336, 0x237a, 0x2395, 0x2395, 0x249c, 0x24e9, 0x3005, 0x3007, 0x3021, 0x3029, 0x3031, 0x3035, 0x3038, 0x303c, 0x3041, 0x3096, 0x309d, 0x309f, 0x30a1, 0x30fa, 0x30fc, 0x30ff, 0x3105, 0x312c, 0x3131, 0x318e, 0x3190, 0x31b7, 0x31f0, 0x321c, 0x3220, 0x3243, 0x3260, 0x327b, 0x327f, 0x32b0, 0x32c0, 0x32cb, 0x32d0, 0x32fe, 0x3300, 0x3376, 0x337b, 0x33dd, 0x33e0, 0x33fe, 0x3400, 0x4db5, 0x4e00, 0x9fa5, 0xa000, 0xa48c, 0xac00, 0xd7a3, 0xd800, 0xfa2d, 0xfa30, 0xfa6a, 0xfb00, 0xfb06, 0xfb13, 0xfb17, 0xff21, 0xff3a, 0xff41, 0xff5a, 0xff66, 0xffbe, 0xffc2, 0xffc7, 0xffca, 0xffcf, 0xffd2, 0xffd7, 0xffda, 0xffdc, 0x10300, 0x1031e, 0x10320, 0x10323, 0x10330, 0x1034a, 0x10400, 0x10425, 0x10428, 0x1044d, 0x1d000, 0x1d0f5, 0x1d100, 0x1d126, 0x1d12a, 0x1d166, 0x1d16a, 0x1d172, 0x1d183, 0x1d184, 0x1d18c, 0x1d1a9, 0x1d1ae, 0x1d1dd, 0x1d400, 0x1d454, 0x1d456, 0x1d49c, 0x1d49e, 0x1d49f, 0x1d4a2, 0x1d4a2, 0x1d4a5, 0x1d4a6, 0x1d4a9, 0x1d4ac, 0x1d4ae, 0x1d4b9, 0x1d4bb, 0x1d4bb, 0x1d4bd, 0x1d4c0, 0x1d4c2, 0x1d4c3, 0x1d4c5, 0x1d505, 0x1d507, 0x1d50a, 0x1d50d, 0x1d514, 0x1d516, 0x1d51c, 0x1d51e, 0x1d539, 0x1d53b, 0x1d53e, 0x1d540, 0x1d544, 0x1d546, 0x1d546, 0x1d54a, 0x1d550, 0x1d552, 0x1d6a3, 0x1d6a8, 0x1d7c9, 0x20000, 0x2a6d6, 0x2f800, 0x2fa1d, 0xf0000, 0xffffd, 0x100000, 0x10fffd];
936
- /* eslint-enable */
1117
+ var bidirectional_l = [0x0041, 0x005a, 0x0061, 0x007a, 0x00aa, 0x00aa, 0x00b5, 0x00b5, 0x00ba, 0x00ba, 0x00c0, 0x00d6, 0x00d8, 0x00f6, 0x00f8, 0x0220, 0x0222, 0x0233, 0x0250, 0x02ad, 0x02b0, 0x02b8, 0x02bb, 0x02c1, 0x02d0, 0x02d1, 0x02e0, 0x02e4, 0x02ee, 0x02ee, 0x037a, 0x037a, 0x0386, 0x0386, 0x0388, 0x038a, 0x038c, 0x038c, 0x038e, 0x03a1, 0x03a3, 0x03ce, 0x03d0, 0x03f5, 0x0400, 0x0482, 0x048a, 0x04ce, 0x04d0, 0x04f5, 0x04f8, 0x04f9, 0x0500, 0x050f, 0x0531, 0x0556, 0x0559, 0x055f, 0x0561, 0x0587, 0x0589, 0x0589, 0x0903, 0x0903, 0x0905, 0x0939, 0x093d, 0x0940, 0x0949, 0x094c, 0x0950, 0x0950, 0x0958, 0x0961, 0x0964, 0x0970, 0x0982, 0x0983, 0x0985, 0x098c, 0x098f, 0x0990, 0x0993, 0x09a8, 0x09aa, 0x09b0, 0x09b2, 0x09b2, 0x09b6, 0x09b9, 0x09be, 0x09c0, 0x09c7, 0x09c8, 0x09cb, 0x09cc, 0x09d7, 0x09d7, 0x09dc, 0x09dd, 0x09df, 0x09e1, 0x09e6, 0x09f1, 0x09f4, 0x09fa, 0x0a05, 0x0a0a, 0x0a0f, 0x0a10, 0x0a13, 0x0a28, 0x0a2a, 0x0a30, 0x0a32, 0x0a33, 0x0a35, 0x0a36, 0x0a38, 0x0a39, 0x0a3e, 0x0a40, 0x0a59, 0x0a5c, 0x0a5e, 0x0a5e, 0x0a66, 0x0a6f, 0x0a72, 0x0a74, 0x0a83, 0x0a83, 0x0a85, 0x0a8b, 0x0a8d, 0x0a8d, 0x0a8f, 0x0a91, 0x0a93, 0x0aa8, 0x0aaa, 0x0ab0, 0x0ab2, 0x0ab3, 0x0ab5, 0x0ab9, 0x0abd, 0x0ac0, 0x0ac9, 0x0ac9, 0x0acb, 0x0acc, 0x0ad0, 0x0ad0, 0x0ae0, 0x0ae0, 0x0ae6, 0x0aef, 0x0b02, 0x0b03, 0x0b05, 0x0b0c, 0x0b0f, 0x0b10, 0x0b13, 0x0b28, 0x0b2a, 0x0b30, 0x0b32, 0x0b33, 0x0b36, 0x0b39, 0x0b3d, 0x0b3e, 0x0b40, 0x0b40, 0x0b47, 0x0b48, 0x0b4b, 0x0b4c, 0x0b57, 0x0b57, 0x0b5c, 0x0b5d, 0x0b5f, 0x0b61, 0x0b66, 0x0b70, 0x0b83, 0x0b83, 0x0b85, 0x0b8a, 0x0b8e, 0x0b90, 0x0b92, 0x0b95, 0x0b99, 0x0b9a, 0x0b9c, 0x0b9c, 0x0b9e, 0x0b9f, 0x0ba3, 0x0ba4, 0x0ba8, 0x0baa, 0x0bae, 0x0bb5, 0x0bb7, 0x0bb9, 0x0bbe, 0x0bbf, 0x0bc1, 0x0bc2, 0x0bc6, 0x0bc8, 0x0bca, 0x0bcc, 0x0bd7, 0x0bd7, 0x0be7, 0x0bf2, 0x0c01, 0x0c03, 0x0c05, 0x0c0c, 0x0c0e, 0x0c10, 0x0c12, 0x0c28, 0x0c2a, 0x0c33, 0x0c35, 0x0c39, 0x0c41, 0x0c44, 0x0c60, 0x0c61, 0x0c66, 0x0c6f, 0x0c82, 0x0c83, 0x0c85, 0x0c8c, 0x0c8e, 0x0c90, 0x0c92, 0x0ca8, 0x0caa, 0x0cb3, 0x0cb5, 0x0cb9, 0x0cbe, 0x0cbe, 0x0cc0, 0x0cc4, 0x0cc7, 0x0cc8, 0x0cca, 0x0ccb, 0x0cd5, 0x0cd6, 0x0cde, 0x0cde, 0x0ce0, 0x0ce1, 0x0ce6, 0x0cef, 0x0d02, 0x0d03, 0x0d05, 0x0d0c, 0x0d0e, 0x0d10, 0x0d12, 0x0d28, 0x0d2a, 0x0d39, 0x0d3e, 0x0d40, 0x0d46, 0x0d48, 0x0d4a, 0x0d4c, 0x0d57, 0x0d57, 0x0d60, 0x0d61, 0x0d66, 0x0d6f, 0x0d82, 0x0d83, 0x0d85, 0x0d96, 0x0d9a, 0x0db1, 0x0db3, 0x0dbb, 0x0dbd, 0x0dbd, 0x0dc0, 0x0dc6, 0x0dcf, 0x0dd1, 0x0dd8, 0x0ddf, 0x0df2, 0x0df4, 0x0e01, 0x0e30, 0x0e32, 0x0e33, 0x0e40, 0x0e46, 0x0e4f, 0x0e5b, 0x0e81, 0x0e82, 0x0e84, 0x0e84, 0x0e87, 0x0e88, 0x0e8a, 0x0e8a, 0x0e8d, 0x0e8d, 0x0e94, 0x0e97, 0x0e99, 0x0e9f, 0x0ea1, 0x0ea3, 0x0ea5, 0x0ea5, 0x0ea7, 0x0ea7, 0x0eaa, 0x0eab, 0x0ead, 0x0eb0, 0x0eb2, 0x0eb3, 0x0ebd, 0x0ebd, 0x0ec0, 0x0ec4, 0x0ec6, 0x0ec6, 0x0ed0, 0x0ed9, 0x0edc, 0x0edd, 0x0f00, 0x0f17, 0x0f1a, 0x0f34, 0x0f36, 0x0f36, 0x0f38, 0x0f38, 0x0f3e, 0x0f47, 0x0f49, 0x0f6a, 0x0f7f, 0x0f7f, 0x0f85, 0x0f85, 0x0f88, 0x0f8b, 0x0fbe, 0x0fc5, 0x0fc7, 0x0fcc, 0x0fcf, 0x0fcf, 0x1000, 0x1021, 0x1023, 0x1027, 0x1029, 0x102a, 0x102c, 0x102c, 0x1031, 0x1031, 0x1038, 0x1038, 0x1040, 0x1057, 0x10a0, 0x10c5, 0x10d0, 0x10f8, 0x10fb, 0x10fb, 0x1100, 0x1159, 0x115f, 0x11a2, 0x11a8, 0x11f9, 0x1200, 0x1206, 0x1208, 0x1246, 0x1248, 0x1248, 0x124a, 0x124d, 0x1250, 0x1256, 0x1258, 0x1258, 0x125a, 0x125d, 0x1260, 0x1286, 0x1288, 0x1288, 0x128a, 0x128d, 0x1290, 0x12ae, 0x12b0, 0x12b0, 0x12b2, 0x12b5, 0x12b8, 0x12be, 0x12c0, 0x12c0, 0x12c2, 0x12c5, 0x12c8, 0x12ce, 0x12d0, 0x12d6, 0x12d8, 0x12ee, 0x12f0, 0x130e, 0x1310, 0x1310, 0x1312, 0x1315, 0x1318, 0x131e, 0x1320, 0x1346, 0x1348, 0x135a, 0x1361, 0x137c, 0x13a0, 0x13f4, 0x1401, 0x1676, 0x1681, 0x169a, 0x16a0, 0x16f0, 0x1700, 0x170c, 0x170e, 0x1711, 0x1720, 0x1731, 0x1735, 0x1736, 0x1740, 0x1751, 0x1760, 0x176c, 0x176e, 0x1770, 0x1780, 0x17b6, 0x17be, 0x17c5, 0x17c7, 0x17c8, 0x17d4, 0x17da, 0x17dc, 0x17dc, 0x17e0, 0x17e9, 0x1810, 0x1819, 0x1820, 0x1877, 0x1880, 0x18a8, 0x1e00, 0x1e9b, 0x1ea0, 0x1ef9, 0x1f00, 0x1f15, 0x1f18, 0x1f1d, 0x1f20, 0x1f45, 0x1f48, 0x1f4d, 0x1f50, 0x1f57, 0x1f59, 0x1f59, 0x1f5b, 0x1f5b, 0x1f5d, 0x1f5d, 0x1f5f, 0x1f7d, 0x1f80, 0x1fb4, 0x1fb6, 0x1fbc, 0x1fbe, 0x1fbe, 0x1fc2, 0x1fc4, 0x1fc6, 0x1fcc, 0x1fd0, 0x1fd3, 0x1fd6, 0x1fdb, 0x1fe0, 0x1fec, 0x1ff2, 0x1ff4, 0x1ff6, 0x1ffc, 0x200e, 0x200e, 0x2071, 0x2071, 0x207f, 0x207f, 0x2102, 0x2102, 0x2107, 0x2107, 0x210a, 0x2113, 0x2115, 0x2115, 0x2119, 0x211d, 0x2124, 0x2124, 0x2126, 0x2126, 0x2128, 0x2128, 0x212a, 0x212d, 0x212f, 0x2131, 0x2133, 0x2139, 0x213d, 0x213f, 0x2145, 0x2149, 0x2160, 0x2183, 0x2336, 0x237a, 0x2395, 0x2395, 0x249c, 0x24e9, 0x3005, 0x3007, 0x3021, 0x3029, 0x3031, 0x3035, 0x3038, 0x303c, 0x3041, 0x3096, 0x309d, 0x309f, 0x30a1, 0x30fa, 0x30fc, 0x30ff, 0x3105, 0x312c, 0x3131, 0x318e, 0x3190, 0x31b7, 0x31f0, 0x321c, 0x3220, 0x3243, 0x3260, 0x327b, 0x327f, 0x32b0, 0x32c0, 0x32cb, 0x32d0, 0x32fe, 0x3300, 0x3376, 0x337b, 0x33dd, 0x33e0, 0x33fe, 0x3400, 0x4db5, 0x4e00, 0x9fa5, 0xa000, 0xa48c, 0xac00, 0xd7a3, 0xd800, 0xfa2d, 0xfa30, 0xfa6a, 0xfb00, 0xfb06, 0xfb13, 0xfb17, 0xff21, 0xff3a, 0xff41, 0xff5a, 0xff66, 0xffbe, 0xffc2, 0xffc7, 0xffca, 0xffcf, 0xffd2, 0xffd7, 0xffda, 0xffdc, 0x10300, 0x1031e, 0x10320, 0x10323, 0x10330, 0x1034a, 0x10400, 0x10425, 0x10428, 0x1044d, 0x1d000, 0x1d0f5, 0x1d100, 0x1d126, 0x1d12a, 0x1d166, 0x1d16a, 0x1d172, 0x1d183, 0x1d184, 0x1d18c, 0x1d1a9, 0x1d1ae, 0x1d1dd, 0x1d400, 0x1d454, 0x1d456, 0x1d49c, 0x1d49e, 0x1d49f, 0x1d4a2, 0x1d4a2, 0x1d4a5, 0x1d4a6, 0x1d4a9, 0x1d4ac, 0x1d4ae, 0x1d4b9, 0x1d4bb, 0x1d4bb, 0x1d4bd, 0x1d4c0, 0x1d4c2, 0x1d4c3, 0x1d4c5, 0x1d505, 0x1d507, 0x1d50a, 0x1d50d, 0x1d514, 0x1d516, 0x1d51c, 0x1d51e, 0x1d539, 0x1d53b, 0x1d53e, 0x1d540, 0x1d544, 0x1d546, 0x1d546, 0x1d54a, 0x1d550, 0x1d552, 0x1d6a3, 0x1d6a8, 0x1d7c9, 0x20000, 0x2a6d6, 0x2f800, 0x2fa1d, 0xf0000, 0xffffd, 0x100000, 0x10fffd]; // prettier-ignore-end
937
1118
 
938
1119
  var isBidirectionalL = function isBidirectionalL(character) {
939
1120
  return inRange(character, bidirectional_l);
940
1121
  };
941
1122
 
942
- /**
943
- * non-ASCII space characters [StringPrep, C.1.2] that can be
944
- * mapped to SPACE (U+0020)
1123
+ /**
1124
+ * non-ASCII space characters [StringPrep, C.1.2] that can be
1125
+ * mapped to SPACE (U+0020)
945
1126
  */
946
1127
 
947
1128
  var mapping2space = isNonASCIISpaceCharacter;
948
- /**
949
- * the "commonly mapped to nothing" characters [StringPrep, B.1]
950
- * that can be mapped to nothing.
1129
+ /**
1130
+ * the "commonly mapped to nothing" characters [StringPrep, B.1]
1131
+ * that can be mapped to nothing.
951
1132
  */
952
1133
 
953
1134
  var mapping2nothing = isCommonlyMappedToNothing; // utils
@@ -963,12 +1144,12 @@ var first = function first(x) {
963
1144
  var last = function last(x) {
964
1145
  return x[x.length - 1];
965
1146
  };
966
- /**
967
- * Convert provided string into an array of Unicode Code Points.
968
- * Based on https://stackoverflow.com/a/21409165/1556249
969
- * and https://www.npmjs.com/package/code-point-at.
970
- * @param {string} input
971
- * @returns {number[]}
1147
+ /**
1148
+ * Convert provided string into an array of Unicode Code Points.
1149
+ * Based on https://stackoverflow.com/a/21409165/1556249
1150
+ * and https://www.npmjs.com/package/code-point-at.
1151
+ * @param {string} input
1152
+ * @returns {number[]}
972
1153
  */
973
1154
 
974
1155
 
@@ -994,12 +1175,12 @@ function toCodePoints(input) {
994
1175
 
995
1176
  return codepoints;
996
1177
  }
997
- /**
998
- * SASLprep.
999
- * @param {string} input
1000
- * @param {Object} opts
1001
- * @param {boolean} opts.allowUnassigned
1002
- * @returns {string}
1178
+ /**
1179
+ * SASLprep.
1180
+ * @param {string} input
1181
+ * @param {Object} opts
1182
+ * @param {boolean} opts.allowUnassigned
1183
+ * @returns {string}
1003
1184
  */
1004
1185
 
1005
1186
 
@@ -1049,10 +1230,10 @@ function saslprep(input) {
1049
1230
  if (hasBidiRAL && hasBidiL) {
1050
1231
  throw new Error('String must not contain RandALCat and LCat at the same time,' + ' see https://tools.ietf.org/html/rfc3454#section-6');
1051
1232
  }
1052
- /**
1053
- * 4.2 If a string contains any RandALCat character, a RandALCat
1054
- * character MUST be the first character of the string, and a
1055
- * RandALCat character MUST be the last character of the string.
1233
+ /**
1234
+ * 4.2 If a string contains any RandALCat character, a RandALCat
1235
+ * character MUST be the first character of the string, and a
1236
+ * RandALCat character MUST be the last character of the string.
1056
1237
  */
1057
1238
 
1058
1239
 
@@ -1066,9 +1247,7 @@ function saslprep(input) {
1066
1247
  return normalized_input;
1067
1248
  }
1068
1249
 
1069
- var PDFSecurity =
1070
- /*#__PURE__*/
1071
- function () {
1250
+ var PDFSecurity = /*#__PURE__*/function () {
1072
1251
  _createClass(PDFSecurity, null, [{
1073
1252
  key: "generateFileID",
1074
1253
  value: function generateFileID() {
@@ -1076,11 +1255,12 @@ function () {
1076
1255
  var infoStr = "".concat(info.CreationDate.getTime(), "\n");
1077
1256
 
1078
1257
  for (var key in info) {
1258
+ // eslint-disable-next-line no-prototype-builtins
1079
1259
  if (!info.hasOwnProperty(key)) {
1080
1260
  continue;
1081
1261
  }
1082
1262
 
1083
- infoStr += "".concat(key, ": ").concat(info[key], "\n");
1263
+ infoStr += "".concat(key, ": ").concat(info[key].valueOf(), "\n");
1084
1264
  }
1085
1265
 
1086
1266
  return wordArrayToBuffer(CryptoJS.MD5(infoStr));
@@ -1224,7 +1404,7 @@ function () {
1224
1404
  key: "_setupEncryptionV5",
1225
1405
  value: function _setupEncryptionV5(encDict, options) {
1226
1406
  this.keyBits = 256;
1227
- var permissions = getPermissionsR3(options);
1407
+ var permissions = getPermissionsR3(options.permissions);
1228
1408
  var processedUserPassword = processPasswordR5(options.userPassword);
1229
1409
  var processedOwnerPassword = options.ownerPassword ? processPasswordR5(options.ownerPassword) : processedUserPassword;
1230
1410
  this.encryptionKey = getEncryptionKeyR5(PDFSecurity.generateRandomWordArray);
@@ -1468,7 +1648,7 @@ function getEncryptedPermissionsR5(permissions, encryptionKey, generateRandomWor
1468
1648
 
1469
1649
  function processPasswordR2R3R4() {
1470
1650
  var password = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1471
- var out = new Buffer(32);
1651
+ var out = Buffer.alloc(32);
1472
1652
  var length = password.length;
1473
1653
  var index = 0;
1474
1654
 
@@ -1495,7 +1675,7 @@ function processPasswordR5() {
1495
1675
  var password = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1496
1676
  password = unescape(encodeURIComponent(saslprep(password)));
1497
1677
  var length = Math.min(127, password.length);
1498
- var out = new Buffer(length);
1678
+ var out = Buffer.alloc(length);
1499
1679
 
1500
1680
  for (var i = 0; i < length; i++) {
1501
1681
  out[i] = password.charCodeAt(i);
@@ -1522,9 +1702,7 @@ var PASSWORD_PADDING = [0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x
1522
1702
 
1523
1703
  var number = PDFObject.number;
1524
1704
 
1525
- var PDFGradient =
1526
- /*#__PURE__*/
1527
- function () {
1705
+ var PDFGradient = /*#__PURE__*/function () {
1528
1706
  function PDFGradient(doc) {
1529
1707
  _classCallCheck(this, PDFGradient);
1530
1708
 
@@ -1639,28 +1817,19 @@ function () {
1639
1817
  })) {
1640
1818
  var grad = this.opacityGradient();
1641
1819
  grad._colorSpace = 'DeviceGray';
1642
- var _iteratorNormalCompletion = true;
1643
- var _didIteratorError = false;
1644
- var _iteratorError = undefined;
1820
+
1821
+ var _iterator = _createForOfIteratorHelper(this.stops),
1822
+ _step;
1645
1823
 
1646
1824
  try {
1647
- for (var _iterator = this.stops[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
1825
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1648
1826
  var stop = _step.value;
1649
1827
  grad.stop(stop[0], [stop[2]]);
1650
1828
  }
1651
1829
  } catch (err) {
1652
- _didIteratorError = true;
1653
- _iteratorError = err;
1830
+ _iterator.e(err);
1654
1831
  } finally {
1655
- try {
1656
- if (!_iteratorNormalCompletion && _iterator.return != null) {
1657
- _iterator.return();
1658
- }
1659
- } finally {
1660
- if (_didIteratorError) {
1661
- throw _iteratorError;
1662
- }
1663
- }
1832
+ _iterator.f();
1664
1833
  }
1665
1834
 
1666
1835
  grad = grad.embed(this.matrix);
@@ -1753,17 +1922,17 @@ function () {
1753
1922
  return PDFGradient;
1754
1923
  }();
1755
1924
 
1756
- var PDFLinearGradient =
1757
- /*#__PURE__*/
1758
- function (_PDFGradient) {
1925
+ var PDFLinearGradient = /*#__PURE__*/function (_PDFGradient) {
1759
1926
  _inherits(PDFLinearGradient, _PDFGradient);
1760
1927
 
1928
+ var _super = _createSuper(PDFLinearGradient);
1929
+
1761
1930
  function PDFLinearGradient(doc, x1, y1, x2, y2) {
1762
1931
  var _this;
1763
1932
 
1764
1933
  _classCallCheck(this, PDFLinearGradient);
1765
1934
 
1766
- _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFLinearGradient).call(this, doc));
1935
+ _this = _super.call(this, doc);
1767
1936
  _this.x1 = x1;
1768
1937
  _this.y1 = y1;
1769
1938
  _this.x2 = x2;
@@ -1792,17 +1961,17 @@ function (_PDFGradient) {
1792
1961
  return PDFLinearGradient;
1793
1962
  }(PDFGradient);
1794
1963
 
1795
- var PDFRadialGradient =
1796
- /*#__PURE__*/
1797
- function (_PDFGradient2) {
1964
+ var PDFRadialGradient = /*#__PURE__*/function (_PDFGradient2) {
1798
1965
  _inherits(PDFRadialGradient, _PDFGradient2);
1799
1966
 
1967
+ var _super2 = _createSuper(PDFRadialGradient);
1968
+
1800
1969
  function PDFRadialGradient(doc, x1, y1, r1, x2, y2, r2) {
1801
1970
  var _this2;
1802
1971
 
1803
1972
  _classCallCheck(this, PDFRadialGradient);
1804
1973
 
1805
- _this2 = _possibleConstructorReturn(this, _getPrototypeOf(PDFRadialGradient).call(this, doc));
1974
+ _this2 = _super2.call(this, doc);
1806
1975
  _this2.doc = doc;
1807
1976
  _this2.x1 = x1;
1808
1977
  _this2.y1 = y1;
@@ -2183,12 +2352,12 @@ var parse = function parse(path) {
2183
2352
  var curArg = '';
2184
2353
  var foundDecimal = false;
2185
2354
  var params = 0;
2186
- var _iteratorNormalCompletion = true;
2187
- var _didIteratorError = false;
2188
- var _iteratorError = undefined;
2355
+
2356
+ var _iterator = _createForOfIteratorHelper(path),
2357
+ _step;
2189
2358
 
2190
2359
  try {
2191
- for (var _iterator = path[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
2360
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2192
2361
  var c = _step.value;
2193
2362
 
2194
2363
  if (parameters[c] != null) {
@@ -2247,18 +2416,9 @@ var parse = function parse(path) {
2247
2416
  } // add the last command
2248
2417
 
2249
2418
  } catch (err) {
2250
- _didIteratorError = true;
2251
- _iteratorError = err;
2419
+ _iterator.e(err);
2252
2420
  } finally {
2253
- try {
2254
- if (!_iteratorNormalCompletion && _iterator.return != null) {
2255
- _iterator.return();
2256
- }
2257
- } finally {
2258
- if (_didIteratorError) {
2259
- throw _iteratorError;
2260
- }
2261
- }
2421
+ _iterator.f();
2262
2422
  }
2263
2423
 
2264
2424
  if (curArg.length > 0) {
@@ -2466,29 +2626,20 @@ var solveArc = function solveArc(doc, x, y, coords) {
2466
2626
  ey = _coords[6];
2467
2627
 
2468
2628
  var segs = arcToSegments(ex, ey, rx, ry, large, sweep, rot, x, y);
2469
- var _iteratorNormalCompletion2 = true;
2470
- var _didIteratorError2 = false;
2471
- var _iteratorError2 = undefined;
2629
+
2630
+ var _iterator2 = _createForOfIteratorHelper(segs),
2631
+ _step2;
2472
2632
 
2473
2633
  try {
2474
- for (var _iterator2 = segs[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
2634
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2475
2635
  var seg = _step2.value;
2476
2636
  var bez = segmentToBezier.apply(void 0, _toConsumableArray(seg));
2477
2637
  doc.bezierCurveTo.apply(doc, _toConsumableArray(bez));
2478
2638
  }
2479
2639
  } catch (err) {
2480
- _didIteratorError2 = true;
2481
- _iteratorError2 = err;
2640
+ _iterator2.e(err);
2482
2641
  } finally {
2483
- try {
2484
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
2485
- _iterator2.return();
2486
- }
2487
- } finally {
2488
- if (_didIteratorError2) {
2489
- throw _iteratorError2;
2490
- }
2491
- }
2642
+ _iterator2.f();
2492
2643
  }
2493
2644
  }; // from Inkscape svgtopdf, thanks!
2494
2645
 
@@ -2570,9 +2721,7 @@ var segmentToBezier = function segmentToBezier(cx, cy, th0, th1, rx, ry, sin_th,
2570
2721
  return [a00 * x1 + a01 * y1, a10 * x1 + a11 * y1, a00 * x2 + a01 * y2, a10 * x2 + a11 * y2, a00 * x3 + a01 * y3, a10 * x3 + a11 * y3];
2571
2722
  };
2572
2723
 
2573
- var SVGPath =
2574
- /*#__PURE__*/
2575
- function () {
2724
+ var SVGPath = /*#__PURE__*/function () {
2576
2725
  function SVGPath() {
2577
2726
  _classCallCheck(this, SVGPath);
2578
2727
  }
@@ -2951,9 +3100,7 @@ var WIN_ANSI_MAP = {
2951
3100
  };
2952
3101
  var characters = ".notdef .notdef .notdef .notdef\n.notdef .notdef .notdef .notdef\n.notdef .notdef .notdef .notdef\n.notdef .notdef .notdef .notdef\n.notdef .notdef .notdef .notdef\n.notdef .notdef .notdef .notdef\n.notdef .notdef .notdef .notdef\n.notdef .notdef .notdef .notdef\n \nspace exclam quotedbl numbersign\ndollar percent ampersand quotesingle\nparenleft parenright asterisk plus\ncomma hyphen period slash\nzero one two three\nfour five six seven\neight nine colon semicolon\nless equal greater question\n \nat A B C\nD E F G\nH I J K\nL M N O\nP Q R S\nT U V W\nX Y Z bracketleft\nbackslash bracketright asciicircum underscore\n \ngrave a b c\nd e f g\nh i j k\nl m n o\np q r s\nt u v w\nx y z braceleft\nbar braceright asciitilde .notdef\n \nEuro .notdef quotesinglbase florin\nquotedblbase ellipsis dagger daggerdbl\ncircumflex perthousand Scaron guilsinglleft\nOE .notdef Zcaron .notdef\n.notdef quoteleft quoteright quotedblleft\nquotedblright bullet endash emdash\ntilde trademark scaron guilsinglright\noe .notdef zcaron ydieresis\n \nspace exclamdown cent sterling\ncurrency yen brokenbar section\ndieresis copyright ordfeminine guillemotleft\nlogicalnot hyphen registered macron\ndegree plusminus twosuperior threesuperior\nacute mu paragraph periodcentered\ncedilla onesuperior ordmasculine guillemotright\nonequarter onehalf threequarters questiondown\n \nAgrave Aacute Acircumflex Atilde\nAdieresis Aring AE Ccedilla\nEgrave Eacute Ecircumflex Edieresis\nIgrave Iacute Icircumflex Idieresis\nEth Ntilde Ograve Oacute\nOcircumflex Otilde Odieresis multiply\nOslash Ugrave Uacute Ucircumflex\nUdieresis Yacute Thorn germandbls\n \nagrave aacute acircumflex atilde\nadieresis aring ae ccedilla\negrave eacute ecircumflex edieresis\nigrave iacute icircumflex idieresis\neth ntilde ograve oacute\nocircumflex otilde odieresis divide\noslash ugrave uacute ucircumflex\nudieresis yacute thorn ydieresis".split(/\s+/);
2953
3102
 
2954
- var AFMFont =
2955
- /*#__PURE__*/
2956
- function () {
3103
+ var AFMFont = /*#__PURE__*/function () {
2957
3104
  _createClass(AFMFont, null, [{
2958
3105
  key: "open",
2959
3106
  value: function open(filename) {
@@ -2991,12 +3138,12 @@ function () {
2991
3138
  key: "parse",
2992
3139
  value: function parse() {
2993
3140
  var section = '';
2994
- var _iteratorNormalCompletion = true;
2995
- var _didIteratorError = false;
2996
- var _iteratorError = undefined;
3141
+
3142
+ var _iterator = _createForOfIteratorHelper(this.contents.split('\n')),
3143
+ _step;
2997
3144
 
2998
3145
  try {
2999
- for (var _iterator = this.contents.split('\n')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
3146
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
3000
3147
  var line = _step.value;
3001
3148
  var match;
3002
3149
  var a;
@@ -3047,18 +3194,9 @@ function () {
3047
3194
  }
3048
3195
  }
3049
3196
  } catch (err) {
3050
- _didIteratorError = true;
3051
- _iteratorError = err;
3197
+ _iterator.e(err);
3052
3198
  } finally {
3053
- try {
3054
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3055
- _iterator.return();
3056
- }
3057
- } finally {
3058
- if (_didIteratorError) {
3059
- throw _iteratorError;
3060
- }
3061
- }
3199
+ _iterator.f();
3062
3200
  }
3063
3201
  }
3064
3202
  }, {
@@ -3119,9 +3257,7 @@ function () {
3119
3257
  return AFMFont;
3120
3258
  }();
3121
3259
 
3122
- var PDFFont =
3123
- /*#__PURE__*/
3124
- function () {
3260
+ var PDFFont = /*#__PURE__*/function () {
3125
3261
  function PDFFont() {
3126
3262
  _classCallCheck(this, PDFFont);
3127
3263
  }
@@ -3216,17 +3352,17 @@ var STANDARD_FONTS = {
3216
3352
  }
3217
3353
  };
3218
3354
 
3219
- var StandardFont =
3220
- /*#__PURE__*/
3221
- function (_PDFFont) {
3355
+ var StandardFont = /*#__PURE__*/function (_PDFFont) {
3222
3356
  _inherits(StandardFont, _PDFFont);
3223
3357
 
3358
+ var _super = _createSuper(StandardFont);
3359
+
3224
3360
  function StandardFont(document, name, id) {
3225
3361
  var _this;
3226
3362
 
3227
3363
  _classCallCheck(this, StandardFont);
3228
3364
 
3229
- _this = _possibleConstructorReturn(this, _getPrototypeOf(StandardFont).call(this));
3365
+ _this = _super.call(this);
3230
3366
  _this.document = document;
3231
3367
  _this.name = name;
3232
3368
  _this.id = id;
@@ -3279,28 +3415,19 @@ function (_PDFFont) {
3279
3415
  var glyphs = this.font.glyphsForString("".concat(string));
3280
3416
  var advances = this.font.advancesForGlyphs(glyphs);
3281
3417
  var width = 0;
3282
- var _iteratorNormalCompletion = true;
3283
- var _didIteratorError = false;
3284
- var _iteratorError = undefined;
3418
+
3419
+ var _iterator = _createForOfIteratorHelper(advances),
3420
+ _step;
3285
3421
 
3286
3422
  try {
3287
- for (var _iterator = advances[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
3423
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
3288
3424
  var advance = _step.value;
3289
3425
  width += advance;
3290
3426
  }
3291
3427
  } catch (err) {
3292
- _didIteratorError = true;
3293
- _iteratorError = err;
3428
+ _iterator.e(err);
3294
3429
  } finally {
3295
- try {
3296
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3297
- _iterator.return();
3298
- }
3299
- } finally {
3300
- if (_didIteratorError) {
3301
- throw _iteratorError;
3302
- }
3303
- }
3430
+ _iterator.f();
3304
3431
  }
3305
3432
 
3306
3433
  var scale = size / 1000;
@@ -3320,17 +3447,17 @@ var toHex = function toHex(num) {
3320
3447
  return "0000".concat(num.toString(16)).slice(-4);
3321
3448
  };
3322
3449
 
3323
- var EmbeddedFont =
3324
- /*#__PURE__*/
3325
- function (_PDFFont) {
3450
+ var EmbeddedFont = /*#__PURE__*/function (_PDFFont) {
3326
3451
  _inherits(EmbeddedFont, _PDFFont);
3327
3452
 
3453
+ var _super = _createSuper(EmbeddedFont);
3454
+
3328
3455
  function EmbeddedFont(document, font, id) {
3329
3456
  var _this;
3330
3457
 
3331
3458
  _classCallCheck(this, EmbeddedFont);
3332
3459
 
3333
- _this = _possibleConstructorReturn(this, _getPrototypeOf(EmbeddedFont).call(this));
3460
+ _this = _super.call(this);
3334
3461
  _this.document = document;
3335
3462
  _this.font = font;
3336
3463
  _this.id = id;
@@ -3495,11 +3622,11 @@ function (_PDFFont) {
3495
3622
 
3496
3623
  if (this.font.head.macStyle.italic) {
3497
3624
  flags |= 1 << 6;
3498
- } // generate a tag (6 uppercase letters. 16 is the char code offset from '1' to 'A'. 74 will map to 'Z')
3625
+ } // generate a tag (6 uppercase letters. 17 is the char code offset from '0' to 'A'. 73 will map to 'Z')
3499
3626
 
3500
3627
 
3501
3628
  var tag = [1, 2, 3, 4, 5, 6].map(function (i) {
3502
- return String.fromCharCode((_this2.id.charCodeAt(i) || 74) + 16);
3629
+ return String.fromCharCode((_this2.id.charCodeAt(i) || 73) + 17);
3503
3630
  }).join('');
3504
3631
  var name = tag + '+' + this.font.postscriptName;
3505
3632
  var bbox = this.font.bbox;
@@ -3561,21 +3688,20 @@ function (_PDFFont) {
3561
3688
  value: function toUnicodeCmap() {
3562
3689
  var cmap = this.document.ref();
3563
3690
  var entries = [];
3564
- var _iteratorNormalCompletion = true;
3565
- var _didIteratorError = false;
3566
- var _iteratorError = undefined;
3691
+
3692
+ var _iterator = _createForOfIteratorHelper(this.unicode),
3693
+ _step;
3567
3694
 
3568
3695
  try {
3569
- for (var _iterator = this.unicode[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
3696
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
3570
3697
  var codePoints = _step.value;
3571
3698
  var encoded = []; // encode codePoints to utf16
3572
3699
 
3573
- var _iteratorNormalCompletion2 = true;
3574
- var _didIteratorError2 = false;
3575
- var _iteratorError2 = undefined;
3700
+ var _iterator2 = _createForOfIteratorHelper(codePoints),
3701
+ _step2;
3576
3702
 
3577
3703
  try {
3578
- for (var _iterator2 = codePoints[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
3704
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3579
3705
  var value = _step2.value;
3580
3706
 
3581
3707
  if (value > 0xffff) {
@@ -3587,35 +3713,17 @@ function (_PDFFont) {
3587
3713
  encoded.push(toHex(value));
3588
3714
  }
3589
3715
  } catch (err) {
3590
- _didIteratorError2 = true;
3591
- _iteratorError2 = err;
3716
+ _iterator2.e(err);
3592
3717
  } finally {
3593
- try {
3594
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
3595
- _iterator2.return();
3596
- }
3597
- } finally {
3598
- if (_didIteratorError2) {
3599
- throw _iteratorError2;
3600
- }
3601
- }
3718
+ _iterator2.f();
3602
3719
  }
3603
3720
 
3604
3721
  entries.push("<".concat(encoded.join(' '), ">"));
3605
3722
  }
3606
3723
  } catch (err) {
3607
- _didIteratorError = true;
3608
- _iteratorError = err;
3724
+ _iterator.e(err);
3609
3725
  } finally {
3610
- try {
3611
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3612
- _iterator.return();
3613
- }
3614
- } finally {
3615
- if (_didIteratorError) {
3616
- throw _iteratorError;
3617
- }
3618
- }
3726
+ _iterator.f();
3619
3727
  }
3620
3728
 
3621
3729
  cmap.end("/CIDInit /ProcSet findresource begin\n12 dict begin\nbegincmap\n/CIDSystemInfo <<\n /Registry (Adobe)\n /Ordering (UCS)\n /Supplement 0\n>> def\n/CMapName /Adobe-Identity-UCS def\n/CMapType 2 def\n1 begincodespacerange\n<0000><ffff>\nendcodespacerange\n1 beginbfrange\n<0000> <".concat(toHex(entries.length - 1), "> [").concat(entries.join(' '), "]\nendbfrange\nendcmap\nCMapName currentdict /CMap defineresource pop\nend\nend"));
@@ -3626,9 +3734,7 @@ function (_PDFFont) {
3626
3734
  return EmbeddedFont;
3627
3735
  }(PDFFont);
3628
3736
 
3629
- var PDFFontFactory =
3630
- /*#__PURE__*/
3631
- function () {
3737
+ var PDFFontFactory = /*#__PURE__*/function () {
3632
3738
  function PDFFontFactory() {
3633
3739
  _classCallCheck(this, PDFFontFactory);
3634
3740
  }
@@ -3649,9 +3755,9 @@ function () {
3649
3755
  if (Buffer.isBuffer(src)) {
3650
3756
  font = fontkit.create(src, family);
3651
3757
  } else if (src instanceof Uint8Array) {
3652
- font = fontkit.create(new Buffer(src), family);
3758
+ font = fontkit.create(Buffer.from(src), family);
3653
3759
  } else if (src instanceof ArrayBuffer) {
3654
- font = fontkit.create(new Buffer(new Uint8Array(src)), family);
3760
+ font = fontkit.create(Buffer.from(new Uint8Array(src)), family);
3655
3761
  }
3656
3762
 
3657
3763
  if (font == null) {
@@ -3753,17 +3859,17 @@ var FontsMixin = {
3753
3859
  }
3754
3860
  };
3755
3861
 
3756
- var LineWrapper =
3757
- /*#__PURE__*/
3758
- function (_EventEmitter) {
3862
+ var LineWrapper = /*#__PURE__*/function (_EventEmitter) {
3759
3863
  _inherits(LineWrapper, _EventEmitter);
3760
3864
 
3865
+ var _super = _createSuper(LineWrapper);
3866
+
3761
3867
  function LineWrapper(document, options) {
3762
3868
  var _this;
3763
3869
 
3764
3870
  _classCallCheck(this, LineWrapper);
3765
3871
 
3766
- _this = _possibleConstructorReturn(this, _getPrototypeOf(LineWrapper).call(this));
3872
+ _this = _super.call(this);
3767
3873
  _this.document = document;
3768
3874
  _this.indent = options.indent || 0;
3769
3875
  _this.characterSpacing = options.characterSpacing || 0;
@@ -3986,7 +4092,7 @@ function (_EventEmitter) {
3986
4092
 
3987
4093
  buffer = buffer.replace(/\s+$/, '');
3988
4094
  textWidth = _this2.wordWidth(buffer + _this2.ellipsis); // remove characters from the buffer until the ellipsis fits
3989
- // to avoid inifinite loop need to stop while-loop if buffer is empty string
4095
+ // to avoid infinite loop need to stop while-loop if buffer is empty string
3990
4096
 
3991
4097
  while (buffer && textWidth > _this2.lineWidth) {
3992
4098
  buffer = buffer.slice(0, -1).replace(/\s+$/, '');
@@ -4076,7 +4182,7 @@ function (_EventEmitter) {
4076
4182
  return false;
4077
4183
  }
4078
4184
 
4079
- this.document.addPage();
4185
+ this.document.continueOnNewPage();
4080
4186
  this.column = 1;
4081
4187
  this.startY = this.document.page.margins.top;
4082
4188
  this.maxY = this.document.page.maxY();
@@ -4133,13 +4239,21 @@ var TextMixin = {
4133
4239
  return this;
4134
4240
  },
4135
4241
  _text: function _text(text, x, y, options, lineCallback) {
4242
+ var _this = this;
4243
+
4136
4244
  options = this._initOptions(x, y, options); // Convert text to a string
4137
4245
 
4138
4246
  text = text == null ? '' : "".concat(text); // if the wordSpacing option is specified, remove multiple consecutive spaces
4139
4247
 
4140
4248
  if (options.wordSpacing) {
4141
4249
  text = text.replace(/\s{2,}/g, ' ');
4142
- } // word wrapping
4250
+ }
4251
+
4252
+ var addStructure = function addStructure() {
4253
+ if (options.structParent) {
4254
+ options.structParent.add(_this.struct(options.structType || 'P', [_this.markStructureContent(options.structType || 'P')]));
4255
+ }
4256
+ }; // word wrapping
4143
4257
 
4144
4258
 
4145
4259
  if (options.width) {
@@ -4148,34 +4262,26 @@ var TextMixin = {
4148
4262
  if (!wrapper) {
4149
4263
  wrapper = new LineWrapper(this, options);
4150
4264
  wrapper.on('line', lineCallback);
4265
+ wrapper.on('firstLine', addStructure);
4151
4266
  }
4152
4267
 
4153
4268
  this._wrapper = options.continued ? wrapper : null;
4154
4269
  this._textOptions = options.continued ? options : null;
4155
4270
  wrapper.wrap(text, options); // render paragraphs as single lines
4156
4271
  } else {
4157
- var _iteratorNormalCompletion = true;
4158
- var _didIteratorError = false;
4159
- var _iteratorError = undefined;
4272
+ var _iterator = _createForOfIteratorHelper(text.split('\n')),
4273
+ _step;
4160
4274
 
4161
4275
  try {
4162
- for (var _iterator = text.split('\n')[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
4276
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4163
4277
  var line = _step.value;
4278
+ addStructure();
4164
4279
  lineCallback(line, options);
4165
4280
  }
4166
4281
  } catch (err) {
4167
- _didIteratorError = true;
4168
- _iteratorError = err;
4282
+ _iterator.e(err);
4169
4283
  } finally {
4170
- try {
4171
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4172
- _iterator.return();
4173
- }
4174
- } finally {
4175
- if (_didIteratorError) {
4176
- throw _iteratorError;
4177
- }
4178
- }
4284
+ _iterator.f();
4179
4285
  }
4180
4286
  }
4181
4287
 
@@ -4189,7 +4295,7 @@ var TextMixin = {
4189
4295
  return this._font.widthOfString(string, this._fontSize, options.features) + (options.characterSpacing || 0) * (string.length - 1);
4190
4296
  },
4191
4297
  heightOfString: function heightOfString(text, options) {
4192
- var _this = this;
4298
+ var _this2 = this;
4193
4299
 
4194
4300
  var x = this.x,
4195
4301
  y = this.y;
@@ -4199,7 +4305,7 @@ var TextMixin = {
4199
4305
  var lineGap = options.lineGap || this._lineGap || 0;
4200
4306
 
4201
4307
  this._text(text, this.x, this.y, options, function () {
4202
- return _this.y += _this.currentLineHeight(true) + lineGap;
4308
+ return _this2.y += _this2.currentLineHeight(true) + lineGap;
4203
4309
  });
4204
4310
 
4205
4311
  var height = this.y - y;
@@ -4208,7 +4314,7 @@ var TextMixin = {
4208
4314
  return height;
4209
4315
  },
4210
4316
  list: function list(_list, x, y, options, wrapper) {
4211
- var _this2 = this;
4317
+ var _this3 = this;
4212
4318
 
4213
4319
  options = this._initOptions(x, y, options);
4214
4320
  var listType = options.listType || 'bullet';
@@ -4263,35 +4369,75 @@ var TextMixin = {
4263
4369
  level = 1;
4264
4370
  var i = 0;
4265
4371
  wrapper.on('firstLine', function () {
4372
+ var item, itemType, labelType, bodyType;
4373
+
4374
+ if (options.structParent) {
4375
+ if (options.structTypes) {
4376
+ var _options$structTypes = _slicedToArray(options.structTypes, 3);
4377
+
4378
+ itemType = _options$structTypes[0];
4379
+ labelType = _options$structTypes[1];
4380
+ bodyType = _options$structTypes[2];
4381
+ } else {
4382
+ itemType = 'LI';
4383
+ labelType = 'Lbl';
4384
+ bodyType = 'LBody';
4385
+ }
4386
+ }
4387
+
4388
+ if (itemType) {
4389
+ item = _this3.struct(itemType);
4390
+ options.structParent.add(item);
4391
+ } else if (options.structParent) {
4392
+ item = options.structParent;
4393
+ }
4394
+
4266
4395
  var l;
4267
4396
 
4268
4397
  if ((l = levels[i++]) !== level) {
4269
4398
  var diff = itemIndent * (l - level);
4270
- _this2.x += diff;
4399
+ _this3.x += diff;
4271
4400
  wrapper.lineWidth -= diff;
4272
4401
  level = l;
4273
4402
  }
4274
4403
 
4404
+ if (item && (labelType || bodyType)) {
4405
+ item.add(_this3.struct(labelType || bodyType, [_this3.markStructureContent(labelType || bodyType)]));
4406
+ }
4407
+
4275
4408
  switch (listType) {
4276
4409
  case 'bullet':
4277
- _this2.circle(_this2.x - indent + r, _this2.y + midLine, r);
4410
+ _this3.circle(_this3.x - indent + r, _this3.y + midLine, r);
4278
4411
 
4279
- return _this2.fill();
4412
+ _this3.fill();
4413
+
4414
+ break;
4280
4415
 
4281
4416
  case 'numbered':
4282
4417
  case 'lettered':
4283
4418
  var text = label(numbers[i - 1]);
4284
- return _this2._fragment(text, _this2.x - indent, _this2.y, options);
4419
+
4420
+ _this3._fragment(text, _this3.x - indent, _this3.y, options);
4421
+
4422
+ break;
4423
+ }
4424
+
4425
+ if (item && labelType && bodyType) {
4426
+ item.add(_this3.struct(bodyType, [_this3.markStructureContent(bodyType)]));
4427
+ }
4428
+
4429
+ if (item && item !== options.structParent) {
4430
+ item.end();
4285
4431
  }
4286
4432
  });
4287
4433
  wrapper.on('sectionStart', function () {
4288
4434
  var pos = indent + itemIndent * (level - 1);
4289
- _this2.x += pos;
4435
+ _this3.x += pos;
4290
4436
  return wrapper.lineWidth -= pos;
4291
4437
  });
4292
4438
  wrapper.on('sectionEnd', function () {
4293
4439
  var pos = indent + itemIndent * (level - 1);
4294
- _this2.x -= pos;
4440
+ _this3.x -= pos;
4295
4441
  return wrapper.lineWidth += pos;
4296
4442
  });
4297
4443
  wrapper.wrap(items.join('\n'), options);
@@ -4366,7 +4512,7 @@ var TextMixin = {
4366
4512
  }
4367
4513
  },
4368
4514
  _fragment: function _fragment(text, x, y, options) {
4369
- var _this3 = this;
4515
+ var _this4 = this;
4370
4516
 
4371
4517
  var dy, encoded, i, positions, textWidth, words;
4372
4518
  text = "".concat(text).replace(/\n/g, '');
@@ -4456,10 +4602,10 @@ var TextMixin = {
4456
4602
 
4457
4603
  if (options.destination != null) {
4458
4604
  this.addNamedDestination(options.destination, 'XYZ', x, y, null);
4459
- } // create underline or strikethrough line
4605
+ } // create underline
4460
4606
 
4461
4607
 
4462
- if (options.underline || options.strike) {
4608
+ if (options.underline) {
4463
4609
  this.save();
4464
4610
 
4465
4611
  if (!options.stroke) {
@@ -4468,15 +4614,29 @@ var TextMixin = {
4468
4614
 
4469
4615
  var lineWidth = this._fontSize < 10 ? 0.5 : Math.floor(this._fontSize / 10);
4470
4616
  this.lineWidth(lineWidth);
4471
- var d = options.underline ? 1 : 2;
4472
- var lineY = y + this.currentLineHeight() / d;
4617
+ var lineY = y + this.currentLineHeight() - lineWidth;
4618
+ this.moveTo(x, lineY);
4619
+ this.lineTo(x + renderedWidth, lineY);
4620
+ this.stroke();
4621
+ this.restore();
4622
+ } // create strikethrough line
4623
+
4624
+
4625
+ if (options.strike) {
4626
+ this.save();
4473
4627
 
4474
- if (options.underline) {
4475
- lineY -= lineWidth;
4628
+ if (!options.stroke) {
4629
+ this.strokeColor.apply(this, _toConsumableArray(this._fillColor || []));
4476
4630
  }
4477
4631
 
4478
- this.moveTo(x, lineY);
4479
- this.lineTo(x + renderedWidth, lineY);
4632
+ var _lineWidth = this._fontSize < 10 ? 0.5 : Math.floor(this._fontSize / 10);
4633
+
4634
+ this.lineWidth(_lineWidth);
4635
+
4636
+ var _lineY = y + this.currentLineHeight() / 2;
4637
+
4638
+ this.moveTo(x, _lineY);
4639
+ this.lineTo(x + renderedWidth, _lineY);
4480
4640
  this.stroke();
4481
4641
  this.restore();
4482
4642
  }
@@ -4533,12 +4693,12 @@ var TextMixin = {
4533
4693
  wordSpacing *= 1000 / this._fontSize;
4534
4694
  encoded = [];
4535
4695
  positions = [];
4536
- var _iteratorNormalCompletion2 = true;
4537
- var _didIteratorError2 = false;
4538
- var _iteratorError2 = undefined;
4696
+
4697
+ var _iterator2 = _createForOfIteratorHelper(words),
4698
+ _step2;
4539
4699
 
4540
4700
  try {
4541
- for (var _iterator2 = words[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
4701
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4542
4702
  var word = _step2.value;
4543
4703
 
4544
4704
  var _this$_font$encode = this._font.encode(word, options.features),
@@ -4562,18 +4722,9 @@ var TextMixin = {
4562
4722
  positions[positions.length - 1] = space;
4563
4723
  }
4564
4724
  } catch (err) {
4565
- _didIteratorError2 = true;
4566
- _iteratorError2 = err;
4725
+ _iterator2.e(err);
4567
4726
  } finally {
4568
- try {
4569
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
4570
- _iterator2.return();
4571
- }
4572
- } finally {
4573
- if (_didIteratorError2) {
4574
- throw _iteratorError2;
4575
- }
4576
- }
4727
+ _iterator2.f();
4577
4728
  }
4578
4729
  } else {
4579
4730
  var _this$_font$encode3 = this._font.encode(text, options.features);
@@ -4604,7 +4755,7 @@ var TextMixin = {
4604
4755
  addSegment(i);
4605
4756
 
4606
4757
  if (commands.length > 0) {
4607
- _this3.addContent("[".concat(commands.join(' '), "] TJ"));
4758
+ _this4.addContent("[".concat(commands.join(' '), "] TJ"));
4608
4759
 
4609
4760
  return commands.length = 0;
4610
4761
  }
@@ -4654,9 +4805,7 @@ var COLOR_SPACE_MAP = {
4654
4805
  4: 'DeviceCMYK'
4655
4806
  };
4656
4807
 
4657
- var JPEG =
4658
- /*#__PURE__*/
4659
- function () {
4808
+ var JPEG = /*#__PURE__*/function () {
4660
4809
  function JPEG(data, label) {
4661
4810
  _classCallCheck(this, JPEG);
4662
4811
 
@@ -4728,9 +4877,7 @@ function () {
4728
4877
  return JPEG;
4729
4878
  }();
4730
4879
 
4731
- var PNGImage =
4732
- /*#__PURE__*/
4733
- function () {
4880
+ var PNGImage = /*#__PURE__*/function () {
4734
4881
  function PNGImage(data, label) {
4735
4882
  _classCallCheck(this, PNGImage);
4736
4883
 
@@ -4779,7 +4926,7 @@ function () {
4779
4926
  } else {
4780
4927
  // embed the color palette in the PDF as an object stream
4781
4928
  var palette = this.document.ref();
4782
- palette.end(new Buffer(this.image.palette)); // build the color space array for the image
4929
+ palette.end(Buffer.from(this.image.palette)); // build the color space array for the image
4783
4930
 
4784
4931
  this.obj.data['ColorSpace'] = ['Indexed', 'DeviceRGB', this.image.palette.length / 3 - 1, palette];
4785
4932
  } // For PNG color types 0, 2 and 3, the transparency data is stored in
@@ -4796,28 +4943,19 @@ function () {
4796
4943
  // An array with N elements, where N is two times the number of color components.
4797
4944
  var rgb = this.image.transparency.rgb;
4798
4945
  var mask = [];
4799
- var _iteratorNormalCompletion = true;
4800
- var _didIteratorError = false;
4801
- var _iteratorError = undefined;
4946
+
4947
+ var _iterator = _createForOfIteratorHelper(rgb),
4948
+ _step;
4802
4949
 
4803
4950
  try {
4804
- for (var _iterator = rgb[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
4951
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4805
4952
  var x = _step.value;
4806
4953
  mask.push(x, x);
4807
4954
  }
4808
4955
  } catch (err) {
4809
- _didIteratorError = true;
4810
- _iteratorError = err;
4956
+ _iterator.e(err);
4811
4957
  } finally {
4812
- try {
4813
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4814
- _iterator.return();
4815
- }
4816
- } finally {
4817
- if (_didIteratorError) {
4818
- throw _iteratorError;
4819
- }
4820
- }
4958
+ _iterator.f();
4821
4959
  }
4822
4960
 
4823
4961
  this.obj.data['Mask'] = mask;
@@ -4873,8 +5011,8 @@ function () {
4873
5011
  var a, p;
4874
5012
  var colorCount = _this.image.colors;
4875
5013
  var pixelCount = _this.width * _this.height;
4876
- var imgData = new Buffer(pixelCount * colorCount);
4877
- var alphaChannel = new Buffer(pixelCount);
5014
+ var imgData = Buffer.alloc(pixelCount * colorCount);
5015
+ var alphaChannel = Buffer.alloc(pixelCount);
4878
5016
  var i = p = a = 0;
4879
5017
  var len = pixels.length; // For 16bit images copy only most significant byte (MSB) - PNG data is always stored in network byte order (MSB first)
4880
5018
 
@@ -4902,7 +5040,7 @@ function () {
4902
5040
 
4903
5041
  var transparency = this.image.transparency.indexed;
4904
5042
  return this.image.decodePixels(function (pixels) {
4905
- var alphaChannel = new Buffer(_this2.width * _this2.height);
5043
+ var alphaChannel = Buffer.alloc(_this2.width * _this2.height);
4906
5044
  var i = 0;
4907
5045
 
4908
5046
  for (var j = 0, end = pixels.length; j < end; j++) {
@@ -4929,9 +5067,7 @@ function () {
4929
5067
  return PNGImage;
4930
5068
  }();
4931
5069
 
4932
- var PDFImage =
4933
- /*#__PURE__*/
4934
- function () {
5070
+ var PDFImage = /*#__PURE__*/function () {
4935
5071
  function PDFImage() {
4936
5072
  _classCallCheck(this, PDFImage);
4937
5073
  }
@@ -4944,12 +5080,12 @@ function () {
4944
5080
  if (Buffer.isBuffer(src)) {
4945
5081
  data = src;
4946
5082
  } else if (src instanceof ArrayBuffer) {
4947
- data = new Buffer(new Uint8Array(src));
5083
+ data = Buffer.from(new Uint8Array(src));
4948
5084
  } else {
4949
5085
  var match;
4950
5086
 
4951
5087
  if (match = /^data:.+;base64,(.*)$/.exec(src)) {
4952
- data = new Buffer(match[1], 'base64');
5088
+ data = Buffer.from(match[1], 'base64');
4953
5089
  } else {
4954
5090
  data = fs.readFileSync(src);
4955
5091
 
@@ -5256,6 +5392,24 @@ var AnnotationsMixin = {
5256
5392
  options.DA = new String();
5257
5393
  return this.annotate(x, y, w, h, options);
5258
5394
  },
5395
+ fileAnnotation: function fileAnnotation(x, y, w, h) {
5396
+ var file = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
5397
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
5398
+ // create hidden file
5399
+ var filespec = this.file(file.src, Object.assign({
5400
+ hidden: true
5401
+ }, file));
5402
+ options.Subtype = 'FileAttachment';
5403
+ options.FS = filespec; // add description from filespec unless description (Contents) has already been set
5404
+
5405
+ if (options.Contents) {
5406
+ options.Contents = new String(options.Contents);
5407
+ } else if (filespec.data.Desc) {
5408
+ options.Contents = filespec.data.Desc;
5409
+ }
5410
+
5411
+ return this.annotate(x, y, w, h, options);
5412
+ },
5259
5413
  _convertRect: function _convertRect(x1, y1, w, h) {
5260
5414
  // flip y1 and y2
5261
5415
  var y2 = y1;
@@ -5279,9 +5433,7 @@ var AnnotationsMixin = {
5279
5433
  }
5280
5434
  };
5281
5435
 
5282
- var PDFOutline =
5283
- /*#__PURE__*/
5284
- function () {
5436
+ var PDFOutline = /*#__PURE__*/function () {
5285
5437
  function PDFOutline(document, parent, title, dest) {
5286
5438
  var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
5287
5439
  expanded: false
@@ -5368,32 +5520,523 @@ var OutlineMixin = {
5368
5520
  }
5369
5521
  };
5370
5522
 
5371
- var FIELD_FLAGS = {
5372
- readOnly: 1,
5373
- required: 2,
5374
- noExport: 4,
5375
- multiline: 0x1000,
5376
- password: 0x2000,
5377
- toggleToOffButton: 0x4000,
5378
- radioButton: 0x8000,
5379
- pushButton: 0x10000,
5380
- combo: 0x20000,
5381
- edit: 0x40000,
5382
- sort: 0x80000,
5383
- multiSelect: 0x200000,
5384
- noSpell: 0x400000
5385
- };
5386
- var FIELD_JUSTIFY = {
5387
- left: 0,
5388
- center: 1,
5389
- right: 2
5390
- };
5391
- var VALUE_MAP = {
5392
- value: 'V',
5393
- defaultValue: 'DV'
5394
- };
5395
- var FORMAT_SPECIAL = {
5396
- zip: '0',
5523
+ /*
5524
+ PDFStructureContent - a reference to a marked structure content
5525
+ By Ben Schmidt
5526
+ */
5527
+ var PDFStructureContent = /*#__PURE__*/function () {
5528
+ function PDFStructureContent(pageRef, mcid) {
5529
+ _classCallCheck(this, PDFStructureContent);
5530
+
5531
+ this.refs = [{
5532
+ pageRef: pageRef,
5533
+ mcid: mcid
5534
+ }];
5535
+ }
5536
+
5537
+ _createClass(PDFStructureContent, [{
5538
+ key: "push",
5539
+ value: function push(structContent) {
5540
+ var _this = this;
5541
+
5542
+ structContent.refs.forEach(function (ref) {
5543
+ return _this.refs.push(ref);
5544
+ });
5545
+ }
5546
+ }]);
5547
+
5548
+ return PDFStructureContent;
5549
+ }();
5550
+
5551
+ var PDFStructureElement = /*#__PURE__*/function () {
5552
+ function PDFStructureElement(document, type) {
5553
+ var _this = this;
5554
+
5555
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5556
+ var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
5557
+
5558
+ _classCallCheck(this, PDFStructureElement);
5559
+
5560
+ this.document = document;
5561
+ this._attached = false;
5562
+ this._ended = false;
5563
+ this._flushed = false;
5564
+ this.dictionary = document.ref({
5565
+ // Type: "StructElem",
5566
+ S: type
5567
+ });
5568
+ var data = this.dictionary.data;
5569
+
5570
+ if (Array.isArray(options) || this._isValidChild(options)) {
5571
+ children = options;
5572
+ options = {};
5573
+ }
5574
+
5575
+ if (typeof options.title !== 'undefined') {
5576
+ data.T = new String(options.title);
5577
+ }
5578
+
5579
+ if (typeof options.lang !== 'undefined') {
5580
+ data.Lang = new String(options.lang);
5581
+ }
5582
+
5583
+ if (typeof options.alt !== 'undefined') {
5584
+ data.Alt = new String(options.alt);
5585
+ }
5586
+
5587
+ if (typeof options.expanded !== 'undefined') {
5588
+ data.E = new String(options.expanded);
5589
+ }
5590
+
5591
+ if (typeof options.actual !== 'undefined') {
5592
+ data.ActualText = new String(options.actual);
5593
+ }
5594
+
5595
+ this._children = [];
5596
+
5597
+ if (children) {
5598
+ if (!Array.isArray(children)) {
5599
+ children = [children];
5600
+ }
5601
+
5602
+ children.forEach(function (child) {
5603
+ return _this.add(child);
5604
+ });
5605
+ this.end();
5606
+ }
5607
+ }
5608
+
5609
+ _createClass(PDFStructureElement, [{
5610
+ key: "add",
5611
+ value: function add(child) {
5612
+ if (this._ended) {
5613
+ throw new Error("Cannot add child to already-ended structure element");
5614
+ }
5615
+
5616
+ if (!this._isValidChild(child)) {
5617
+ throw new Error("Invalid structure element child");
5618
+ }
5619
+
5620
+ if (child instanceof PDFStructureElement) {
5621
+ child.setParent(this.dictionary);
5622
+
5623
+ if (this._attached) {
5624
+ child.setAttached();
5625
+ }
5626
+ }
5627
+
5628
+ if (child instanceof PDFStructureContent) {
5629
+ this._addContentToParentTree(child);
5630
+ }
5631
+
5632
+ if (typeof child === 'function' && this._attached) {
5633
+ // _contentForClosure() adds the content to the parent tree
5634
+ child = this._contentForClosure(child);
5635
+ }
5636
+
5637
+ this._children.push(child);
5638
+
5639
+ return this;
5640
+ }
5641
+ }, {
5642
+ key: "_addContentToParentTree",
5643
+ value: function _addContentToParentTree(content) {
5644
+ var _this2 = this;
5645
+
5646
+ content.refs.forEach(function (_ref) {
5647
+ var pageRef = _ref.pageRef,
5648
+ mcid = _ref.mcid;
5649
+
5650
+ var pageStructParents = _this2.document.getStructParentTree().get(pageRef.data.StructParents);
5651
+
5652
+ pageStructParents[mcid] = _this2.dictionary;
5653
+ });
5654
+ }
5655
+ }, {
5656
+ key: "setParent",
5657
+ value: function setParent(parentRef) {
5658
+ if (this.dictionary.data.P) {
5659
+ throw new Error("Structure element added to more than one parent");
5660
+ }
5661
+
5662
+ this.dictionary.data.P = parentRef;
5663
+
5664
+ this._flush();
5665
+ }
5666
+ }, {
5667
+ key: "setAttached",
5668
+ value: function setAttached() {
5669
+ var _this3 = this;
5670
+
5671
+ if (this._attached) {
5672
+ return;
5673
+ }
5674
+
5675
+ this._children.forEach(function (child, index) {
5676
+ if (child instanceof PDFStructureElement) {
5677
+ child.setAttached();
5678
+ }
5679
+
5680
+ if (typeof child === 'function') {
5681
+ _this3._children[index] = _this3._contentForClosure(child);
5682
+ }
5683
+ });
5684
+
5685
+ this._attached = true;
5686
+
5687
+ this._flush();
5688
+ }
5689
+ }, {
5690
+ key: "end",
5691
+ value: function end() {
5692
+ if (this._ended) {
5693
+ return;
5694
+ }
5695
+
5696
+ this._children.filter(function (child) {
5697
+ return child instanceof PDFStructureElement;
5698
+ }).forEach(function (child) {
5699
+ return child.end();
5700
+ });
5701
+
5702
+ this._ended = true;
5703
+
5704
+ this._flush();
5705
+ }
5706
+ }, {
5707
+ key: "_isValidChild",
5708
+ value: function _isValidChild(child) {
5709
+ return child instanceof PDFStructureElement || child instanceof PDFStructureContent || typeof child === 'function';
5710
+ }
5711
+ }, {
5712
+ key: "_contentForClosure",
5713
+ value: function _contentForClosure(closure) {
5714
+ var content = this.document.markStructureContent(this.dictionary.data.S);
5715
+ closure();
5716
+ this.document.endMarkedContent();
5717
+
5718
+ this._addContentToParentTree(content);
5719
+
5720
+ return content;
5721
+ }
5722
+ }, {
5723
+ key: "_isFlushable",
5724
+ value: function _isFlushable() {
5725
+ if (!this.dictionary.data.P || !this._ended) {
5726
+ return false;
5727
+ }
5728
+
5729
+ return this._children.every(function (child) {
5730
+ if (typeof child === 'function') {
5731
+ return false;
5732
+ }
5733
+
5734
+ if (child instanceof PDFStructureElement) {
5735
+ return child._isFlushable();
5736
+ }
5737
+
5738
+ return true;
5739
+ });
5740
+ }
5741
+ }, {
5742
+ key: "_flush",
5743
+ value: function _flush() {
5744
+ var _this4 = this;
5745
+
5746
+ if (this._flushed || !this._isFlushable()) {
5747
+ return;
5748
+ }
5749
+
5750
+ this.dictionary.data.K = [];
5751
+
5752
+ this._children.forEach(function (child) {
5753
+ return _this4._flushChild(child);
5754
+ });
5755
+
5756
+ this.dictionary.end(); // free memory used by children; the dictionary itself may still be
5757
+ // referenced by a parent structure element or root, but we can
5758
+ // at least trim the tree here
5759
+
5760
+ this._children = [];
5761
+ this.dictionary.data.K = null;
5762
+ this._flushed = true;
5763
+ }
5764
+ }, {
5765
+ key: "_flushChild",
5766
+ value: function _flushChild(child) {
5767
+ var _this5 = this;
5768
+
5769
+ if (child instanceof PDFStructureElement) {
5770
+ this.dictionary.data.K.push(child.dictionary);
5771
+ }
5772
+
5773
+ if (child instanceof PDFStructureContent) {
5774
+ child.refs.forEach(function (_ref2) {
5775
+ var pageRef = _ref2.pageRef,
5776
+ mcid = _ref2.mcid;
5777
+
5778
+ if (!_this5.dictionary.data.Pg) {
5779
+ _this5.dictionary.data.Pg = pageRef;
5780
+ }
5781
+
5782
+ if (_this5.dictionary.data.Pg === pageRef) {
5783
+ _this5.dictionary.data.K.push(mcid);
5784
+ } else {
5785
+ _this5.dictionary.data.K.push({
5786
+ Type: "MCR",
5787
+ Pg: pageRef,
5788
+ MCID: mcid
5789
+ });
5790
+ }
5791
+ });
5792
+ }
5793
+ }
5794
+ }]);
5795
+
5796
+ return PDFStructureElement;
5797
+ }();
5798
+
5799
+ var PDFNumberTree = /*#__PURE__*/function (_PDFTree) {
5800
+ _inherits(PDFNumberTree, _PDFTree);
5801
+
5802
+ var _super = _createSuper(PDFNumberTree);
5803
+
5804
+ function PDFNumberTree() {
5805
+ _classCallCheck(this, PDFNumberTree);
5806
+
5807
+ return _super.apply(this, arguments);
5808
+ }
5809
+
5810
+ _createClass(PDFNumberTree, [{
5811
+ key: "_compareKeys",
5812
+ value: function _compareKeys(a, b) {
5813
+ return parseInt(a) - parseInt(b);
5814
+ }
5815
+ }, {
5816
+ key: "_keysName",
5817
+ value: function _keysName() {
5818
+ return "Nums";
5819
+ }
5820
+ }, {
5821
+ key: "_dataForKey",
5822
+ value: function _dataForKey(k) {
5823
+ return parseInt(k);
5824
+ }
5825
+ }]);
5826
+
5827
+ return PDFNumberTree;
5828
+ }(PDFTree);
5829
+
5830
+ var MarkingsMixin = {
5831
+ initMarkings: function initMarkings(options) {
5832
+ this.structChildren = [];
5833
+
5834
+ if (options.tagged) {
5835
+ this.getMarkInfoDictionary().data.Marked = true;
5836
+ this.getStructTreeRoot();
5837
+ }
5838
+ },
5839
+ markContent: function markContent(tag) {
5840
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
5841
+
5842
+ if (tag === 'Artifact' || options && options.mcid) {
5843
+ var toClose = 0;
5844
+ this.page.markings.forEach(function (marking) {
5845
+ if (toClose || marking.structContent || marking.tag === 'Artifact') {
5846
+ toClose++;
5847
+ }
5848
+ });
5849
+
5850
+ while (toClose--) {
5851
+ this.endMarkedContent();
5852
+ }
5853
+ }
5854
+
5855
+ if (!options) {
5856
+ this.page.markings.push({
5857
+ tag: tag
5858
+ });
5859
+ this.addContent("/".concat(tag, " BMC"));
5860
+ return this;
5861
+ }
5862
+
5863
+ this.page.markings.push({
5864
+ tag: tag,
5865
+ options: options
5866
+ });
5867
+ var dictionary = {};
5868
+
5869
+ if (typeof options.mcid !== 'undefined') {
5870
+ dictionary.MCID = options.mcid;
5871
+ }
5872
+
5873
+ if (tag === 'Artifact') {
5874
+ if (typeof options.type === 'string') {
5875
+ dictionary.Type = options.type;
5876
+ }
5877
+
5878
+ if (Array.isArray(options.bbox)) {
5879
+ dictionary.BBox = [options.bbox[0], this.page.height - options.bbox[3], options.bbox[2], this.page.height - options.bbox[1]];
5880
+ }
5881
+
5882
+ if (Array.isArray(options.attached) && options.attached.every(function (val) {
5883
+ return typeof val === 'string';
5884
+ })) {
5885
+ dictionary.Attached = options.attached;
5886
+ }
5887
+ }
5888
+
5889
+ if (tag === 'Span') {
5890
+ if (options.lang) {
5891
+ dictionary.Lang = new String(options.lang);
5892
+ }
5893
+
5894
+ if (options.alt) {
5895
+ dictionary.Alt = new String(options.alt);
5896
+ }
5897
+
5898
+ if (options.expanded) {
5899
+ dictionary.E = new String(options.expanded);
5900
+ }
5901
+
5902
+ if (options.actual) {
5903
+ dictionary.ActualText = new String(options.actual);
5904
+ }
5905
+ }
5906
+
5907
+ this.addContent("/".concat(tag, " ").concat(PDFObject.convert(dictionary), " BDC"));
5908
+ return this;
5909
+ },
5910
+ markStructureContent: function markStructureContent(tag) {
5911
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5912
+ var pageStructParents = this.getStructParentTree().get(this.page.structParentTreeKey);
5913
+ var mcid = pageStructParents.length;
5914
+ pageStructParents.push(null);
5915
+ this.markContent(tag, _objectSpread2(_objectSpread2({}, options), {}, {
5916
+ mcid: mcid
5917
+ }));
5918
+ var structContent = new PDFStructureContent(this.page.dictionary, mcid);
5919
+ this.page.markings.slice(-1)[0].structContent = structContent;
5920
+ return structContent;
5921
+ },
5922
+ endMarkedContent: function endMarkedContent() {
5923
+ this.page.markings.pop();
5924
+ this.addContent('EMC');
5925
+ return this;
5926
+ },
5927
+ struct: function struct(type) {
5928
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5929
+ var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
5930
+ return new PDFStructureElement(this, type, options, children);
5931
+ },
5932
+ addStructure: function addStructure(structElem) {
5933
+ var structTreeRoot = this.getStructTreeRoot();
5934
+ structElem.setParent(structTreeRoot);
5935
+ structElem.setAttached();
5936
+ this.structChildren.push(structElem);
5937
+
5938
+ if (!structTreeRoot.data.K) {
5939
+ structTreeRoot.data.K = [];
5940
+ }
5941
+
5942
+ structTreeRoot.data.K.push(structElem.dictionary);
5943
+ return this;
5944
+ },
5945
+ initPageMarkings: function initPageMarkings(pageMarkings) {
5946
+ var _this = this;
5947
+
5948
+ pageMarkings.forEach(function (marking) {
5949
+ if (marking.structContent) {
5950
+ var structContent = marking.structContent;
5951
+
5952
+ var newStructContent = _this.markStructureContent(marking.tag, marking.options);
5953
+
5954
+ structContent.push(newStructContent);
5955
+ _this.page.markings.slice(-1)[0].structContent = structContent;
5956
+ } else {
5957
+ _this.markContent(marking.tag, marking.options);
5958
+ }
5959
+ });
5960
+ },
5961
+ endPageMarkings: function endPageMarkings(page) {
5962
+ var pageMarkings = page.markings;
5963
+ pageMarkings.forEach(function () {
5964
+ return page.write('EMC');
5965
+ });
5966
+ page.markings = [];
5967
+ return pageMarkings;
5968
+ },
5969
+ getMarkInfoDictionary: function getMarkInfoDictionary() {
5970
+ if (!this._root.data.MarkInfo) {
5971
+ this._root.data.MarkInfo = this.ref({});
5972
+ }
5973
+
5974
+ return this._root.data.MarkInfo;
5975
+ },
5976
+ getStructTreeRoot: function getStructTreeRoot() {
5977
+ if (!this._root.data.StructTreeRoot) {
5978
+ this._root.data.StructTreeRoot = this.ref({
5979
+ Type: 'StructTreeRoot',
5980
+ ParentTree: new PDFNumberTree(),
5981
+ ParentTreeNextKey: 0
5982
+ });
5983
+ }
5984
+
5985
+ return this._root.data.StructTreeRoot;
5986
+ },
5987
+ getStructParentTree: function getStructParentTree() {
5988
+ return this.getStructTreeRoot().data.ParentTree;
5989
+ },
5990
+ createStructParentTreeNextKey: function createStructParentTreeNextKey() {
5991
+ // initialise the MarkInfo dictionary
5992
+ this.getMarkInfoDictionary();
5993
+ var structTreeRoot = this.getStructTreeRoot();
5994
+ var key = structTreeRoot.data.ParentTreeNextKey++;
5995
+ structTreeRoot.data.ParentTree.add(key, []);
5996
+ return key;
5997
+ },
5998
+ endMarkings: function endMarkings() {
5999
+ var structTreeRoot = this._root.data.StructTreeRoot;
6000
+
6001
+ if (structTreeRoot) {
6002
+ structTreeRoot.end();
6003
+ this.structChildren.forEach(function (structElem) {
6004
+ return structElem.end();
6005
+ });
6006
+ }
6007
+
6008
+ if (this._root.data.MarkInfo) {
6009
+ this._root.data.MarkInfo.end();
6010
+ }
6011
+ }
6012
+ };
6013
+
6014
+ var FIELD_FLAGS = {
6015
+ readOnly: 1,
6016
+ required: 2,
6017
+ noExport: 4,
6018
+ multiline: 0x1000,
6019
+ password: 0x2000,
6020
+ toggleToOffButton: 0x4000,
6021
+ radioButton: 0x8000,
6022
+ pushButton: 0x10000,
6023
+ combo: 0x20000,
6024
+ edit: 0x40000,
6025
+ sort: 0x80000,
6026
+ multiSelect: 0x200000,
6027
+ noSpell: 0x400000
6028
+ };
6029
+ var FIELD_JUSTIFY = {
6030
+ left: 0,
6031
+ center: 1,
6032
+ right: 2
6033
+ };
6034
+ var VALUE_MAP = {
6035
+ value: 'V',
6036
+ defaultValue: 'DV'
6037
+ };
6038
+ var FORMAT_SPECIAL = {
6039
+ zip: '0',
5397
6040
  zipPlus4: '1',
5398
6041
  zip4: '1',
5399
6042
  phone: '2',
@@ -5413,9 +6056,9 @@ var FORMAT_DEFAULT = {
5413
6056
  }
5414
6057
  };
5415
6058
  var AcroFormMixin = {
5416
- /**
5417
- * Must call if adding AcroForms to a document. Must also call font() before
5418
- * this method to set the default font.
6059
+ /**
6060
+ * Must call if adding AcroForms to a document. Must also call font() before
6061
+ * this method to set the default font.
5419
6062
  */
5420
6063
  initForm: function initForm() {
5421
6064
  if (!this._font) {
@@ -5441,8 +6084,8 @@ var AcroFormMixin = {
5441
6084
  return this;
5442
6085
  },
5443
6086
 
5444
- /**
5445
- * Called automatically by document.js
6087
+ /**
6088
+ * Called automatically by document.js
5446
6089
  */
5447
6090
  endAcroForm: function endAcroForm() {
5448
6091
  var _this = this;
@@ -5479,12 +6122,12 @@ var AcroFormMixin = {
5479
6122
  return this;
5480
6123
  },
5481
6124
 
5482
- /**
5483
- * Creates and adds a form field to the document. Form fields are intermediate
5484
- * nodes in a PDF form that are used to specify form name heirarchy and form
5485
- * value defaults.
5486
- * @param {string} name - field name (T attribute in field dictionary)
5487
- * @param {object} options - other attributes to include in field dictionary
6125
+ /**
6126
+ * Creates and adds a form field to the document. Form fields are intermediate
6127
+ * nodes in a PDF form that are used to specify form name heirarchy and form
6128
+ * value defaults.
6129
+ * @param {string} name - field name (T attribute in field dictionary)
6130
+ * @param {object} options - other attributes to include in field dictionary
5488
6131
  */
5489
6132
  formField: function formField(name) {
5490
6133
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -5498,16 +6141,16 @@ var AcroFormMixin = {
5498
6141
  return fieldRef;
5499
6142
  },
5500
6143
 
5501
- /**
5502
- * Creates and adds a Form Annotation to the document. Form annotations are
5503
- * called Widget annotations internally within a PDF file.
5504
- * @param {string} name - form field name (T attribute of widget annotation
5505
- * dictionary)
5506
- * @param {number} x
5507
- * @param {number} y
5508
- * @param {number} w
5509
- * @param {number} h
5510
- * @param {object} options
6144
+ /**
6145
+ * Creates and adds a Form Annotation to the document. Form annotations are
6146
+ * called Widget annotations internally within a PDF file.
6147
+ * @param {string} name - form field name (T attribute of widget annotation
6148
+ * dictionary)
6149
+ * @param {number} x
6150
+ * @param {number} y
6151
+ * @param {number} w
6152
+ * @param {number} h
6153
+ * @param {object} options
5511
6154
  */
5512
6155
  formAnnotation: function formAnnotation(name, type, x, y, w, h) {
5513
6156
  var options = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
@@ -5728,9 +6371,11 @@ var AcroFormMixin = {
5728
6371
  if (this._acroform.defaultFont !== this._font.name) {
5729
6372
  options.DR = {
5730
6373
  Font: {}
5731
- };
6374
+ }; // Get the fontSize option. If not set use auto sizing
6375
+
6376
+ var fontSize = options.fontSize || 0;
5732
6377
  options.DR.Font[this._font.id] = this._font.ref();
5733
- options.DA = new String("/".concat(this._font.id, " 0 Tf 0 g"));
6378
+ options.DA = new String("/".concat(this._font.id, " ").concat(fontSize, " Tf 0 g"));
5734
6379
  }
5735
6380
 
5736
6381
  return options;
@@ -5761,8 +6406,6 @@ var AcroFormMixin = {
5761
6406
  options.Opt = select;
5762
6407
  }
5763
6408
 
5764
- if (options.value || options.defaultValue) ;
5765
-
5766
6409
  Object.keys(VALUE_MAP).forEach(function (key) {
5767
6410
  if (options[key] !== undefined) {
5768
6411
  options[VALUE_MAP[key]] = options[key];
@@ -5789,11 +6432,131 @@ var AcroFormMixin = {
5789
6432
  }
5790
6433
  };
5791
6434
 
5792
- var PDFDocument =
5793
- /*#__PURE__*/
5794
- function (_stream$Readable) {
6435
+ var AttachmentsMixin = {
6436
+ /**
6437
+ * Embed contents of `src` in PDF
6438
+ * @param {Buffer | ArrayBuffer | string} src input Buffer, ArrayBuffer, base64 encoded string or path to file
6439
+ * @param {object} options
6440
+ * * options.name: filename to be shown in PDF, will use `src` if none set
6441
+ * * options.type: filetype to be shown in PDF
6442
+ * * options.description: description to be shown in PDF
6443
+ * * options.hidden: if true, do not add attachment to EmbeddedFiles dictionary. Useful for file attachment annotations
6444
+ * * options.creationDate: override creation date
6445
+ * * options.modifiedDate: override modified date
6446
+ * @returns filespec reference
6447
+ */
6448
+ file: function file(src) {
6449
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6450
+ options.name = options.name || src;
6451
+ var refBody = {
6452
+ Type: 'EmbeddedFile',
6453
+ Params: {}
6454
+ };
6455
+ var data;
6456
+
6457
+ if (!src) {
6458
+ throw new Error('No src specified');
6459
+ }
6460
+
6461
+ if (Buffer.isBuffer(src)) {
6462
+ data = src;
6463
+ } else if (src instanceof ArrayBuffer) {
6464
+ data = Buffer.from(new Uint8Array(src));
6465
+ } else {
6466
+ var match;
6467
+
6468
+ if (match = /^data:(.*);base64,(.*)$/.exec(src)) {
6469
+ if (match[1]) {
6470
+ refBody.Subtype = match[1].replace('/', '#2F');
6471
+ }
6472
+
6473
+ data = Buffer.from(match[2], 'base64');
6474
+ } else {
6475
+ data = fs.readFileSync(src);
6476
+
6477
+ if (!data) {
6478
+ throw new Error("Could not read contents of file at filepath ".concat(src));
6479
+ } // update CreationDate and ModDate
6480
+
6481
+
6482
+ var _fs$statSync = fs.statSync(src),
6483
+ birthtime = _fs$statSync.birthtime,
6484
+ ctime = _fs$statSync.ctime;
6485
+
6486
+ refBody.Params.CreationDate = birthtime;
6487
+ refBody.Params.ModDate = ctime;
6488
+ }
6489
+ } // override creation date and modified date
6490
+
6491
+
6492
+ if (options.creationDate instanceof Date) {
6493
+ refBody.Params.CreationDate = options.creationDate;
6494
+ }
6495
+
6496
+ if (options.modifiedDate instanceof Date) {
6497
+ refBody.Params.ModDate = options.modifiedDate;
6498
+ } // add optional subtype
6499
+
6500
+
6501
+ if (options.type) {
6502
+ refBody.Subtype = options.type.replace('/', '#2F');
6503
+ } // add checksum and size information
6504
+
6505
+
6506
+ var checksum = CryptoJS.MD5(CryptoJS.lib.WordArray.create(new Uint8Array(data)));
6507
+ refBody.Params.CheckSum = new String(checksum);
6508
+ refBody.Params.Size = data.byteLength; // save some space when embedding the same file again
6509
+ // if a file with the same name and metadata exists, reuse its reference
6510
+
6511
+ var ref;
6512
+ if (!this._fileRegistry) this._fileRegistry = {};
6513
+ var file = this._fileRegistry[options.name];
6514
+
6515
+ if (file && isEqual(refBody, file)) {
6516
+ ref = file.ref;
6517
+ } else {
6518
+ ref = this.ref(refBody);
6519
+ ref.end(data);
6520
+ this._fileRegistry[options.name] = _objectSpread2(_objectSpread2({}, refBody), {}, {
6521
+ ref: ref
6522
+ });
6523
+ } // add filespec for embedded file
6524
+
6525
+
6526
+ var fileSpecBody = {
6527
+ Type: 'Filespec',
6528
+ F: new String(options.name),
6529
+ EF: {
6530
+ F: ref
6531
+ },
6532
+ UF: new String(options.name)
6533
+ };
6534
+
6535
+ if (options.description) {
6536
+ fileSpecBody.Desc = new String(options.description);
6537
+ }
6538
+
6539
+ var filespec = this.ref(fileSpecBody);
6540
+ filespec.end();
6541
+
6542
+ if (!options.hidden) {
6543
+ this.addNamedEmbeddedFile(options.name, filespec);
6544
+ }
6545
+
6546
+ return filespec;
6547
+ }
6548
+ };
6549
+ /** check two embedded file metadata objects for equality */
6550
+
6551
+ function isEqual(a, b) {
6552
+ return a.Subtype === b.Subtype && a.Params.CheckSum.toString() === b.Params.CheckSum.toString() && a.Params.Size === b.Params.Size && a.Params.CreationDate === b.Params.CreationDate && a.Params.ModDate === b.Params.ModDate;
6553
+ }
6554
+
6555
+ var PDFDocument = /*#__PURE__*/function (_stream$Readable) {
5795
6556
  _inherits(PDFDocument, _stream$Readable);
5796
6557
 
6558
+ var _super = _createSuper(PDFDocument);
6559
+
5797
6560
  function PDFDocument() {
5798
6561
  var _this;
5799
6562
 
@@ -5801,7 +6564,7 @@ function (_stream$Readable) {
5801
6564
 
5802
6565
  _classCallCheck(this, PDFDocument);
5803
6566
 
5804
- _this = _possibleConstructorReturn(this, _getPrototypeOf(PDFDocument).call(this, options));
6567
+ _this = _super.call(this, options);
5805
6568
  _this.options = options; // PDF version
5806
6569
 
5807
6570
  switch (options.pdfVersion) {
@@ -5851,7 +6614,12 @@ function (_stream$Readable) {
5851
6614
  Type: 'Catalog',
5852
6615
  Pages: Pages,
5853
6616
  Names: Names
5854
- }); // The current page
6617
+ });
6618
+
6619
+ if (_this.options.lang) {
6620
+ _this._root.data.Lang = new String(_this.options.lang);
6621
+ } // The current page
6622
+
5855
6623
 
5856
6624
  _this.page = null; // Initialize mixins
5857
6625
 
@@ -5865,7 +6633,9 @@ function (_stream$Readable) {
5865
6633
 
5866
6634
  _this.initImages();
5867
6635
 
5868
- _this.initOutline(); // Initialize the metadata
6636
+ _this.initOutline();
6637
+
6638
+ _this.initMarkings(options); // Initialize the metadata
5869
6639
 
5870
6640
 
5871
6641
  _this.info = {
@@ -5879,6 +6649,12 @@ function (_stream$Readable) {
5879
6649
  var val = _this.options.info[key];
5880
6650
  _this.info[key] = val;
5881
6651
  }
6652
+ }
6653
+
6654
+ if (_this.options.displayTitle) {
6655
+ _this._root.data.ViewerPreferences = _this.ref({
6656
+ DisplayDocTitle: true
6657
+ });
5882
6658
  } // Generate file ID
5883
6659
 
5884
6660
 
@@ -5903,10 +6679,10 @@ function (_stream$Readable) {
5903
6679
  _createClass(PDFDocument, [{
5904
6680
  key: "addPage",
5905
6681
  value: function addPage(options) {
5906
- // end the current page if needed
5907
6682
  if (options == null) {
5908
6683
  options = this.options;
5909
- }
6684
+ } // end the current page if needed
6685
+
5910
6686
 
5911
6687
  if (!this.options.bufferPages) {
5912
6688
  this.flushPages();
@@ -5931,6 +6707,14 @@ function (_stream$Readable) {
5931
6707
  this.emit('pageAdded');
5932
6708
  return this;
5933
6709
  }
6710
+ }, {
6711
+ key: "continueOnNewPage",
6712
+ value: function continueOnNewPage(options) {
6713
+ var pageMarkings = this.endPageMarkings(this.page);
6714
+ this.addPage(options);
6715
+ this.initPageMarkings(pageMarkings);
6716
+ return this;
6717
+ }
5934
6718
  }, {
5935
6719
  key: "bufferedPageRange",
5936
6720
  value: function bufferedPageRange() {
@@ -5958,28 +6742,20 @@ function (_stream$Readable) {
5958
6742
  var pages = this._pageBuffer;
5959
6743
  this._pageBuffer = [];
5960
6744
  this._pageBufferStart += pages.length;
5961
- var _iteratorNormalCompletion = true;
5962
- var _didIteratorError = false;
5963
- var _iteratorError = undefined;
6745
+
6746
+ var _iterator = _createForOfIteratorHelper(pages),
6747
+ _step;
5964
6748
 
5965
6749
  try {
5966
- for (var _iterator = pages[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
6750
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
5967
6751
  var page = _step.value;
6752
+ this.endPageMarkings(page);
5968
6753
  page.end();
5969
6754
  }
5970
6755
  } catch (err) {
5971
- _didIteratorError = true;
5972
- _iteratorError = err;
6756
+ _iterator.e(err);
5973
6757
  } finally {
5974
- try {
5975
- if (!_iteratorNormalCompletion && _iterator.return != null) {
5976
- _iterator.return();
5977
- }
5978
- } finally {
5979
- if (_didIteratorError) {
5980
- throw _iteratorError;
5981
- }
5982
- }
6758
+ _iterator.f();
5983
6759
  }
5984
6760
  }
5985
6761
  }, {
@@ -6001,6 +6777,19 @@ function (_stream$Readable) {
6001
6777
 
6002
6778
  this._root.data.Names.data.Dests.add(name, args);
6003
6779
  }
6780
+ }, {
6781
+ key: "addNamedEmbeddedFile",
6782
+ value: function addNamedEmbeddedFile(name, ref) {
6783
+ if (!this._root.data.Names.data.EmbeddedFiles) {
6784
+ // disabling /Limits for this tree fixes attachments not showing in Adobe Reader
6785
+ this._root.data.Names.data.EmbeddedFiles = new PDFNameTree({
6786
+ limits: false
6787
+ });
6788
+ } // add filespec to EmbeddedFiles
6789
+
6790
+
6791
+ this._root.data.Names.data.EmbeddedFiles.add(name, ref);
6792
+ }
6004
6793
  }, {
6005
6794
  key: "addNamedJavaScript",
6006
6795
  value: function addNamedJavaScript(name, js) {
@@ -6034,7 +6823,7 @@ function (_stream$Readable) {
6034
6823
  key: "_write",
6035
6824
  value: function _write(data) {
6036
6825
  if (!Buffer.isBuffer(data)) {
6037
- data = new Buffer(data + '\n', 'binary');
6826
+ data = Buffer.from(data + '\n', 'binary');
6038
6827
  }
6039
6828
 
6040
6829
  this.push(data);
@@ -6093,6 +6882,7 @@ function (_stream$Readable) {
6093
6882
  }
6094
6883
 
6095
6884
  this.endOutline();
6885
+ this.endMarkings();
6096
6886
 
6097
6887
  this._root.end();
6098
6888
 
@@ -6102,6 +6892,10 @@ function (_stream$Readable) {
6102
6892
 
6103
6893
  this.endAcroForm();
6104
6894
 
6895
+ if (this._root.data.ViewerPreferences) {
6896
+ this._root.data.ViewerPreferences.end();
6897
+ }
6898
+
6105
6899
  if (this._security) {
6106
6900
  this._security.end();
6107
6901
  }
@@ -6114,7 +6908,7 @@ function (_stream$Readable) {
6114
6908
  }
6115
6909
  }, {
6116
6910
  key: "_finalize",
6117
- value: function _finalize(fn) {
6911
+ value: function _finalize() {
6118
6912
  // generate xref
6119
6913
  var xRefOffset = this._offset;
6120
6914
 
@@ -6124,12 +6918,11 @@ function (_stream$Readable) {
6124
6918
 
6125
6919
  this._write('0000000000 65535 f ');
6126
6920
 
6127
- var _iteratorNormalCompletion2 = true;
6128
- var _didIteratorError2 = false;
6129
- var _iteratorError2 = undefined;
6921
+ var _iterator2 = _createForOfIteratorHelper(this._offsets),
6922
+ _step2;
6130
6923
 
6131
6924
  try {
6132
- for (var _iterator2 = this._offsets[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
6925
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
6133
6926
  var offset = _step2.value;
6134
6927
  offset = "0000000000".concat(offset).slice(-10);
6135
6928
 
@@ -6137,18 +6930,9 @@ function (_stream$Readable) {
6137
6930
  } // trailer
6138
6931
 
6139
6932
  } catch (err) {
6140
- _didIteratorError2 = true;
6141
- _iteratorError2 = err;
6933
+ _iterator2.e(err);
6142
6934
  } finally {
6143
- try {
6144
- if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
6145
- _iterator2.return();
6146
- }
6147
- } finally {
6148
- if (_didIteratorError2) {
6149
- throw _iteratorError2;
6150
- }
6151
- }
6935
+ _iterator2.f();
6152
6936
  }
6153
6937
 
6154
6938
  var trailer = {
@@ -6196,7 +6980,10 @@ mixin(TextMixin);
6196
6980
  mixin(ImagesMixin);
6197
6981
  mixin(AnnotationsMixin);
6198
6982
  mixin(OutlineMixin);
6983
+ mixin(MarkingsMixin);
6199
6984
  mixin(AcroFormMixin);
6985
+ mixin(AttachmentsMixin);
6986
+ PDFDocument.LineWrapper = LineWrapper;
6200
6987
 
6201
6988
  export default PDFDocument;
6202
6989
  //# sourceMappingURL=pdfkit.es5.js.map