pdfkit 0.15.1 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/js/pdfkit.es.js +15 -6
- package/js/pdfkit.es.js.map +1 -1
- package/js/pdfkit.js +15 -6
- package/js/pdfkit.js.map +1 -1
- package/js/pdfkit.standalone.js +31691 -31680
- package/package.json +1 -1
package/js/pdfkit.js
CHANGED
|
@@ -2718,7 +2718,7 @@ class EmbeddedFont extends PDFFont {
|
|
|
2718
2718
|
} else {
|
|
2719
2719
|
descriptor.data.FontFile2 = fontFile;
|
|
2720
2720
|
}
|
|
2721
|
-
if (this.document.subset) {
|
|
2721
|
+
if (this.document.subset && this.document.subset === 1) {
|
|
2722
2722
|
const CIDSet = Buffer.from('FFFFFFFFC0', 'hex');
|
|
2723
2723
|
const CIDSetRef = this.document.ref();
|
|
2724
2724
|
CIDSetRef.write(CIDSet);
|
|
@@ -3357,11 +3357,10 @@ var TextMixin = {
|
|
|
3357
3357
|
return `${text}.`;
|
|
3358
3358
|
}
|
|
3359
3359
|
};
|
|
3360
|
-
const drawListItem = function (listItem) {
|
|
3360
|
+
const drawListItem = function (listItem, i) {
|
|
3361
3361
|
wrapper = new LineWrapper(this, options);
|
|
3362
3362
|
wrapper.on('line', this._line);
|
|
3363
3363
|
level = 1;
|
|
3364
|
-
let i = 0;
|
|
3365
3364
|
wrapper.once('firstLine', () => {
|
|
3366
3365
|
let item, itemType, labelType, bodyType;
|
|
3367
3366
|
if (options.structParent) {
|
|
@@ -3418,7 +3417,7 @@ var TextMixin = {
|
|
|
3418
3417
|
wrapper.wrap(listItem, options);
|
|
3419
3418
|
};
|
|
3420
3419
|
for (let i = 0; i < items.length; i++) {
|
|
3421
|
-
drawListItem.call(this, items[i]);
|
|
3420
|
+
drawListItem.call(this, items[i], i);
|
|
3422
3421
|
}
|
|
3423
3422
|
return this;
|
|
3424
3423
|
},
|
|
@@ -5032,7 +5031,7 @@ var AcroFormMixin = {
|
|
|
5032
5031
|
},
|
|
5033
5032
|
_resolveFont(options) {
|
|
5034
5033
|
// add current font to document-level AcroForm dict if necessary
|
|
5035
|
-
if (this._acroform.fonts[this._font.id]
|
|
5034
|
+
if (this._acroform.fonts[this._font.id] == null) {
|
|
5036
5035
|
this._acroform.fonts[this._font.id] = this._font.ref();
|
|
5037
5036
|
}
|
|
5038
5037
|
|
|
@@ -5104,10 +5103,12 @@ var AttachmentsMixin = {
|
|
|
5104
5103
|
* * options.hidden: if true, do not add attachment to EmbeddedFiles dictionary. Useful for file attachment annotations
|
|
5105
5104
|
* * options.creationDate: override creation date
|
|
5106
5105
|
* * options.modifiedDate: override modified date
|
|
5106
|
+
* * options.relationship: Relationship between the PDF document and its attached file. Can be 'Alternative', 'Data', 'Source', 'Supplement' or 'Unspecified'.
|
|
5107
5107
|
* @returns filespec reference
|
|
5108
5108
|
*/
|
|
5109
5109
|
file(src, options = {}) {
|
|
5110
5110
|
options.name = options.name || src;
|
|
5111
|
+
options.relationship = options.relationship || 'Unspecified';
|
|
5111
5112
|
const refBody = {
|
|
5112
5113
|
Type: 'EmbeddedFile',
|
|
5113
5114
|
Params: {}
|
|
@@ -5178,6 +5179,7 @@ var AttachmentsMixin = {
|
|
|
5178
5179
|
// add filespec for embedded file
|
|
5179
5180
|
const fileSpecBody = {
|
|
5180
5181
|
Type: 'Filespec',
|
|
5182
|
+
AFRelationship: options.relationship,
|
|
5181
5183
|
F: new String(options.name),
|
|
5182
5184
|
EF: {
|
|
5183
5185
|
F: ref
|
|
@@ -5192,13 +5194,20 @@ var AttachmentsMixin = {
|
|
|
5192
5194
|
if (!options.hidden) {
|
|
5193
5195
|
this.addNamedEmbeddedFile(options.name, filespec);
|
|
5194
5196
|
}
|
|
5197
|
+
|
|
5198
|
+
// Add file to the catalogue to be PDF/A3 compliant
|
|
5199
|
+
if (this._root.data.AF) {
|
|
5200
|
+
this._root.data.AF.push(filespec);
|
|
5201
|
+
} else {
|
|
5202
|
+
this._root.data.AF = [filespec];
|
|
5203
|
+
}
|
|
5195
5204
|
return filespec;
|
|
5196
5205
|
}
|
|
5197
5206
|
};
|
|
5198
5207
|
|
|
5199
5208
|
/** check two embedded file metadata objects for equality */
|
|
5200
5209
|
function isEqual(a, b) {
|
|
5201
|
-
return a.Subtype === b.Subtype && a.Params.CheckSum.toString() === b.Params.CheckSum.toString() && a.Params.Size === b.Params.Size && a.Params.CreationDate.getTime() === b.Params.CreationDate.getTime() && a.Params.ModDate.getTime() === b.Params.ModDate.getTime();
|
|
5210
|
+
return a.Subtype === b.Subtype && a.Params.CheckSum.toString() === b.Params.CheckSum.toString() && a.Params.Size === b.Params.Size && a.Params.CreationDate.getTime() === b.Params.CreationDate.getTime() && (a.Params.ModDate === undefined && b.Params.ModDate === undefined || a.Params.ModDate.getTime() === b.Params.ModDate.getTime());
|
|
5202
5211
|
}
|
|
5203
5212
|
|
|
5204
5213
|
var PDFA = {
|