pdfkit 0.17.1 → 0.17.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 +4 -0
- package/js/pdfkit.es.js +18 -20
- package/js/pdfkit.es.js.map +1 -1
- package/js/pdfkit.js +18 -20
- package/js/pdfkit.js.map +1 -1
- package/js/pdfkit.standalone.js +316 -133
- package/jsconfig.json +13 -0
- package/package.json +1 -1
- package/types/jest.custom-matchers.d.ts +28 -0
package/js/pdfkit.js
CHANGED
|
@@ -2956,12 +2956,14 @@ class LineWrapper extends events.EventEmitter {
|
|
|
2956
2956
|
}
|
|
2957
2957
|
emitLine();
|
|
2958
2958
|
if (PDFNumber(this.document.y + lh) > this.maxY) {
|
|
2959
|
+
this.emit('sectionEnd', options, this);
|
|
2959
2960
|
const shouldContinue = this.nextSection();
|
|
2960
2961
|
if (!shouldContinue) {
|
|
2961
2962
|
wc = 0;
|
|
2962
2963
|
buffer = '';
|
|
2963
2964
|
return false;
|
|
2964
2965
|
}
|
|
2966
|
+
this.emit('sectionStart', options, this);
|
|
2965
2967
|
}
|
|
2966
2968
|
if (bk.required) {
|
|
2967
2969
|
this.spaceLeft = this.lineWidth;
|
|
@@ -2994,7 +2996,6 @@ class LineWrapper extends events.EventEmitter {
|
|
|
2994
2996
|
}
|
|
2995
2997
|
}
|
|
2996
2998
|
nextSection(options) {
|
|
2997
|
-
this.emit('sectionEnd', options, this);
|
|
2998
2999
|
if (++this.column > this.columns) {
|
|
2999
3000
|
if (this.height != null) {
|
|
3000
3001
|
return false;
|
|
@@ -3013,7 +3014,6 @@ class LineWrapper extends events.EventEmitter {
|
|
|
3013
3014
|
this.document.y = this.startY;
|
|
3014
3015
|
this.emit('columnBreak', options, this);
|
|
3015
3016
|
}
|
|
3016
|
-
this.emit('sectionStart', options, this);
|
|
3017
3017
|
return true;
|
|
3018
3018
|
}
|
|
3019
3019
|
}
|
|
@@ -3021,6 +3021,15 @@ class LineWrapper extends events.EventEmitter {
|
|
|
3021
3021
|
const {
|
|
3022
3022
|
number
|
|
3023
3023
|
} = PDFObject;
|
|
3024
|
+
function formatListLabel(n, listType) {
|
|
3025
|
+
if (listType === 'numbered') {
|
|
3026
|
+
return `${n}.`;
|
|
3027
|
+
}
|
|
3028
|
+
var letter = String.fromCharCode((n - 1) % 26 + 65);
|
|
3029
|
+
var times = Math.floor((n - 1) / 26 + 1);
|
|
3030
|
+
var text = Array(times + 1).join(letter);
|
|
3031
|
+
return `${text}.`;
|
|
3032
|
+
}
|
|
3024
3033
|
var TextMixin = {
|
|
3025
3034
|
initText() {
|
|
3026
3035
|
this._line = this._line.bind(this);
|
|
@@ -3197,7 +3206,7 @@ var TextMixin = {
|
|
|
3197
3206
|
this.y = y;
|
|
3198
3207
|
return height;
|
|
3199
3208
|
},
|
|
3200
|
-
list(list, x, y, options
|
|
3209
|
+
list(list, x, y, options) {
|
|
3201
3210
|
options = this._initOptions(x, y, options);
|
|
3202
3211
|
const listType = options.listType || 'bullet';
|
|
3203
3212
|
const unit = Math.round(this._font.ascender / 1000 * this._fontSize);
|
|
@@ -3227,19 +3236,8 @@ var TextMixin = {
|
|
|
3227
3236
|
}
|
|
3228
3237
|
};
|
|
3229
3238
|
flatten(list);
|
|
3230
|
-
const label = function (n) {
|
|
3231
|
-
switch (listType) {
|
|
3232
|
-
case 'numbered':
|
|
3233
|
-
return `${n}.`;
|
|
3234
|
-
case 'lettered':
|
|
3235
|
-
var letter = String.fromCharCode((n - 1) % 26 + 65);
|
|
3236
|
-
var times = Math.floor((n - 1) / 26 + 1);
|
|
3237
|
-
var text = Array(times + 1).join(letter);
|
|
3238
|
-
return `${text}.`;
|
|
3239
|
-
}
|
|
3240
|
-
};
|
|
3241
3239
|
const drawListItem = function (listItem, i) {
|
|
3242
|
-
wrapper = new LineWrapper(this, options);
|
|
3240
|
+
const wrapper = new LineWrapper(this, options);
|
|
3243
3241
|
wrapper.on('line', this._line);
|
|
3244
3242
|
level = 1;
|
|
3245
3243
|
wrapper.once('firstLine', () => {
|
|
@@ -3274,7 +3272,7 @@ var TextMixin = {
|
|
|
3274
3272
|
break;
|
|
3275
3273
|
case 'numbered':
|
|
3276
3274
|
case 'lettered':
|
|
3277
|
-
var text =
|
|
3275
|
+
var text = formatListLabel(numbers[i - 1], listType);
|
|
3278
3276
|
this._fragment(text, this.x - indent, this.y, options);
|
|
3279
3277
|
break;
|
|
3280
3278
|
}
|
|
@@ -3342,11 +3340,11 @@ var TextMixin = {
|
|
|
3342
3340
|
},
|
|
3343
3341
|
_line(text, options = {}, wrapper) {
|
|
3344
3342
|
this._fragment(text, this.x, this.y, options);
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
this.x += this.widthOfString(text, options);
|
|
3348
|
-
} else {
|
|
3343
|
+
if (wrapper) {
|
|
3344
|
+
const lineGap = options.lineGap || this._lineGap || 0;
|
|
3349
3345
|
this.y += this.currentLineHeight(true) + lineGap;
|
|
3346
|
+
} else {
|
|
3347
|
+
this.x += this.widthOfString(text, options);
|
|
3350
3348
|
}
|
|
3351
3349
|
},
|
|
3352
3350
|
_fragment(text, x, y, options) {
|