pdfkit 0.10.0 → 0.11.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.
- package/CHANGELOG.md +39 -27
- package/LICENSE +7 -7
- package/README.md +181 -175
- package/js/data/Courier-Bold.afm +342 -342
- package/js/data/Courier-BoldOblique.afm +342 -342
- package/js/data/Courier-Oblique.afm +342 -342
- package/js/data/Courier.afm +342 -342
- package/js/data/Helvetica-Bold.afm +2827 -2827
- package/js/data/Helvetica-BoldOblique.afm +2827 -2827
- package/js/data/Helvetica-Oblique.afm +3051 -3051
- package/js/data/Helvetica.afm +3051 -3051
- package/js/data/Symbol.afm +213 -213
- package/js/data/Times-Bold.afm +2588 -2588
- package/js/data/Times-BoldItalic.afm +2384 -2384
- package/js/data/Times-Italic.afm +2667 -2667
- package/js/data/Times-Roman.afm +2419 -2419
- package/js/data/ZapfDingbats.afm +225 -225
- package/js/pdfkit.es5.js +574 -96
- package/js/pdfkit.es5.js.map +1 -1
- package/js/pdfkit.esnext.js +660 -255
- package/js/pdfkit.esnext.js.map +1 -1
- package/js/pdfkit.js +588 -119
- package/js/pdfkit.js.map +1 -1
- package/js/pdfkit.standalone.js +13183 -16170
- package/package.json +85 -85
package/js/pdfkit.es5.js
CHANGED
|
@@ -101,6 +101,10 @@ function _iterableToArray(iter) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
function _iterableToArrayLimit(arr, i) {
|
|
104
|
+
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
104
108
|
var _arr = [];
|
|
105
109
|
var _n = true;
|
|
106
110
|
var _d = false;
|
|
@@ -134,8 +138,8 @@ function _nonIterableRest() {
|
|
|
134
138
|
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
/*
|
|
138
|
-
PDFAbstractReference - abstract class for PDF reference
|
|
141
|
+
/*
|
|
142
|
+
PDFAbstractReference - abstract class for PDF reference
|
|
139
143
|
*/
|
|
140
144
|
var PDFAbstractReference =
|
|
141
145
|
/*#__PURE__*/
|
|
@@ -454,9 +458,9 @@ function (_PDFAbstractReference) {
|
|
|
454
458
|
return PDFReference;
|
|
455
459
|
}(PDFAbstractReference);
|
|
456
460
|
|
|
457
|
-
/*
|
|
458
|
-
PDFPage - represents a single page in the PDF document
|
|
459
|
-
By Devon Govett
|
|
461
|
+
/*
|
|
462
|
+
PDFPage - represents a single page in the PDF document
|
|
463
|
+
By Devon Govett
|
|
460
464
|
*/
|
|
461
465
|
var DEFAULT_MARGINS = {
|
|
462
466
|
top: 72,
|
|
@@ -612,11 +616,11 @@ function () {
|
|
|
612
616
|
return PDFPage;
|
|
613
617
|
}();
|
|
614
618
|
|
|
615
|
-
/**
|
|
616
|
-
* Check if value is in a range group.
|
|
617
|
-
* @param {number} value
|
|
618
|
-
* @param {number[]} rangeGroup
|
|
619
|
-
* @returns {boolean}
|
|
619
|
+
/**
|
|
620
|
+
* Check if value is in a range group.
|
|
621
|
+
* @param {number} value
|
|
622
|
+
* @param {number[]} rangeGroup
|
|
623
|
+
* @returns {boolean}
|
|
620
624
|
*/
|
|
621
625
|
function inRange(value, rangeGroup) {
|
|
622
626
|
if (value < rangeGroup[0]) return false;
|
|
@@ -646,9 +650,9 @@ function inRange(value, rangeGroup) {
|
|
|
646
650
|
|
|
647
651
|
/* eslint-disable prettier/prettier */
|
|
648
652
|
|
|
649
|
-
/**
|
|
650
|
-
* A.1 Unassigned code points in Unicode 3.2
|
|
651
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-A.1
|
|
653
|
+
/**
|
|
654
|
+
* A.1 Unassigned code points in Unicode 3.2
|
|
655
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-A.1
|
|
652
656
|
*/
|
|
653
657
|
|
|
654
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,9 +663,9 @@ var isUnassignedCodePoint = function isUnassignedCodePoint(character) {
|
|
|
659
663
|
};
|
|
660
664
|
/* eslint-disable prettier/prettier */
|
|
661
665
|
|
|
662
|
-
/**
|
|
663
|
-
* B.1 Commonly mapped to nothing
|
|
664
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-B.1
|
|
666
|
+
/**
|
|
667
|
+
* B.1 Commonly mapped to nothing
|
|
668
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-B.1
|
|
665
669
|
*/
|
|
666
670
|
|
|
667
671
|
|
|
@@ -673,9 +677,9 @@ var isCommonlyMappedToNothing = function isCommonlyMappedToNothing(character) {
|
|
|
673
677
|
};
|
|
674
678
|
/* eslint-disable prettier/prettier */
|
|
675
679
|
|
|
676
|
-
/**
|
|
677
|
-
* C.1.2 Non-ASCII space characters
|
|
678
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.1.2
|
|
680
|
+
/**
|
|
681
|
+
* C.1.2 Non-ASCII space characters
|
|
682
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.1.2
|
|
679
683
|
*/
|
|
680
684
|
|
|
681
685
|
|
|
@@ -723,9 +727,9 @@ var isNonASCIISpaceCharacter = function isNonASCIISpaceCharacter(character) {
|
|
|
723
727
|
|
|
724
728
|
|
|
725
729
|
var non_ASCII_controls_characters = [
|
|
726
|
-
/**
|
|
727
|
-
* C.2.2 Non-ASCII control characters
|
|
728
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.2.2
|
|
730
|
+
/**
|
|
731
|
+
* C.2.2 Non-ASCII control characters
|
|
732
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.2.2
|
|
729
733
|
*/
|
|
730
734
|
0x0080, 0x009f
|
|
731
735
|
/* [CONTROL CHARACTERS] */
|
|
@@ -761,9 +765,9 @@ var non_ASCII_controls_characters = [
|
|
|
761
765
|
/* [MUSICAL CONTROL CHARACTERS] */
|
|
762
766
|
];
|
|
763
767
|
var non_character_codepoints = [
|
|
764
|
-
/**
|
|
765
|
-
* C.4 Non-character code points
|
|
766
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.4
|
|
768
|
+
/**
|
|
769
|
+
* C.4 Non-character code points
|
|
770
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.4
|
|
767
771
|
*/
|
|
768
772
|
0xfdd0, 0xfdef
|
|
769
773
|
/* [NONCHARACTER CODE POINTS] */
|
|
@@ -800,23 +804,23 @@ var non_character_codepoints = [
|
|
|
800
804
|
, 0x10fffe, 0x10ffff
|
|
801
805
|
/* [NONCHARACTER CODE POINTS] */
|
|
802
806
|
];
|
|
803
|
-
/**
|
|
804
|
-
* 2.3. Prohibited Output
|
|
807
|
+
/**
|
|
808
|
+
* 2.3. Prohibited Output
|
|
805
809
|
*/
|
|
806
810
|
|
|
807
811
|
var prohibited_characters = [
|
|
808
|
-
/**
|
|
809
|
-
* C.2.1 ASCII control characters
|
|
810
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.2.1
|
|
812
|
+
/**
|
|
813
|
+
* C.2.1 ASCII control characters
|
|
814
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.2.1
|
|
811
815
|
*/
|
|
812
816
|
0, 0x001f
|
|
813
817
|
/* [CONTROL CHARACTERS] */
|
|
814
818
|
, 0x007f, 0x007f
|
|
815
819
|
/* DELETE */
|
|
816
820
|
,
|
|
817
|
-
/**
|
|
818
|
-
* C.8 Change display properties or are deprecated
|
|
819
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.8
|
|
821
|
+
/**
|
|
822
|
+
* C.8 Change display properties or are deprecated
|
|
823
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.8
|
|
820
824
|
*/
|
|
821
825
|
0x0340, 0x0340
|
|
822
826
|
/* COMBINING GRAVE TONE MARK */
|
|
@@ -849,28 +853,28 @@ var prohibited_characters = [
|
|
|
849
853
|
, 0x206f, 0x206f
|
|
850
854
|
/* NOMINAL DIGIT SHAPES */
|
|
851
855
|
,
|
|
852
|
-
/**
|
|
853
|
-
* C.7 Inappropriate for canonical representation
|
|
854
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.7
|
|
856
|
+
/**
|
|
857
|
+
* C.7 Inappropriate for canonical representation
|
|
858
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.7
|
|
855
859
|
*/
|
|
856
860
|
0x2ff0, 0x2ffb
|
|
857
861
|
/* [IDEOGRAPHIC DESCRIPTION CHARACTERS] */
|
|
858
862
|
,
|
|
859
|
-
/**
|
|
860
|
-
* C.5 Surrogate codes
|
|
861
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.5
|
|
863
|
+
/**
|
|
864
|
+
* C.5 Surrogate codes
|
|
865
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.5
|
|
862
866
|
*/
|
|
863
867
|
0xd800, 0xdfff,
|
|
864
|
-
/**
|
|
865
|
-
* C.3 Private use
|
|
866
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.3
|
|
868
|
+
/**
|
|
869
|
+
* C.3 Private use
|
|
870
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.3
|
|
867
871
|
*/
|
|
868
872
|
0xe000, 0xf8ff
|
|
869
873
|
/* [PRIVATE USE, PLANE 0] */
|
|
870
874
|
,
|
|
871
|
-
/**
|
|
872
|
-
* C.6 Inappropriate for plain text
|
|
873
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.6
|
|
875
|
+
/**
|
|
876
|
+
* C.6 Inappropriate for plain text
|
|
877
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.6
|
|
874
878
|
*/
|
|
875
879
|
0xfff9, 0xfff9
|
|
876
880
|
/* INTERLINEAR ANNOTATION ANCHOR */
|
|
@@ -883,18 +887,18 @@ var prohibited_characters = [
|
|
|
883
887
|
, 0xfffd, 0xfffd
|
|
884
888
|
/* REPLACEMENT CHARACTER */
|
|
885
889
|
,
|
|
886
|
-
/**
|
|
887
|
-
* C.9 Tagging characters
|
|
888
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.9
|
|
890
|
+
/**
|
|
891
|
+
* C.9 Tagging characters
|
|
892
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.9
|
|
889
893
|
*/
|
|
890
894
|
0xe0001, 0xe0001
|
|
891
895
|
/* LANGUAGE TAG */
|
|
892
896
|
, 0xe0020, 0xe007f
|
|
893
897
|
/* [TAGGING CHARACTERS] */
|
|
894
898
|
,
|
|
895
|
-
/**
|
|
896
|
-
* C.3 Private use
|
|
897
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-C.3
|
|
899
|
+
/**
|
|
900
|
+
* C.3 Private use
|
|
901
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-C.3
|
|
898
902
|
*/
|
|
899
903
|
0xf0000, 0xffffd
|
|
900
904
|
/* [PRIVATE USE, PLANE 15] */
|
|
@@ -908,9 +912,9 @@ var isProhibitedCharacter = function isProhibitedCharacter(character) {
|
|
|
908
912
|
};
|
|
909
913
|
/* eslint-disable prettier/prettier */
|
|
910
914
|
|
|
911
|
-
/**
|
|
912
|
-
* D.1 Characters with bidirectional property "R" or "AL"
|
|
913
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-D.1
|
|
915
|
+
/**
|
|
916
|
+
* D.1 Characters with bidirectional property "R" or "AL"
|
|
917
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-D.1
|
|
914
918
|
*/
|
|
915
919
|
|
|
916
920
|
|
|
@@ -922,9 +926,9 @@ var isBidirectionalRAL = function isBidirectionalRAL(character) {
|
|
|
922
926
|
};
|
|
923
927
|
/* eslint-disable prettier/prettier */
|
|
924
928
|
|
|
925
|
-
/**
|
|
926
|
-
* D.2 Characters with bidirectional property "L"
|
|
927
|
-
* @link https://tools.ietf.org/html/rfc3454#appendix-D.2
|
|
929
|
+
/**
|
|
930
|
+
* D.2 Characters with bidirectional property "L"
|
|
931
|
+
* @link https://tools.ietf.org/html/rfc3454#appendix-D.2
|
|
928
932
|
*/
|
|
929
933
|
|
|
930
934
|
|
|
@@ -935,15 +939,15 @@ var isBidirectionalL = function isBidirectionalL(character) {
|
|
|
935
939
|
return inRange(character, bidirectional_l);
|
|
936
940
|
};
|
|
937
941
|
|
|
938
|
-
/**
|
|
939
|
-
* non-ASCII space characters [StringPrep, C.1.2] that can be
|
|
940
|
-
* mapped to SPACE (U+0020)
|
|
942
|
+
/**
|
|
943
|
+
* non-ASCII space characters [StringPrep, C.1.2] that can be
|
|
944
|
+
* mapped to SPACE (U+0020)
|
|
941
945
|
*/
|
|
942
946
|
|
|
943
947
|
var mapping2space = isNonASCIISpaceCharacter;
|
|
944
|
-
/**
|
|
945
|
-
* the "commonly mapped to nothing" characters [StringPrep, B.1]
|
|
946
|
-
* that can be mapped to nothing.
|
|
948
|
+
/**
|
|
949
|
+
* the "commonly mapped to nothing" characters [StringPrep, B.1]
|
|
950
|
+
* that can be mapped to nothing.
|
|
947
951
|
*/
|
|
948
952
|
|
|
949
953
|
var mapping2nothing = isCommonlyMappedToNothing; // utils
|
|
@@ -959,12 +963,12 @@ var first = function first(x) {
|
|
|
959
963
|
var last = function last(x) {
|
|
960
964
|
return x[x.length - 1];
|
|
961
965
|
};
|
|
962
|
-
/**
|
|
963
|
-
* Convert provided string into an array of Unicode Code Points.
|
|
964
|
-
* Based on https://stackoverflow.com/a/21409165/1556249
|
|
965
|
-
* and https://www.npmjs.com/package/code-point-at.
|
|
966
|
-
* @param {string} input
|
|
967
|
-
* @returns {number[]}
|
|
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[]}
|
|
968
972
|
*/
|
|
969
973
|
|
|
970
974
|
|
|
@@ -990,12 +994,12 @@ function toCodePoints(input) {
|
|
|
990
994
|
|
|
991
995
|
return codepoints;
|
|
992
996
|
}
|
|
993
|
-
/**
|
|
994
|
-
* SASLprep.
|
|
995
|
-
* @param {string} input
|
|
996
|
-
* @param {Object} opts
|
|
997
|
-
* @param {boolean} opts.allowUnassigned
|
|
998
|
-
* @returns {string}
|
|
997
|
+
/**
|
|
998
|
+
* SASLprep.
|
|
999
|
+
* @param {string} input
|
|
1000
|
+
* @param {Object} opts
|
|
1001
|
+
* @param {boolean} opts.allowUnassigned
|
|
1002
|
+
* @returns {string}
|
|
999
1003
|
*/
|
|
1000
1004
|
|
|
1001
1005
|
|
|
@@ -1045,10 +1049,10 @@ function saslprep(input) {
|
|
|
1045
1049
|
if (hasBidiRAL && hasBidiL) {
|
|
1046
1050
|
throw new Error('String must not contain RandALCat and LCat at the same time,' + ' see https://tools.ietf.org/html/rfc3454#section-6');
|
|
1047
1051
|
}
|
|
1048
|
-
/**
|
|
1049
|
-
* 4.2 If a string contains any RandALCat character, a RandALCat
|
|
1050
|
-
* character MUST be the first character of the string, and a
|
|
1051
|
-
* RandALCat character MUST be the last character of the string.
|
|
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.
|
|
1052
1056
|
*/
|
|
1053
1057
|
|
|
1054
1058
|
|
|
@@ -1076,7 +1080,7 @@ function () {
|
|
|
1076
1080
|
continue;
|
|
1077
1081
|
}
|
|
1078
1082
|
|
|
1079
|
-
infoStr += "".concat(key, ": ").concat(info[key]
|
|
1083
|
+
infoStr += "".concat(key, ": ").concat(info[key], "\n");
|
|
1080
1084
|
}
|
|
1081
1085
|
|
|
1082
1086
|
return wordArrayToBuffer(CryptoJS.MD5(infoStr));
|
|
@@ -1567,15 +1571,16 @@ function () {
|
|
|
1567
1571
|
key: "embed",
|
|
1568
1572
|
value: function embed(m) {
|
|
1569
1573
|
var fn;
|
|
1574
|
+
var stopsLength = this.stops.length;
|
|
1570
1575
|
|
|
1571
|
-
if (
|
|
1576
|
+
if (stopsLength === 0) {
|
|
1572
1577
|
return;
|
|
1573
1578
|
}
|
|
1574
1579
|
|
|
1575
1580
|
this.embedded = true;
|
|
1576
1581
|
this.matrix = m; // if the last stop comes before 100%, add a copy at 100%
|
|
1577
1582
|
|
|
1578
|
-
var last = this.stops[
|
|
1583
|
+
var last = this.stops[stopsLength - 1];
|
|
1579
1584
|
|
|
1580
1585
|
if (last[0] < 1) {
|
|
1581
1586
|
this.stops.push([1, last[1], last[2]]);
|
|
@@ -1585,7 +1590,7 @@ function () {
|
|
|
1585
1590
|
var encode = [];
|
|
1586
1591
|
var stops = [];
|
|
1587
1592
|
|
|
1588
|
-
for (var i = 0
|
|
1593
|
+
for (var i = 0; i < stopsLength - 1; i++) {
|
|
1589
1594
|
encode.push(0, 1);
|
|
1590
1595
|
|
|
1591
1596
|
if (i + 2 !== stopsLength) {
|
|
@@ -1604,7 +1609,7 @@ function () {
|
|
|
1604
1609
|
} // if there are only two stops, we don't need a stitching function
|
|
1605
1610
|
|
|
1606
1611
|
|
|
1607
|
-
if (
|
|
1612
|
+
if (stopsLength === 1) {
|
|
1608
1613
|
fn = stops[0];
|
|
1609
1614
|
} else {
|
|
1610
1615
|
fn = this.doc.ref({
|
|
@@ -1625,9 +1630,7 @@ function () {
|
|
|
1625
1630
|
Type: 'Pattern',
|
|
1626
1631
|
PatternType: 2,
|
|
1627
1632
|
Shading: shader,
|
|
1628
|
-
Matrix: this.matrix.map(
|
|
1629
|
-
return number(v);
|
|
1630
|
-
})
|
|
1633
|
+
Matrix: this.matrix.map(number)
|
|
1631
1634
|
});
|
|
1632
1635
|
pattern.end();
|
|
1633
1636
|
|
|
@@ -2321,7 +2324,7 @@ var runners = {
|
|
|
2321
2324
|
cy = a[5];
|
|
2322
2325
|
px = a[2];
|
|
2323
2326
|
py = a[3];
|
|
2324
|
-
return doc.bezierCurveTo.apply(doc, _toConsumableArray(a
|
|
2327
|
+
return doc.bezierCurveTo.apply(doc, _toConsumableArray(a));
|
|
2325
2328
|
},
|
|
2326
2329
|
c: function c(doc, a) {
|
|
2327
2330
|
doc.bezierCurveTo(a[0] + cx, a[1] + cy, a[2] + cx, a[3] + cy, a[4] + cx, a[5] + cy);
|
|
@@ -2470,8 +2473,8 @@ var solveArc = function solveArc(doc, x, y, coords) {
|
|
|
2470
2473
|
try {
|
|
2471
2474
|
for (var _iterator2 = segs[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
2472
2475
|
var seg = _step2.value;
|
|
2473
|
-
var bez = segmentToBezier.apply(void 0, _toConsumableArray(seg
|
|
2474
|
-
doc.bezierCurveTo.apply(doc, _toConsumableArray(bez
|
|
2476
|
+
var bez = segmentToBezier.apply(void 0, _toConsumableArray(seg));
|
|
2477
|
+
doc.bezierCurveTo.apply(doc, _toConsumableArray(bez));
|
|
2475
2478
|
}
|
|
2476
2479
|
} catch (err) {
|
|
2477
2480
|
_didIteratorError2 = true;
|
|
@@ -3520,9 +3523,9 @@ function (_PDFFont) {
|
|
|
3520
3523
|
}
|
|
3521
3524
|
|
|
3522
3525
|
descriptor.end();
|
|
3523
|
-
var
|
|
3526
|
+
var descendantFontData = {
|
|
3524
3527
|
Type: 'Font',
|
|
3525
|
-
Subtype:
|
|
3528
|
+
Subtype: 'CIDFontType0',
|
|
3526
3529
|
BaseFont: name,
|
|
3527
3530
|
CIDSystemInfo: {
|
|
3528
3531
|
Registry: new String('Adobe'),
|
|
@@ -3531,7 +3534,14 @@ function (_PDFFont) {
|
|
|
3531
3534
|
},
|
|
3532
3535
|
FontDescriptor: descriptor,
|
|
3533
3536
|
W: [0, this.widths]
|
|
3534
|
-
}
|
|
3537
|
+
};
|
|
3538
|
+
|
|
3539
|
+
if (!isCFF) {
|
|
3540
|
+
descendantFontData.Subtype = 'CIDFontType2';
|
|
3541
|
+
descendantFontData.CIDToGIDMap = 'Identity';
|
|
3542
|
+
}
|
|
3543
|
+
|
|
3544
|
+
var descendantFont = this.document.ref(descendantFontData);
|
|
3535
3545
|
descendantFont.end();
|
|
3536
3546
|
this.dictionary.data = {
|
|
3537
3547
|
Type: 'Font',
|
|
@@ -3868,6 +3878,11 @@ function (_EventEmitter) {
|
|
|
3868
3878
|
mustShrink = w > this.spaceLeft && l > 0;
|
|
3869
3879
|
mightGrow = w <= this.spaceLeft && l < word.length;
|
|
3870
3880
|
}
|
|
3881
|
+
} // check for the edge case where a single character cannot fit into a line.
|
|
3882
|
+
|
|
3883
|
+
|
|
3884
|
+
if (l === 0 && this.spaceLeft === this.lineWidth) {
|
|
3885
|
+
l = 1;
|
|
3871
3886
|
} // send a required break unless this is the last piece and a linebreak is not specified
|
|
3872
3887
|
|
|
3873
3888
|
|
|
@@ -4070,7 +4085,7 @@ function (_EventEmitter) {
|
|
|
4070
4085
|
if (this.document._fillColor) {
|
|
4071
4086
|
var _this$document;
|
|
4072
4087
|
|
|
4073
|
-
(_this$document = this.document).fillColor.apply(_this$document, _toConsumableArray(this.document._fillColor
|
|
4088
|
+
(_this$document = this.document).fillColor.apply(_this$document, _toConsumableArray(this.document._fillColor));
|
|
4074
4089
|
}
|
|
4075
4090
|
|
|
4076
4091
|
this.emit('pageBreak', options, this);
|
|
@@ -4300,7 +4315,7 @@ var TextMixin = {
|
|
|
4300
4315
|
var val = this._textOptions[key];
|
|
4301
4316
|
|
|
4302
4317
|
if (key !== 'continued') {
|
|
4303
|
-
if (result[key]
|
|
4318
|
+
if (result[key] === undefined) {
|
|
4304
4319
|
result[key] = val;
|
|
4305
4320
|
}
|
|
4306
4321
|
}
|
|
@@ -4321,6 +4336,8 @@ var TextMixin = {
|
|
|
4321
4336
|
if (result.width == null) {
|
|
4322
4337
|
result.width = this.page.width - this.x - this.page.margins.right;
|
|
4323
4338
|
}
|
|
4339
|
+
|
|
4340
|
+
result.width = Math.max(result.width, 0);
|
|
4324
4341
|
}
|
|
4325
4342
|
|
|
4326
4343
|
if (!result.columns) {
|
|
@@ -4728,6 +4745,7 @@ function () {
|
|
|
4728
4745
|
_createClass(PNGImage, [{
|
|
4729
4746
|
key: "embed",
|
|
4730
4747
|
value: function embed(document) {
|
|
4748
|
+
var dataDecoded = false;
|
|
4731
4749
|
this.document = document;
|
|
4732
4750
|
|
|
4733
4751
|
if (this.obj) {
|
|
@@ -4735,6 +4753,7 @@ function () {
|
|
|
4735
4753
|
}
|
|
4736
4754
|
|
|
4737
4755
|
var hasAlphaChannel = this.image.hasAlphaChannel;
|
|
4756
|
+
var isInterlaced = this.image.interlaceMethod === 1;
|
|
4738
4757
|
this.obj = this.document.ref({
|
|
4739
4758
|
Type: 'XObject',
|
|
4740
4759
|
Subtype: 'Image',
|
|
@@ -4746,7 +4765,7 @@ function () {
|
|
|
4746
4765
|
|
|
4747
4766
|
if (!hasAlphaChannel) {
|
|
4748
4767
|
var params = this.document.ref({
|
|
4749
|
-
Predictor: 15,
|
|
4768
|
+
Predictor: isInterlaced ? 1 : 15,
|
|
4750
4769
|
Colors: this.image.colors,
|
|
4751
4770
|
BitsPerComponent: this.image.bits,
|
|
4752
4771
|
Columns: this.width
|
|
@@ -4805,14 +4824,20 @@ function () {
|
|
|
4805
4824
|
} else if (this.image.transparency.indexed) {
|
|
4806
4825
|
// Create a transparency SMask for the image based on the data
|
|
4807
4826
|
// in the PLTE and tRNS sections. See below for details on SMasks.
|
|
4827
|
+
dataDecoded = true;
|
|
4808
4828
|
return this.loadIndexedAlphaChannel();
|
|
4809
4829
|
} else if (hasAlphaChannel) {
|
|
4810
4830
|
// For PNG color types 4 and 6, the transparency data is stored as a alpha
|
|
4811
4831
|
// channel mixed in with the main image data. Separate this data out into an
|
|
4812
4832
|
// SMask object and store it separately in the PDF.
|
|
4833
|
+
dataDecoded = true;
|
|
4813
4834
|
return this.splitAlphaChannel();
|
|
4814
4835
|
}
|
|
4815
4836
|
|
|
4837
|
+
if (isInterlaced && !dataDecoded) {
|
|
4838
|
+
return this.decodeData();
|
|
4839
|
+
}
|
|
4840
|
+
|
|
4816
4841
|
this.finalize();
|
|
4817
4842
|
}
|
|
4818
4843
|
}, {
|
|
@@ -4888,6 +4913,17 @@ function () {
|
|
|
4888
4913
|
return _this2.finalize();
|
|
4889
4914
|
});
|
|
4890
4915
|
}
|
|
4916
|
+
}, {
|
|
4917
|
+
key: "decodeData",
|
|
4918
|
+
value: function decodeData() {
|
|
4919
|
+
var _this3 = this;
|
|
4920
|
+
|
|
4921
|
+
this.image.decodePixels(function (pixels) {
|
|
4922
|
+
_this3.imgData = zlib.deflateSync(pixels);
|
|
4923
|
+
|
|
4924
|
+
_this3.finalize();
|
|
4925
|
+
});
|
|
4926
|
+
}
|
|
4891
4927
|
}]);
|
|
4892
4928
|
|
|
4893
4929
|
return PNGImage;
|
|
@@ -5082,6 +5118,10 @@ var AnnotationsMixin = {
|
|
|
5082
5118
|
options.Rect = this._convertRect(x, y, w, h);
|
|
5083
5119
|
options.Border = [0, 0, 0];
|
|
5084
5120
|
|
|
5121
|
+
if (options.Subtype === 'Link' && typeof options.F === 'undefined') {
|
|
5122
|
+
options.F = 1 << 2; // Print Annotation Flag
|
|
5123
|
+
}
|
|
5124
|
+
|
|
5085
5125
|
if (options.Subtype !== 'Link') {
|
|
5086
5126
|
if (options.C == null) {
|
|
5087
5127
|
options.C = this._normalizeColor(options.color || [0, 0, 0]);
|
|
@@ -5328,6 +5368,427 @@ var OutlineMixin = {
|
|
|
5328
5368
|
}
|
|
5329
5369
|
};
|
|
5330
5370
|
|
|
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',
|
|
5397
|
+
zipPlus4: '1',
|
|
5398
|
+
zip4: '1',
|
|
5399
|
+
phone: '2',
|
|
5400
|
+
ssn: '3'
|
|
5401
|
+
};
|
|
5402
|
+
var FORMAT_DEFAULT = {
|
|
5403
|
+
number: {
|
|
5404
|
+
nDec: 0,
|
|
5405
|
+
sepComma: false,
|
|
5406
|
+
negStyle: 'MinusBlack',
|
|
5407
|
+
currency: '',
|
|
5408
|
+
currencyPrepend: true
|
|
5409
|
+
},
|
|
5410
|
+
percent: {
|
|
5411
|
+
nDec: 0,
|
|
5412
|
+
sepComma: false
|
|
5413
|
+
}
|
|
5414
|
+
};
|
|
5415
|
+
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.
|
|
5419
|
+
*/
|
|
5420
|
+
initForm: function initForm() {
|
|
5421
|
+
if (!this._font) {
|
|
5422
|
+
throw new Error('Must set a font before calling initForm method');
|
|
5423
|
+
}
|
|
5424
|
+
|
|
5425
|
+
this._acroform = {
|
|
5426
|
+
fonts: {},
|
|
5427
|
+
defaultFont: this._font.name
|
|
5428
|
+
};
|
|
5429
|
+
this._acroform.fonts[this._font.id] = this._font.ref();
|
|
5430
|
+
var data = {
|
|
5431
|
+
Fields: [],
|
|
5432
|
+
NeedAppearances: true,
|
|
5433
|
+
DA: new String("/".concat(this._font.id, " 0 Tf 0 g")),
|
|
5434
|
+
DR: {
|
|
5435
|
+
Font: {}
|
|
5436
|
+
}
|
|
5437
|
+
};
|
|
5438
|
+
data.DR.Font[this._font.id] = this._font.ref();
|
|
5439
|
+
var AcroForm = this.ref(data);
|
|
5440
|
+
this._root.data.AcroForm = AcroForm;
|
|
5441
|
+
return this;
|
|
5442
|
+
},
|
|
5443
|
+
|
|
5444
|
+
/**
|
|
5445
|
+
* Called automatically by document.js
|
|
5446
|
+
*/
|
|
5447
|
+
endAcroForm: function endAcroForm() {
|
|
5448
|
+
var _this = this;
|
|
5449
|
+
|
|
5450
|
+
if (this._root.data.AcroForm) {
|
|
5451
|
+
if (!Object.keys(this._acroform.fonts).length && !this._acroform.defaultFont) {
|
|
5452
|
+
throw new Error('No fonts specified for PDF form');
|
|
5453
|
+
}
|
|
5454
|
+
|
|
5455
|
+
var fontDict = this._root.data.AcroForm.data.DR.Font;
|
|
5456
|
+
Object.keys(this._acroform.fonts).forEach(function (name) {
|
|
5457
|
+
fontDict[name] = _this._acroform.fonts[name];
|
|
5458
|
+
});
|
|
5459
|
+
|
|
5460
|
+
this._root.data.AcroForm.data.Fields.forEach(function (fieldRef) {
|
|
5461
|
+
_this._endChild(fieldRef);
|
|
5462
|
+
});
|
|
5463
|
+
|
|
5464
|
+
this._root.data.AcroForm.end();
|
|
5465
|
+
}
|
|
5466
|
+
|
|
5467
|
+
return this;
|
|
5468
|
+
},
|
|
5469
|
+
_endChild: function _endChild(ref) {
|
|
5470
|
+
var _this2 = this;
|
|
5471
|
+
|
|
5472
|
+
if (Array.isArray(ref.data.Kids)) {
|
|
5473
|
+
ref.data.Kids.forEach(function (childRef) {
|
|
5474
|
+
_this2._endChild(childRef);
|
|
5475
|
+
});
|
|
5476
|
+
ref.end();
|
|
5477
|
+
}
|
|
5478
|
+
|
|
5479
|
+
return this;
|
|
5480
|
+
},
|
|
5481
|
+
|
|
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
|
|
5488
|
+
*/
|
|
5489
|
+
formField: function formField(name) {
|
|
5490
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5491
|
+
|
|
5492
|
+
var fieldDict = this._fieldDict(name, null, options);
|
|
5493
|
+
|
|
5494
|
+
var fieldRef = this.ref(fieldDict);
|
|
5495
|
+
|
|
5496
|
+
this._addToParent(fieldRef);
|
|
5497
|
+
|
|
5498
|
+
return fieldRef;
|
|
5499
|
+
},
|
|
5500
|
+
|
|
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
|
|
5511
|
+
*/
|
|
5512
|
+
formAnnotation: function formAnnotation(name, type, x, y, w, h) {
|
|
5513
|
+
var options = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
|
|
5514
|
+
|
|
5515
|
+
var fieldDict = this._fieldDict(name, type, options);
|
|
5516
|
+
|
|
5517
|
+
fieldDict.Subtype = 'Widget';
|
|
5518
|
+
|
|
5519
|
+
if (fieldDict.F === undefined) {
|
|
5520
|
+
fieldDict.F = 4; // print the annotation
|
|
5521
|
+
} // Add Field annot to page, and get it's ref
|
|
5522
|
+
|
|
5523
|
+
|
|
5524
|
+
this.annotate(x, y, w, h, fieldDict);
|
|
5525
|
+
var annotRef = this.page.annotations[this.page.annotations.length - 1];
|
|
5526
|
+
return this._addToParent(annotRef);
|
|
5527
|
+
},
|
|
5528
|
+
formText: function formText(name, x, y, w, h) {
|
|
5529
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
5530
|
+
return this.formAnnotation(name, 'text', x, y, w, h, options);
|
|
5531
|
+
},
|
|
5532
|
+
formPushButton: function formPushButton(name, x, y, w, h) {
|
|
5533
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
5534
|
+
return this.formAnnotation(name, 'pushButton', x, y, w, h, options);
|
|
5535
|
+
},
|
|
5536
|
+
formCombo: function formCombo(name, x, y, w, h) {
|
|
5537
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
5538
|
+
return this.formAnnotation(name, 'combo', x, y, w, h, options);
|
|
5539
|
+
},
|
|
5540
|
+
formList: function formList(name, x, y, w, h) {
|
|
5541
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
5542
|
+
return this.formAnnotation(name, 'list', x, y, w, h, options);
|
|
5543
|
+
},
|
|
5544
|
+
formRadioButton: function formRadioButton(name, x, y, w, h) {
|
|
5545
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
5546
|
+
return this.formAnnotation(name, 'radioButton', x, y, w, h, options);
|
|
5547
|
+
},
|
|
5548
|
+
formCheckbox: function formCheckbox(name, x, y, w, h) {
|
|
5549
|
+
var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
5550
|
+
return this.formAnnotation(name, 'checkbox', x, y, w, h, options);
|
|
5551
|
+
},
|
|
5552
|
+
_addToParent: function _addToParent(fieldRef) {
|
|
5553
|
+
var parent = fieldRef.data.Parent;
|
|
5554
|
+
|
|
5555
|
+
if (parent) {
|
|
5556
|
+
if (!parent.data.Kids) {
|
|
5557
|
+
parent.data.Kids = [];
|
|
5558
|
+
}
|
|
5559
|
+
|
|
5560
|
+
parent.data.Kids.push(fieldRef);
|
|
5561
|
+
} else {
|
|
5562
|
+
this._root.data.AcroForm.data.Fields.push(fieldRef);
|
|
5563
|
+
}
|
|
5564
|
+
|
|
5565
|
+
return this;
|
|
5566
|
+
},
|
|
5567
|
+
_fieldDict: function _fieldDict(name, type) {
|
|
5568
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
5569
|
+
|
|
5570
|
+
if (!this._acroform) {
|
|
5571
|
+
throw new Error('Call document.initForms() method before adding form elements to document');
|
|
5572
|
+
}
|
|
5573
|
+
|
|
5574
|
+
var opts = Object.assign({}, options);
|
|
5575
|
+
|
|
5576
|
+
if (type !== null) {
|
|
5577
|
+
opts = this._resolveType(type, options);
|
|
5578
|
+
}
|
|
5579
|
+
|
|
5580
|
+
opts = this._resolveFlags(opts);
|
|
5581
|
+
opts = this._resolveJustify(opts);
|
|
5582
|
+
opts = this._resolveFont(opts);
|
|
5583
|
+
opts = this._resolveStrings(opts);
|
|
5584
|
+
opts = this._resolveColors(opts);
|
|
5585
|
+
opts = this._resolveFormat(opts);
|
|
5586
|
+
opts.T = new String(name);
|
|
5587
|
+
|
|
5588
|
+
if (opts.parent) {
|
|
5589
|
+
opts.Parent = opts.parent;
|
|
5590
|
+
delete opts.parent;
|
|
5591
|
+
}
|
|
5592
|
+
|
|
5593
|
+
return opts;
|
|
5594
|
+
},
|
|
5595
|
+
_resolveType: function _resolveType(type, opts) {
|
|
5596
|
+
if (type === 'text') {
|
|
5597
|
+
opts.FT = 'Tx';
|
|
5598
|
+
} else if (type === 'pushButton') {
|
|
5599
|
+
opts.FT = 'Btn';
|
|
5600
|
+
opts.pushButton = true;
|
|
5601
|
+
} else if (type === 'radioButton') {
|
|
5602
|
+
opts.FT = 'Btn';
|
|
5603
|
+
opts.radioButton = true;
|
|
5604
|
+
} else if (type === 'checkbox') {
|
|
5605
|
+
opts.FT = 'Btn';
|
|
5606
|
+
} else if (type === 'combo') {
|
|
5607
|
+
opts.FT = 'Ch';
|
|
5608
|
+
opts.combo = true;
|
|
5609
|
+
} else if (type === 'list') {
|
|
5610
|
+
opts.FT = 'Ch';
|
|
5611
|
+
} else {
|
|
5612
|
+
throw new Error("Invalid form annotation type '".concat(type, "'"));
|
|
5613
|
+
}
|
|
5614
|
+
|
|
5615
|
+
return opts;
|
|
5616
|
+
},
|
|
5617
|
+
_resolveFormat: function _resolveFormat(opts) {
|
|
5618
|
+
var f = opts.format;
|
|
5619
|
+
|
|
5620
|
+
if (f && f.type) {
|
|
5621
|
+
var fnKeystroke;
|
|
5622
|
+
var fnFormat;
|
|
5623
|
+
var params = '';
|
|
5624
|
+
|
|
5625
|
+
if (FORMAT_SPECIAL[f.type] !== undefined) {
|
|
5626
|
+
fnKeystroke = "AFSpecial_Keystroke";
|
|
5627
|
+
fnFormat = "AFSpecial_Format";
|
|
5628
|
+
params = FORMAT_SPECIAL[f.type];
|
|
5629
|
+
} else {
|
|
5630
|
+
var format = f.type.charAt(0).toUpperCase() + f.type.slice(1);
|
|
5631
|
+
fnKeystroke = "AF".concat(format, "_Keystroke");
|
|
5632
|
+
fnFormat = "AF".concat(format, "_Format");
|
|
5633
|
+
|
|
5634
|
+
if (f.type === 'date') {
|
|
5635
|
+
fnKeystroke += 'Ex';
|
|
5636
|
+
params = String(f.param);
|
|
5637
|
+
} else if (f.type === 'time') {
|
|
5638
|
+
params = String(f.param);
|
|
5639
|
+
} else if (f.type === 'number') {
|
|
5640
|
+
var p = Object.assign({}, FORMAT_DEFAULT.number, f);
|
|
5641
|
+
params = String([String(p.nDec), p.sepComma ? '0' : '1', '"' + p.negStyle + '"', 'null', '"' + p.currency + '"', String(p.currencyPrepend)].join(','));
|
|
5642
|
+
} else if (f.type === 'percent') {
|
|
5643
|
+
var _p = Object.assign({}, FORMAT_DEFAULT.percent, f);
|
|
5644
|
+
|
|
5645
|
+
params = String([String(_p.nDec), _p.sepComma ? '0' : '1'].join(','));
|
|
5646
|
+
}
|
|
5647
|
+
}
|
|
5648
|
+
|
|
5649
|
+
opts.AA = opts.AA ? opts.AA : {};
|
|
5650
|
+
opts.AA.K = {
|
|
5651
|
+
S: 'JavaScript',
|
|
5652
|
+
JS: new String("".concat(fnKeystroke, "(").concat(params, ");"))
|
|
5653
|
+
};
|
|
5654
|
+
opts.AA.F = {
|
|
5655
|
+
S: 'JavaScript',
|
|
5656
|
+
JS: new String("".concat(fnFormat, "(").concat(params, ");"))
|
|
5657
|
+
};
|
|
5658
|
+
}
|
|
5659
|
+
|
|
5660
|
+
delete opts.format;
|
|
5661
|
+
return opts;
|
|
5662
|
+
},
|
|
5663
|
+
_resolveColors: function _resolveColors(opts) {
|
|
5664
|
+
var color = this._normalizeColor(opts.backgroundColor);
|
|
5665
|
+
|
|
5666
|
+
if (color) {
|
|
5667
|
+
if (!opts.MK) {
|
|
5668
|
+
opts.MK = {};
|
|
5669
|
+
}
|
|
5670
|
+
|
|
5671
|
+
opts.MK.BG = color;
|
|
5672
|
+
}
|
|
5673
|
+
|
|
5674
|
+
color = this._normalizeColor(opts.borderColor);
|
|
5675
|
+
|
|
5676
|
+
if (color) {
|
|
5677
|
+
if (!opts.MK) {
|
|
5678
|
+
opts.MK = {};
|
|
5679
|
+
}
|
|
5680
|
+
|
|
5681
|
+
opts.MK.BC = color;
|
|
5682
|
+
}
|
|
5683
|
+
|
|
5684
|
+
delete opts.backgroundColor;
|
|
5685
|
+
delete opts.borderColor;
|
|
5686
|
+
return opts;
|
|
5687
|
+
},
|
|
5688
|
+
_resolveFlags: function _resolveFlags(options) {
|
|
5689
|
+
var result = 0;
|
|
5690
|
+
Object.keys(options).forEach(function (key) {
|
|
5691
|
+
if (FIELD_FLAGS[key]) {
|
|
5692
|
+
result |= FIELD_FLAGS[key];
|
|
5693
|
+
delete options[key];
|
|
5694
|
+
}
|
|
5695
|
+
});
|
|
5696
|
+
|
|
5697
|
+
if (result !== 0) {
|
|
5698
|
+
options.Ff = options.Ff ? options.Ff : 0;
|
|
5699
|
+
options.Ff |= result;
|
|
5700
|
+
}
|
|
5701
|
+
|
|
5702
|
+
return options;
|
|
5703
|
+
},
|
|
5704
|
+
_resolveJustify: function _resolveJustify(options) {
|
|
5705
|
+
var result = 0;
|
|
5706
|
+
|
|
5707
|
+
if (options.align !== undefined) {
|
|
5708
|
+
if (typeof FIELD_JUSTIFY[options.align] === 'number') {
|
|
5709
|
+
result = FIELD_JUSTIFY[options.align];
|
|
5710
|
+
}
|
|
5711
|
+
|
|
5712
|
+
delete options.align;
|
|
5713
|
+
}
|
|
5714
|
+
|
|
5715
|
+
if (result !== 0) {
|
|
5716
|
+
options.Q = result; // default
|
|
5717
|
+
}
|
|
5718
|
+
|
|
5719
|
+
return options;
|
|
5720
|
+
},
|
|
5721
|
+
_resolveFont: function _resolveFont(options) {
|
|
5722
|
+
// add current font to document-level AcroForm dict if necessary
|
|
5723
|
+
if (this._acroform.fonts[this._font.id] === null) {
|
|
5724
|
+
this._acroform.fonts[this._font.id] = this._font.ref();
|
|
5725
|
+
} // add current font to field's resource dict (RD) if not the default acroform font
|
|
5726
|
+
|
|
5727
|
+
|
|
5728
|
+
if (this._acroform.defaultFont !== this._font.name) {
|
|
5729
|
+
options.DR = {
|
|
5730
|
+
Font: {}
|
|
5731
|
+
};
|
|
5732
|
+
options.DR.Font[this._font.id] = this._font.ref();
|
|
5733
|
+
options.DA = new String("/".concat(this._font.id, " 0 Tf 0 g"));
|
|
5734
|
+
}
|
|
5735
|
+
|
|
5736
|
+
return options;
|
|
5737
|
+
},
|
|
5738
|
+
_resolveStrings: function _resolveStrings(options) {
|
|
5739
|
+
var select = [];
|
|
5740
|
+
|
|
5741
|
+
function appendChoices(a) {
|
|
5742
|
+
if (Array.isArray(a)) {
|
|
5743
|
+
for (var idx = 0; idx < a.length; idx++) {
|
|
5744
|
+
if (typeof a[idx] === 'string') {
|
|
5745
|
+
select.push(new String(a[idx]));
|
|
5746
|
+
} else {
|
|
5747
|
+
select.push(a[idx]);
|
|
5748
|
+
}
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5751
|
+
}
|
|
5752
|
+
|
|
5753
|
+
appendChoices(options.Opt);
|
|
5754
|
+
|
|
5755
|
+
if (options.select) {
|
|
5756
|
+
appendChoices(options.select);
|
|
5757
|
+
delete options.select;
|
|
5758
|
+
}
|
|
5759
|
+
|
|
5760
|
+
if (select.length) {
|
|
5761
|
+
options.Opt = select;
|
|
5762
|
+
}
|
|
5763
|
+
|
|
5764
|
+
if (options.value || options.defaultValue) ;
|
|
5765
|
+
|
|
5766
|
+
Object.keys(VALUE_MAP).forEach(function (key) {
|
|
5767
|
+
if (options[key] !== undefined) {
|
|
5768
|
+
options[VALUE_MAP[key]] = options[key];
|
|
5769
|
+
delete options[key];
|
|
5770
|
+
}
|
|
5771
|
+
});
|
|
5772
|
+
['V', 'DV'].forEach(function (key) {
|
|
5773
|
+
if (typeof options[key] === 'string') {
|
|
5774
|
+
options[key] = new String(options[key]);
|
|
5775
|
+
}
|
|
5776
|
+
});
|
|
5777
|
+
|
|
5778
|
+
if (options.MK && options.MK.CA) {
|
|
5779
|
+
options.MK.CA = new String(options.MK.CA);
|
|
5780
|
+
}
|
|
5781
|
+
|
|
5782
|
+
if (options.label) {
|
|
5783
|
+
options.MK = options.MK ? options.MK : {};
|
|
5784
|
+
options.MK.CA = new String(options.label);
|
|
5785
|
+
delete options.label;
|
|
5786
|
+
}
|
|
5787
|
+
|
|
5788
|
+
return options;
|
|
5789
|
+
}
|
|
5790
|
+
};
|
|
5791
|
+
|
|
5331
5792
|
var PDFDocument =
|
|
5332
5793
|
/*#__PURE__*/
|
|
5333
5794
|
function (_stream$Readable) {
|
|
@@ -5540,6 +6001,20 @@ function (_stream$Readable) {
|
|
|
5540
6001
|
|
|
5541
6002
|
this._root.data.Names.data.Dests.add(name, args);
|
|
5542
6003
|
}
|
|
6004
|
+
}, {
|
|
6005
|
+
key: "addNamedJavaScript",
|
|
6006
|
+
value: function addNamedJavaScript(name, js) {
|
|
6007
|
+
if (!this._root.data.Names.data.JavaScript) {
|
|
6008
|
+
this._root.data.Names.data.JavaScript = new PDFNameTree();
|
|
6009
|
+
}
|
|
6010
|
+
|
|
6011
|
+
var data = {
|
|
6012
|
+
JS: new String(js),
|
|
6013
|
+
S: 'JavaScript'
|
|
6014
|
+
};
|
|
6015
|
+
|
|
6016
|
+
this._root.data.Names.data.JavaScript.add(name, data);
|
|
6017
|
+
}
|
|
5543
6018
|
}, {
|
|
5544
6019
|
key: "ref",
|
|
5545
6020
|
value: function ref(data) {
|
|
@@ -5625,6 +6100,8 @@ function (_stream$Readable) {
|
|
|
5625
6100
|
|
|
5626
6101
|
this._root.data.Names.end();
|
|
5627
6102
|
|
|
6103
|
+
this.endAcroForm();
|
|
6104
|
+
|
|
5628
6105
|
if (this._security) {
|
|
5629
6106
|
this._security.end();
|
|
5630
6107
|
}
|
|
@@ -5719,6 +6196,7 @@ mixin(TextMixin);
|
|
|
5719
6196
|
mixin(ImagesMixin);
|
|
5720
6197
|
mixin(AnnotationsMixin);
|
|
5721
6198
|
mixin(OutlineMixin);
|
|
6199
|
+
mixin(AcroFormMixin);
|
|
5722
6200
|
|
|
5723
6201
|
export default PDFDocument;
|
|
5724
6202
|
//# sourceMappingURL=pdfkit.es5.js.map
|