pdfkit 0.20.0 → 0.20.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/js/pdfkit.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var module$1 = require('module');
5
6
  var stream = require('stream');
6
7
  var utils = require('@noble/hashes/utils');
7
8
  var zlib$1 = require('zlib');
@@ -2109,8 +2110,8 @@ var ColorMixin = {
2109
2110
  }
2110
2111
  const hex = parseInt(color.slice(1), 16);
2111
2112
  color = [hex >> 16, hex >> 8 & 0xff, hex & 0xff];
2112
- } else if (namedColors[color]) {
2113
- color = namedColors[color];
2113
+ } else if (namedColors[color.toLowerCase()]) {
2114
+ color = namedColors[color.toLowerCase()];
2114
2115
  } else if (this.spotColors[color]) {
2115
2116
  return this.spotColors[color];
2116
2117
  }
@@ -4522,7 +4523,9 @@ var TextMixin = {
4522
4523
  }
4523
4524
  dy = dy / 1000 * this._fontSize;
4524
4525
  }
4525
- const renderedWidth = options.textWidth + wordSpacing * (options.wordCount - 1) + characterSpacing * (text.length - 1);
4526
+ const measuredWidth = options.textWidth ?? this.widthOfString(text, options) - characterSpacing * (text.length - 1);
4527
+ const measuredWordCount = options.wordCount ?? (text.trim() ? text.trim().split(/\s+/).length : 0);
4528
+ const renderedWidth = measuredWidth + wordSpacing * (measuredWordCount - 1) + characterSpacing * (text.length - 1);
4526
4529
  if (options.link != null) {
4527
4530
  const linkOptions = {};
4528
4531
  if (this._currentStructureElement && this._currentStructureElement.dictionary.data.S === 'Link') {
@@ -6132,7 +6135,11 @@ var AttachmentsMixin = {
6132
6135
  }
6133
6136
  };
6134
6137
  function isEqual(a, b) {
6135
- 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());
6138
+ return a.Subtype === b.Subtype && a.Params.CheckSum.toString() === b.Params.CheckSum.toString() && a.Params.Size === b.Params.Size && isSameDate(a.Params.CreationDate, b.Params.CreationDate) && isSameDate(a.Params.ModDate, b.Params.ModDate);
6139
+ }
6140
+ function isSameDate(a, b) {
6141
+ if (a === undefined || b === undefined) return a === b;
6142
+ return a.getTime() === b.getTime();
6136
6143
  }
6137
6144
 
6138
6145
  const ICC_PROFILE_PATH = new URL('./data/sRGB_IEC61966_2_1.icc', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('pdfkit.js', document.baseURI).href))).href;
@@ -7259,21 +7266,22 @@ mixin(AttachmentsMixin);
7259
7266
  mixin(SubsetMixin);
7260
7267
  mixin(TableMixin);
7261
7268
 
7269
+ const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('pdfkit.js', document.baseURI).href)));
7262
7270
  registerStdFontLoaders({
7263
- Courier: () => require('#standard-fonts/Courier'),
7264
- 'Courier-Bold': () => require('#standard-fonts/CourierBold'),
7265
- 'Courier-BoldOblique': () => require('#standard-fonts/CourierBoldOblique'),
7266
- 'Courier-Oblique': () => require('#standard-fonts/CourierOblique'),
7267
- Helvetica: () => require('#standard-fonts/Helvetica'),
7268
- 'Helvetica-Bold': () => require('#standard-fonts/HelveticaBold'),
7269
- 'Helvetica-BoldOblique': () => require('#standard-fonts/HelveticaBoldOblique'),
7270
- 'Helvetica-Oblique': () => require('#standard-fonts/HelveticaOblique'),
7271
- Symbol: () => require('#standard-fonts/Symbol'),
7272
- 'Times-Bold': () => require('#standard-fonts/TimesBold'),
7273
- 'Times-BoldItalic': () => require('#standard-fonts/TimesBoldItalic'),
7274
- 'Times-Italic': () => require('#standard-fonts/TimesItalic'),
7275
- 'Times-Roman': () => require('#standard-fonts/TimesRoman'),
7276
- ZapfDingbats: () => require('#standard-fonts/ZapfDingbats')
7271
+ Courier: () => require$1('#standard-fonts/Courier'),
7272
+ 'Courier-Bold': () => require$1('#standard-fonts/CourierBold'),
7273
+ 'Courier-BoldOblique': () => require$1('#standard-fonts/CourierBoldOblique'),
7274
+ 'Courier-Oblique': () => require$1('#standard-fonts/CourierOblique'),
7275
+ Helvetica: () => require$1('#standard-fonts/Helvetica'),
7276
+ 'Helvetica-Bold': () => require$1('#standard-fonts/HelveticaBold'),
7277
+ 'Helvetica-BoldOblique': () => require$1('#standard-fonts/HelveticaBoldOblique'),
7278
+ 'Helvetica-Oblique': () => require$1('#standard-fonts/HelveticaOblique'),
7279
+ Symbol: () => require$1('#standard-fonts/Symbol'),
7280
+ 'Times-Bold': () => require$1('#standard-fonts/TimesBold'),
7281
+ 'Times-BoldItalic': () => require$1('#standard-fonts/TimesBoldItalic'),
7282
+ 'Times-Italic': () => require$1('#standard-fonts/TimesItalic'),
7283
+ 'Times-Roman': () => require$1('#standard-fonts/TimesRoman'),
7284
+ ZapfDingbats: () => require$1('#standard-fonts/ZapfDingbats')
7277
7285
  });
7278
7286
 
7279
7287
  exports.LineWrapper = LineWrapper;