pdfkit 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,8 +7,8 @@ import { EventEmitter } from 'events';
7
7
  import LineBreaker from 'linebreak';
8
8
  import PNG from 'png-js';
9
9
 
10
- /*
11
- PDFAbstractReference - abstract class for PDF reference
10
+ /*
11
+ PDFAbstractReference - abstract class for PDF reference
12
12
  */
13
13
  class PDFAbstractReference {
14
14
  toString() {
@@ -17,8 +17,8 @@ class PDFAbstractReference {
17
17
 
18
18
  }
19
19
 
20
- /*
21
- PDFTree - abstract base class for name and number tree objects
20
+ /*
21
+ PDFTree - abstract base class for name and number tree objects
22
22
  */
23
23
 
24
24
  class PDFTree {
@@ -59,9 +59,7 @@ class PDFTree {
59
59
  return out.join('\n');
60
60
  }
61
61
 
62
- _compareKeys()
63
- /*a, b*/
64
- {
62
+ _compareKeys() {
65
63
  throw new Error('Must be implemented by subclasses');
66
64
  }
67
65
 
@@ -69,17 +67,15 @@ class PDFTree {
69
67
  throw new Error('Must be implemented by subclasses');
70
68
  }
71
69
 
72
- _dataForKey()
73
- /*k*/
74
- {
70
+ _dataForKey() {
75
71
  throw new Error('Must be implemented by subclasses');
76
72
  }
77
73
 
78
74
  }
79
75
 
80
- /*
81
- PDFObject - converts JavaScript types into their corresponding PDF types.
82
- By Devon Govett
76
+ /*
77
+ PDFObject - converts JavaScript types into their corresponding PDF types.
78
+ By Devon Govett
83
79
  */
84
80
 
85
81
  var pad = (str, length) => (Array(length + 1).join('0') + str).slice(-length);
@@ -195,9 +191,9 @@ class PDFObject {
195
191
 
196
192
  }
197
193
 
198
- /*
199
- PDFReference - represents a reference to another object in the PDF object heirarchy
200
- By Devon Govett
194
+ /*
195
+ PDFReference - represents a reference to another object in the PDF object heirarchy
196
+ By Devon Govett
201
197
  */
202
198
 
203
199
  class PDFReference extends PDFAbstractReference {
@@ -283,9 +279,9 @@ class PDFReference extends PDFAbstractReference {
283
279
 
284
280
  }
285
281
 
286
- /*
287
- PDFPage - represents a single page in the PDF document
288
- By Devon Govett
282
+ /*
283
+ PDFPage - represents a single page in the PDF document
284
+ By Devon Govett
289
285
  */
290
286
  var DEFAULT_MARGINS = {
291
287
  top: 72,
@@ -405,6 +401,11 @@ class PDFPage {
405
401
  return data.Pattern != null ? data.Pattern : data.Pattern = {};
406
402
  }
407
403
 
404
+ get colorSpaces() {
405
+ var data = this.resources.data;
406
+ return data.ColorSpace || (data.ColorSpace = {});
407
+ }
408
+
408
409
  get annotations() {
409
410
  var data = this.dictionary.data;
410
411
  return data.Annots != null ? data.Annots : data.Annots = [];
@@ -431,8 +432,8 @@ class PDFPage {
431
432
 
432
433
  }
433
434
 
434
- /*
435
- PDFNameTree - represents a name tree object
435
+ /*
436
+ PDFNameTree - represents a name tree object
436
437
  */
437
438
 
438
439
  class PDFNameTree extends PDFTree {
@@ -450,11 +451,11 @@ class PDFNameTree extends PDFTree {
450
451
 
451
452
  }
452
453
 
453
- /**
454
- * Check if value is in a range group.
455
- * @param {number} value
456
- * @param {number[]} rangeGroup
457
- * @returns {boolean}
454
+ /**
455
+ * Check if value is in a range group.
456
+ * @param {number} value
457
+ * @param {number[]} rangeGroup
458
+ * @returns {boolean}
458
459
  */
459
460
  function inRange(value, rangeGroup) {
460
461
  if (value < rangeGroup[0]) return false;
@@ -482,18 +483,18 @@ function inRange(value, rangeGroup) {
482
483
  return false;
483
484
  }
484
485
 
485
- /**
486
- * A.1 Unassigned code points in Unicode 3.2
487
- * @link https://tools.ietf.org/html/rfc3454#appendix-A.1
486
+ /**
487
+ * A.1 Unassigned code points in Unicode 3.2
488
+ * @link https://tools.ietf.org/html/rfc3454#appendix-A.1
488
489
  */
489
490
 
490
491
  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
491
492
 
492
493
  var isUnassignedCodePoint = character => inRange(character, unassigned_code_points); // prettier-ignore-start
493
494
 
494
- /**
495
- * B.1 Commonly mapped to nothing
496
- * @link https://tools.ietf.org/html/rfc3454#appendix-B.1
495
+ /**
496
+ * B.1 Commonly mapped to nothing
497
+ * @link https://tools.ietf.org/html/rfc3454#appendix-B.1
497
498
  */
498
499
 
499
500
 
@@ -501,9 +502,9 @@ var commonly_mapped_to_nothing = [0x00ad, 0x00ad, 0x034f, 0x034f, 0x1806, 0x1806
501
502
 
502
503
  var isCommonlyMappedToNothing = character => inRange(character, commonly_mapped_to_nothing); // prettier-ignore-start
503
504
 
504
- /**
505
- * C.1.2 Non-ASCII space characters
506
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.1.2
505
+ /**
506
+ * C.1.2 Non-ASCII space characters
507
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.1.2
507
508
  */
508
509
 
509
510
 
@@ -547,9 +548,9 @@ var isNonASCIISpaceCharacter = character => inRange(character, non_ASCII_space_c
547
548
 
548
549
 
549
550
  var non_ASCII_controls_characters = [
550
- /**
551
- * C.2.2 Non-ASCII control characters
552
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.2
551
+ /**
552
+ * C.2.2 Non-ASCII control characters
553
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.2
553
554
  */
554
555
  0x0080, 0x009f
555
556
  /* [CONTROL CHARACTERS] */
@@ -585,9 +586,9 @@ var non_ASCII_controls_characters = [
585
586
  /* [MUSICAL CONTROL CHARACTERS] */
586
587
  ];
587
588
  var non_character_codepoints = [
588
- /**
589
- * C.4 Non-character code points
590
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.4
589
+ /**
590
+ * C.4 Non-character code points
591
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.4
591
592
  */
592
593
  0xfdd0, 0xfdef
593
594
  /* [NONCHARACTER CODE POINTS] */
@@ -624,23 +625,23 @@ var non_character_codepoints = [
624
625
  , 0x10fffe, 0x10ffff
625
626
  /* [NONCHARACTER CODE POINTS] */
626
627
  ];
627
- /**
628
- * 2.3. Prohibited Output
628
+ /**
629
+ * 2.3. Prohibited Output
629
630
  */
630
631
 
631
632
  var prohibited_characters = [
632
- /**
633
- * C.2.1 ASCII control characters
634
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.1
633
+ /**
634
+ * C.2.1 ASCII control characters
635
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.2.1
635
636
  */
636
637
  0, 0x001f
637
638
  /* [CONTROL CHARACTERS] */
638
639
  , 0x007f, 0x007f
639
640
  /* DELETE */
640
641
  ,
641
- /**
642
- * C.8 Change display properties or are deprecated
643
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.8
642
+ /**
643
+ * C.8 Change display properties or are deprecated
644
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.8
644
645
  */
645
646
  0x0340, 0x0340
646
647
  /* COMBINING GRAVE TONE MARK */
@@ -673,28 +674,28 @@ var prohibited_characters = [
673
674
  , 0x206f, 0x206f
674
675
  /* NOMINAL DIGIT SHAPES */
675
676
  ,
676
- /**
677
- * C.7 Inappropriate for canonical representation
678
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.7
677
+ /**
678
+ * C.7 Inappropriate for canonical representation
679
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.7
679
680
  */
680
681
  0x2ff0, 0x2ffb
681
682
  /* [IDEOGRAPHIC DESCRIPTION CHARACTERS] */
682
683
  ,
683
- /**
684
- * C.5 Surrogate codes
685
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.5
684
+ /**
685
+ * C.5 Surrogate codes
686
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.5
686
687
  */
687
688
  0xd800, 0xdfff,
688
- /**
689
- * C.3 Private use
690
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.3
689
+ /**
690
+ * C.3 Private use
691
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.3
691
692
  */
692
693
  0xe000, 0xf8ff
693
694
  /* [PRIVATE USE, PLANE 0] */
694
695
  ,
695
- /**
696
- * C.6 Inappropriate for plain text
697
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.6
696
+ /**
697
+ * C.6 Inappropriate for plain text
698
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.6
698
699
  */
699
700
  0xfff9, 0xfff9
700
701
  /* INTERLINEAR ANNOTATION ANCHOR */
@@ -707,18 +708,18 @@ var prohibited_characters = [
707
708
  , 0xfffd, 0xfffd
708
709
  /* REPLACEMENT CHARACTER */
709
710
  ,
710
- /**
711
- * C.9 Tagging characters
712
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.9
711
+ /**
712
+ * C.9 Tagging characters
713
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.9
713
714
  */
714
715
  0xe0001, 0xe0001
715
716
  /* LANGUAGE TAG */
716
717
  , 0xe0020, 0xe007f
717
718
  /* [TAGGING CHARACTERS] */
718
719
  ,
719
- /**
720
- * C.3 Private use
721
- * @link https://tools.ietf.org/html/rfc3454#appendix-C.3
720
+ /**
721
+ * C.3 Private use
722
+ * @link https://tools.ietf.org/html/rfc3454#appendix-C.3
722
723
  */
723
724
  0xf0000, 0xffffd
724
725
  /* [PRIVATE USE, PLANE 15] */
@@ -728,9 +729,9 @@ var prohibited_characters = [
728
729
 
729
730
  var isProhibitedCharacter = character => inRange(character, non_ASCII_space_characters) || inRange(character, prohibited_characters) || inRange(character, non_ASCII_controls_characters) || inRange(character, non_character_codepoints); // prettier-ignore-start
730
731
 
731
- /**
732
- * D.1 Characters with bidirectional property "R" or "AL"
733
- * @link https://tools.ietf.org/html/rfc3454#appendix-D.1
732
+ /**
733
+ * D.1 Characters with bidirectional property "R" or "AL"
734
+ * @link https://tools.ietf.org/html/rfc3454#appendix-D.1
734
735
  */
735
736
 
736
737
 
@@ -738,9 +739,9 @@ var bidirectional_r_al = [0x05be, 0x05be, 0x05c0, 0x05c0, 0x05c3, 0x05c3, 0x05d0
738
739
 
739
740
  var isBidirectionalRAL = character => inRange(character, bidirectional_r_al); // prettier-ignore-start
740
741
 
741
- /**
742
- * D.2 Characters with bidirectional property "L"
743
- * @link https://tools.ietf.org/html/rfc3454#appendix-D.2
742
+ /**
743
+ * D.2 Characters with bidirectional property "L"
744
+ * @link https://tools.ietf.org/html/rfc3454#appendix-D.2
744
745
  */
745
746
 
746
747
 
@@ -748,15 +749,15 @@ var bidirectional_l = [0x0041, 0x005a, 0x0061, 0x007a, 0x00aa, 0x00aa, 0x00b5, 0
748
749
 
749
750
  var isBidirectionalL = character => inRange(character, bidirectional_l);
750
751
 
751
- /**
752
- * non-ASCII space characters [StringPrep, C.1.2] that can be
753
- * mapped to SPACE (U+0020)
752
+ /**
753
+ * non-ASCII space characters [StringPrep, C.1.2] that can be
754
+ * mapped to SPACE (U+0020)
754
755
  */
755
756
 
756
757
  var mapping2space = isNonASCIISpaceCharacter;
757
- /**
758
- * the "commonly mapped to nothing" characters [StringPrep, B.1]
759
- * that can be mapped to nothing.
758
+ /**
759
+ * the "commonly mapped to nothing" characters [StringPrep, B.1]
760
+ * that can be mapped to nothing.
760
761
  */
761
762
 
762
763
  var mapping2nothing = isCommonlyMappedToNothing; // utils
@@ -766,12 +767,12 @@ var getCodePoint = character => character.codePointAt(0);
766
767
  var first = x => x[0];
767
768
 
768
769
  var last = x => x[x.length - 1];
769
- /**
770
- * Convert provided string into an array of Unicode Code Points.
771
- * Based on https://stackoverflow.com/a/21409165/1556249
772
- * and https://www.npmjs.com/package/code-point-at.
773
- * @param {string} input
774
- * @returns {number[]}
770
+ /**
771
+ * Convert provided string into an array of Unicode Code Points.
772
+ * Based on https://stackoverflow.com/a/21409165/1556249
773
+ * and https://www.npmjs.com/package/code-point-at.
774
+ * @param {string} input
775
+ * @returns {number[]}
775
776
  */
776
777
 
777
778
 
@@ -797,12 +798,12 @@ function toCodePoints(input) {
797
798
 
798
799
  return codepoints;
799
800
  }
800
- /**
801
- * SASLprep.
802
- * @param {string} input
803
- * @param {Object} opts
804
- * @param {boolean} opts.allowUnassigned
805
- * @returns {string}
801
+ /**
802
+ * SASLprep.
803
+ * @param {string} input
804
+ * @param {Object} opts
805
+ * @param {boolean} opts.allowUnassigned
806
+ * @returns {string}
806
807
  */
807
808
 
808
809
 
@@ -848,10 +849,10 @@ function saslprep(input) {
848
849
  if (hasBidiRAL && hasBidiL) {
849
850
  throw new Error('String must not contain RandALCat and LCat at the same time,' + ' see https://tools.ietf.org/html/rfc3454#section-6');
850
851
  }
851
- /**
852
- * 4.2 If a string contains any RandALCat character, a RandALCat
853
- * character MUST be the first character of the string, and a
854
- * RandALCat character MUST be the last character of the string.
852
+ /**
853
+ * 4.2 If a string contains any RandALCat character, a RandALCat
854
+ * character MUST be the first character of the string, and a
855
+ * RandALCat character MUST be the last character of the string.
855
856
  */
856
857
 
857
858
 
@@ -865,9 +866,9 @@ function saslprep(input) {
865
866
  return normalized_input;
866
867
  }
867
868
 
868
- /*
869
- PDFSecurity - represents PDF security settings
870
- By Yang Liu <hi@zesik.com>
869
+ /*
870
+ PDFSecurity - represents PDF security settings
871
+ By Yang Liu <hi@zesik.com>
871
872
  */
872
873
 
873
874
  class PDFSecurity {
@@ -1478,7 +1479,7 @@ class PDFGradient {
1478
1479
  return pattern;
1479
1480
  }
1480
1481
 
1481
- apply(op) {
1482
+ apply(stroke) {
1482
1483
  // apply gradient transform to existing document ctm
1483
1484
  var [m0, m1, m2, m3, m4, m5] = this.doc._ctm;
1484
1485
  var [m11, m12, m21, m22, dx, dy] = this.transform;
@@ -1488,6 +1489,9 @@ class PDFGradient {
1488
1489
  this.embed(m);
1489
1490
  }
1490
1491
 
1492
+ this.doc._setColorSpace('Pattern', stroke);
1493
+
1494
+ var op = stroke ? 'SCN' : 'scn';
1491
1495
  return this.doc.addContent("/".concat(this.id, " ").concat(op));
1492
1496
  }
1493
1497
 
@@ -1552,24 +1556,119 @@ var Gradient = {
1552
1556
  PDFRadialGradient
1553
1557
  };
1554
1558
 
1559
+ /*
1560
+ PDF tiling pattern support. Uncolored only.
1561
+ */
1562
+ var underlyingColorSpaces = ['DeviceCMYK', 'DeviceRGB'];
1563
+
1564
+ class PDFTilingPattern {
1565
+ constructor(doc, bBox, xStep, yStep, stream) {
1566
+ this.doc = doc;
1567
+ this.bBox = bBox;
1568
+ this.xStep = xStep;
1569
+ this.yStep = yStep;
1570
+ this.stream = stream;
1571
+ }
1572
+
1573
+ createPattern() {
1574
+ // no resources needed for our current usage
1575
+ // required entry
1576
+ var resources = this.doc.ref();
1577
+ resources.end(); // apply default transform matrix (flipped in the default doc._ctm)
1578
+ // see document.js & gradient.js
1579
+
1580
+ var [m0, m1, m2, m3, m4, m5] = this.doc._ctm;
1581
+ var [m11, m12, m21, m22, dx, dy] = [1, 0, 0, 1, 0, 0];
1582
+ var m = [m0 * m11 + m2 * m12, m1 * m11 + m3 * m12, m0 * m21 + m2 * m22, m1 * m21 + m3 * m22, m0 * dx + m2 * dy + m4, m1 * dx + m3 * dy + m5];
1583
+ var pattern = this.doc.ref({
1584
+ Type: 'Pattern',
1585
+ PatternType: 1,
1586
+ // tiling
1587
+ PaintType: 2,
1588
+ // 1-colored, 2-uncolored
1589
+ TilingType: 2,
1590
+ // 2-no distortion
1591
+ BBox: this.bBox,
1592
+ XStep: this.xStep,
1593
+ YStep: this.yStep,
1594
+ Matrix: m.map(v => +v.toFixed(5)),
1595
+ Resources: resources
1596
+ });
1597
+ pattern.end(this.stream);
1598
+ return pattern;
1599
+ }
1600
+
1601
+ embedPatternColorSpaces() {
1602
+ // map each pattern to an underlying color space
1603
+ // and embed on each page
1604
+ underlyingColorSpaces.forEach(csName => {
1605
+ var csId = this.getPatternColorSpaceId(csName);
1606
+ if (this.doc.page.colorSpaces[csId]) return;
1607
+ var cs = this.doc.ref(['Pattern', csName]);
1608
+ cs.end();
1609
+ this.doc.page.colorSpaces[csId] = cs;
1610
+ });
1611
+ }
1612
+
1613
+ getPatternColorSpaceId(underlyingColorspace) {
1614
+ return "CsP".concat(underlyingColorspace);
1615
+ }
1616
+
1617
+ embed() {
1618
+ if (!this.id) {
1619
+ this.doc._patternCount = this.doc._patternCount + 1;
1620
+ this.id = 'P' + this.doc._patternCount;
1621
+ this.pattern = this.createPattern();
1622
+ } // patterns are embedded in each page
1623
+
1624
+
1625
+ if (!this.doc.page.patterns[this.id]) {
1626
+ this.doc.page.patterns[this.id] = this.pattern;
1627
+ }
1628
+ }
1629
+
1630
+ apply(stroke, patternColor) {
1631
+ // do any embedding/creating that might be needed
1632
+ this.embedPatternColorSpaces();
1633
+ this.embed();
1634
+
1635
+ var normalizedColor = this.doc._normalizeColor(patternColor);
1636
+
1637
+ if (!normalizedColor) throw Error("invalid pattern color. (value: ".concat(patternColor, ")")); // select one of the pattern color spaces
1638
+
1639
+ var csId = this.getPatternColorSpaceId(this.doc._getColorSpace(normalizedColor));
1640
+
1641
+ this.doc._setColorSpace(csId, stroke); // stroke/fill using the pattern and color (in the above underlying color space)
1642
+
1643
+
1644
+ var op = stroke ? 'SCN' : 'scn';
1645
+ return this.doc.addContent("".concat(normalizedColor.join(' '), " /").concat(this.id, " ").concat(op));
1646
+ }
1647
+
1648
+ }
1649
+
1650
+ var pattern = {
1651
+ PDFTilingPattern
1652
+ };
1653
+
1555
1654
  var {
1556
1655
  PDFGradient: PDFGradient$1,
1557
1656
  PDFLinearGradient: PDFLinearGradient$1,
1558
1657
  PDFRadialGradient: PDFRadialGradient$1
1559
1658
  } = Gradient;
1659
+ var {
1660
+ PDFTilingPattern: PDFTilingPattern$1
1661
+ } = pattern;
1560
1662
  var ColorMixin = {
1561
1663
  initColor() {
1562
1664
  // The opacity dictionaries
1563
1665
  this._opacityRegistry = {};
1564
1666
  this._opacityCount = 0;
1667
+ this._patternCount = 0;
1565
1668
  return this._gradCount = 0;
1566
1669
  },
1567
1670
 
1568
1671
  _normalizeColor(color) {
1569
- if (color instanceof PDFGradient$1) {
1570
- return color;
1571
- }
1572
-
1573
1672
  if (typeof color === 'string') {
1574
1673
  if (color.charAt(0) === '#') {
1575
1674
  if (color.length === 4) {
@@ -1598,6 +1697,19 @@ var ColorMixin = {
1598
1697
  },
1599
1698
 
1600
1699
  _setColor(color, stroke) {
1700
+ if (color instanceof PDFGradient$1) {
1701
+ color.apply(stroke);
1702
+ return true; // see if tiling pattern, decode & apply it it
1703
+ } else if (Array.isArray(color) && color[0] instanceof PDFTilingPattern$1) {
1704
+ color[0].apply(stroke, color[1]);
1705
+ return true;
1706
+ } // any other case should be a normal color and not a pattern
1707
+
1708
+
1709
+ return this._setColorCore(color, stroke);
1710
+ },
1711
+
1712
+ _setColorCore(color, stroke) {
1601
1713
  color = this._normalizeColor(color);
1602
1714
 
1603
1715
  if (!color) {
@@ -1606,19 +1718,12 @@ var ColorMixin = {
1606
1718
 
1607
1719
  var op = stroke ? 'SCN' : 'scn';
1608
1720
 
1609
- if (color instanceof PDFGradient$1) {
1610
- this._setColorSpace('Pattern', stroke);
1721
+ var space = this._getColorSpace(color);
1611
1722
 
1612
- color.apply(op);
1613
- } else {
1614
- var space = color.length === 4 ? 'DeviceCMYK' : 'DeviceRGB';
1615
-
1616
- this._setColorSpace(space, stroke);
1617
-
1618
- color = color.join(' ');
1619
- this.addContent("".concat(color, " ").concat(op));
1620
- }
1723
+ this._setColorSpace(space, stroke);
1621
1724
 
1725
+ color = color.join(' ');
1726
+ this.addContent("".concat(color, " ").concat(op));
1622
1727
  return true;
1623
1728
  },
1624
1729
 
@@ -1627,6 +1732,10 @@ var ColorMixin = {
1627
1732
  return this.addContent("/".concat(space, " ").concat(op));
1628
1733
  },
1629
1734
 
1735
+ _getColorSpace(color) {
1736
+ return color.length === 4 ? 'DeviceCMYK' : 'DeviceRGB';
1737
+ },
1738
+
1630
1739
  fillColor(color, opacity) {
1631
1740
  var set = this._setColor(color, false);
1632
1741
 
@@ -1717,6 +1826,10 @@ var ColorMixin = {
1717
1826
 
1718
1827
  radialGradient(x1, y1, r1, x2, y2, r2) {
1719
1828
  return new PDFRadialGradient$1(this, x1, y1, r1, x2, y2, r2);
1829
+ },
1830
+
1831
+ pattern(bbox, xStep, yStep, stream) {
1832
+ return new PDFTilingPattern$1(this, bbox, xStep, yStep, stream);
1720
1833
  }
1721
1834
 
1722
1835
  };
@@ -4020,10 +4133,10 @@ var TextMixin = {
4020
4133
 
4021
4134
  if (options.destination != null) {
4022
4135
  this.addNamedDestination(options.destination, 'XYZ', x, y, null);
4023
- } // create underline or strikethrough line
4136
+ } // create underline
4024
4137
 
4025
4138
 
4026
- if (options.underline || options.strike) {
4139
+ if (options.underline) {
4027
4140
  this.save();
4028
4141
 
4029
4142
  if (!options.stroke) {
@@ -4032,15 +4145,29 @@ var TextMixin = {
4032
4145
 
4033
4146
  var lineWidth = this._fontSize < 10 ? 0.5 : Math.floor(this._fontSize / 10);
4034
4147
  this.lineWidth(lineWidth);
4035
- var d = options.underline ? 1 : 2;
4036
- var lineY = y + this.currentLineHeight() / d;
4148
+ var lineY = y + this.currentLineHeight() - lineWidth;
4149
+ this.moveTo(x, lineY);
4150
+ this.lineTo(x + renderedWidth, lineY);
4151
+ this.stroke();
4152
+ this.restore();
4153
+ } // create strikethrough line
4154
+
4155
+
4156
+ if (options.strike) {
4157
+ this.save();
4037
4158
 
4038
- if (options.underline) {
4039
- lineY -= lineWidth;
4159
+ if (!options.stroke) {
4160
+ this.strokeColor(...(this._fillColor || []));
4040
4161
  }
4041
4162
 
4042
- this.moveTo(x, lineY);
4043
- this.lineTo(x + renderedWidth, lineY);
4163
+ var _lineWidth = this._fontSize < 10 ? 0.5 : Math.floor(this._fontSize / 10);
4164
+
4165
+ this.lineWidth(_lineWidth);
4166
+
4167
+ var _lineY = y + this.currentLineHeight() / 2;
4168
+
4169
+ this.moveTo(x, _lineY);
4170
+ this.lineTo(x + renderedWidth, _lineY);
4044
4171
  this.stroke();
4045
4172
  this.restore();
4046
4173
  }
@@ -4421,9 +4548,9 @@ class PNGImage {
4421
4548
 
4422
4549
  }
4423
4550
 
4424
- /*
4425
- PDFImage - embeds images in PDF documents
4426
- By Devon Govett
4551
+ /*
4552
+ PDFImage - embeds images in PDF documents
4553
+ By Devon Govett
4427
4554
  */
4428
4555
 
4429
4556
  class PDFImage {
@@ -4864,29 +4991,18 @@ var OutlineMixin = {
4864
4991
 
4865
4992
  };
4866
4993
 
4867
- function _defineProperty(obj, key, value) {
4868
- if (key in obj) {
4869
- Object.defineProperty(obj, key, {
4870
- value: value,
4871
- enumerable: true,
4872
- configurable: true,
4873
- writable: true
4874
- });
4875
- } else {
4876
- obj[key] = value;
4877
- }
4878
-
4879
- return obj;
4880
- }
4881
-
4882
4994
  function ownKeys(object, enumerableOnly) {
4883
4995
  var keys = Object.keys(object);
4884
4996
 
4885
4997
  if (Object.getOwnPropertySymbols) {
4886
4998
  var symbols = Object.getOwnPropertySymbols(object);
4887
- if (enumerableOnly) symbols = symbols.filter(function (sym) {
4888
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
4889
- });
4999
+
5000
+ if (enumerableOnly) {
5001
+ symbols = symbols.filter(function (sym) {
5002
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
5003
+ });
5004
+ }
5005
+
4890
5006
  keys.push.apply(keys, symbols);
4891
5007
  }
4892
5008
 
@@ -4913,9 +5029,24 @@ function _objectSpread2(target) {
4913
5029
  return target;
4914
5030
  }
4915
5031
 
4916
- /*
4917
- PDFStructureContent - a reference to a marked structure content
4918
- By Ben Schmidt
5032
+ function _defineProperty(obj, key, value) {
5033
+ if (key in obj) {
5034
+ Object.defineProperty(obj, key, {
5035
+ value: value,
5036
+ enumerable: true,
5037
+ configurable: true,
5038
+ writable: true
5039
+ });
5040
+ } else {
5041
+ obj[key] = value;
5042
+ }
5043
+
5044
+ return obj;
5045
+ }
5046
+
5047
+ /*
5048
+ PDFStructureContent - a reference to a marked structure content
5049
+ By Ben Schmidt
4919
5050
  */
4920
5051
  class PDFStructureContent {
4921
5052
  constructor(pageRef, mcid) {
@@ -4931,9 +5062,9 @@ class PDFStructureContent {
4931
5062
 
4932
5063
  }
4933
5064
 
4934
- /*
4935
- PDFStructureElement - represents an element in the PDF logical structure tree
4936
- By Ben Schmidt
5065
+ /*
5066
+ PDFStructureElement - represents an element in the PDF logical structure tree
5067
+ By Ben Schmidt
4937
5068
  */
4938
5069
 
4939
5070
  class PDFStructureElement {
@@ -5019,7 +5150,7 @@ class PDFStructureElement {
5019
5150
  }
5020
5151
 
5021
5152
  _addContentToParentTree(content) {
5022
- content.refs.forEach((_ref) => {
5153
+ content.refs.forEach(_ref => {
5023
5154
  var {
5024
5155
  pageRef,
5025
5156
  mcid
@@ -5127,7 +5258,7 @@ class PDFStructureElement {
5127
5258
  }
5128
5259
 
5129
5260
  if (child instanceof PDFStructureContent) {
5130
- child.refs.forEach((_ref2) => {
5261
+ child.refs.forEach(_ref2 => {
5131
5262
  var {
5132
5263
  pageRef,
5133
5264
  mcid
@@ -5152,8 +5283,8 @@ class PDFStructureElement {
5152
5283
 
5153
5284
  }
5154
5285
 
5155
- /*
5156
- PDFNumberTree - represents a number tree object
5286
+ /*
5287
+ PDFNumberTree - represents a number tree object
5157
5288
  */
5158
5289
 
5159
5290
  class PDFNumberTree extends PDFTree {
@@ -5176,7 +5307,8 @@ var MarkingsMixin = {
5176
5307
  this.structChildren = [];
5177
5308
 
5178
5309
  if (options.tagged) {
5179
- this.getMarkingsDictionary().data.Marked = true;
5310
+ this.getMarkInfoDictionary().data.Marked = true;
5311
+ this.getStructTreeRoot();
5180
5312
  }
5181
5313
  },
5182
5314
 
@@ -5309,18 +5441,18 @@ var MarkingsMixin = {
5309
5441
  return pageMarkings;
5310
5442
  },
5311
5443
 
5312
- getMarkingsDictionary() {
5313
- if (!this._root.data.Markings) {
5314
- this._root.data.Markings = this.ref({});
5444
+ getMarkInfoDictionary() {
5445
+ if (!this._root.data.MarkInfo) {
5446
+ this._root.data.MarkInfo = this.ref({});
5315
5447
  }
5316
5448
 
5317
- return this._root.data.Markings;
5449
+ return this._root.data.MarkInfo;
5318
5450
  },
5319
5451
 
5320
5452
  getStructTreeRoot() {
5321
5453
  if (!this._root.data.StructTreeRoot) {
5322
5454
  this._root.data.StructTreeRoot = this.ref({
5323
- Type: "StructTreeRoot",
5455
+ Type: 'StructTreeRoot',
5324
5456
  ParentTree: new PDFNumberTree(),
5325
5457
  ParentTreeNextKey: 0
5326
5458
  });
@@ -5334,8 +5466,8 @@ var MarkingsMixin = {
5334
5466
  },
5335
5467
 
5336
5468
  createStructParentTreeNextKey() {
5337
- // initialise the Markings dictionary
5338
- this.getMarkingsDictionary();
5469
+ // initialise the MarkInfo dictionary
5470
+ this.getMarkInfoDictionary();
5339
5471
  var structTreeRoot = this.getStructTreeRoot();
5340
5472
  var key = structTreeRoot.data.ParentTreeNextKey++;
5341
5473
  structTreeRoot.data.ParentTree.add(key, []);
@@ -5350,8 +5482,8 @@ var MarkingsMixin = {
5350
5482
  this.structChildren.forEach(structElem => structElem.end());
5351
5483
  }
5352
5484
 
5353
- if (this._root.data.Markings) {
5354
- this._root.data.Markings.end();
5485
+ if (this._root.data.MarkInfo) {
5486
+ this._root.data.MarkInfo.end();
5355
5487
  }
5356
5488
  }
5357
5489
 
@@ -5402,9 +5534,9 @@ var FORMAT_DEFAULT = {
5402
5534
  }
5403
5535
  };
5404
5536
  var AcroFormMixin = {
5405
- /**
5406
- * Must call if adding AcroForms to a document. Must also call font() before
5407
- * this method to set the default font.
5537
+ /**
5538
+ * Must call if adding AcroForms to a document. Must also call font() before
5539
+ * this method to set the default font.
5408
5540
  */
5409
5541
  initForm() {
5410
5542
  if (!this._font) {
@@ -5430,8 +5562,8 @@ var AcroFormMixin = {
5430
5562
  return this;
5431
5563
  },
5432
5564
 
5433
- /**
5434
- * Called automatically by document.js
5565
+ /**
5566
+ * Called automatically by document.js
5435
5567
  */
5436
5568
  endAcroForm() {
5437
5569
  if (this._root.data.AcroForm) {
@@ -5465,12 +5597,12 @@ var AcroFormMixin = {
5465
5597
  return this;
5466
5598
  },
5467
5599
 
5468
- /**
5469
- * Creates and adds a form field to the document. Form fields are intermediate
5470
- * nodes in a PDF form that are used to specify form name heirarchy and form
5471
- * value defaults.
5472
- * @param {string} name - field name (T attribute in field dictionary)
5473
- * @param {object} options - other attributes to include in field dictionary
5600
+ /**
5601
+ * Creates and adds a form field to the document. Form fields are intermediate
5602
+ * nodes in a PDF form that are used to specify form name heirarchy and form
5603
+ * value defaults.
5604
+ * @param {string} name - field name (T attribute in field dictionary)
5605
+ * @param {object} options - other attributes to include in field dictionary
5474
5606
  */
5475
5607
  formField(name) {
5476
5608
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -5484,16 +5616,16 @@ var AcroFormMixin = {
5484
5616
  return fieldRef;
5485
5617
  },
5486
5618
 
5487
- /**
5488
- * Creates and adds a Form Annotation to the document. Form annotations are
5489
- * called Widget annotations internally within a PDF file.
5490
- * @param {string} name - form field name (T attribute of widget annotation
5491
- * dictionary)
5492
- * @param {number} x
5493
- * @param {number} y
5494
- * @param {number} w
5495
- * @param {number} h
5496
- * @param {object} options
5619
+ /**
5620
+ * Creates and adds a Form Annotation to the document. Form annotations are
5621
+ * called Widget annotations internally within a PDF file.
5622
+ * @param {string} name - form field name (T attribute of widget annotation
5623
+ * dictionary)
5624
+ * @param {number} x
5625
+ * @param {number} y
5626
+ * @param {number} w
5627
+ * @param {number} h
5628
+ * @param {object} options
5497
5629
  */
5498
5630
  formAnnotation(name, type, x, y, w, h) {
5499
5631
  var options = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
@@ -5728,9 +5860,11 @@ var AcroFormMixin = {
5728
5860
  if (this._acroform.defaultFont !== this._font.name) {
5729
5861
  options.DR = {
5730
5862
  Font: {}
5731
- };
5863
+ }; // Get the fontSize option. If not set use auto sizing
5864
+
5865
+ var fontSize = options.fontSize || 0;
5732
5866
  options.DR.Font[this._font.id] = this._font.ref();
5733
- options.DA = new String("/".concat(this._font.id, " 0 Tf 0 g"));
5867
+ options.DA = new String("/".concat(this._font.id, " ").concat(fontSize, " Tf 0 g"));
5734
5868
  }
5735
5869
 
5736
5870
  return options;
@@ -5790,17 +5924,17 @@ var AcroFormMixin = {
5790
5924
  };
5791
5925
 
5792
5926
  var AttachmentsMixin = {
5793
- /**
5794
- * Embed contents of `src` in PDF
5795
- * @param {Buffer | ArrayBuffer | string} src input Buffer, ArrayBuffer, base64 encoded string or path to file
5796
- * @param {object} options
5797
- * * options.name: filename to be shown in PDF, will use `src` if none set
5798
- * * options.type: filetype to be shown in PDF
5799
- * * options.description: description to be shown in PDF
5800
- * * options.hidden: if true, do not add attachment to EmbeddedFiles dictionary. Useful for file attachment annotations
5801
- * * options.creationDate: override creation date
5802
- * * options.modifiedDate: override modified date
5803
- * @returns filespec reference
5927
+ /**
5928
+ * Embed contents of `src` in PDF
5929
+ * @param {Buffer | ArrayBuffer | string} src input Buffer, ArrayBuffer, base64 encoded string or path to file
5930
+ * @param {object} options
5931
+ * * options.name: filename to be shown in PDF, will use `src` if none set
5932
+ * * options.type: filetype to be shown in PDF
5933
+ * * options.description: description to be shown in PDF
5934
+ * * options.hidden: if true, do not add attachment to EmbeddedFiles dictionary. Useful for file attachment annotations
5935
+ * * options.creationDate: override creation date
5936
+ * * options.modifiedDate: override modified date
5937
+ * @returns filespec reference
5804
5938
  */
5805
5939
  file(src) {
5806
5940
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -5907,16 +6041,12 @@ var AttachmentsMixin = {
5907
6041
  /** check two embedded file metadata objects for equality */
5908
6042
 
5909
6043
  function isEqual(a, b) {
5910
- if (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) {
5911
- return false;
5912
- }
5913
-
5914
- return true;
6044
+ 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;
5915
6045
  }
5916
6046
 
5917
- /*
5918
- PDFDocument - represents an entire PDF document
5919
- By Devon Govett
6047
+ /*
6048
+ PDFDocument - represents an entire PDF document
6049
+ By Devon Govett
5920
6050
  */
5921
6051
 
5922
6052
  class PDFDocument extends stream.Readable {