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/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
+ ### [v0.20.2] - 2026-08-29
6
+
7
+ - Fix bundlers and file tracers packing the ESM copies of the standard font metrics instead of the CommonJS ones the Node build actually loads, which left `Cannot find module` errors for every standard font at runtime, by resolving the internal `#standard-fonts/*` mapping to a single file under all conditions
8
+ - Fix `doc.file()` throwing when the same in-memory attachment is embedded twice under one name, because the creation and modified dates the deduplication check compares are absent for sources that are not read from disk
9
+ - Fix `doc.text()` throwing `unsupported number: NaN` when `lineBreak: false` is combined with `underline`, `strike`, `link` or `goTo`, because the rendered width was computed from the line wrapper's measurements, which are never produced when wrapping is disabled
10
+
11
+ ### [v0.20.1] - 2026-08-23
12
+
13
+ - Add a Node ESM build so `import 'pdfkit'` in Node resolves to the Node build (real file system, native zlib, Node streams, self-registering standard fonts) instead of the browser bundle
14
+
15
+ ### [v0.20.0] - 2026-08-23
16
+
5
17
  - [BREAKING CHANGE] Remove the virtual file system (`pdfkit/virtual-fs`). Browser builds no longer depend on `fs`: use `registerFile` to register `Uint8Array` data under a path, pass a `Uint8Array` or `ArrayBuffer` directly to `registerFont`, `image` and `file`, or pass a data URL directly to `image` and `file`
6
18
  - Add `registerFile(path, data, options)` to globally register in-memory files in Node and browsers, with optional `birthtime` and `ctime` metadata. Passing `undefined` as data unregisters the path
7
19
  - [BREAKING CHANGE] Export `PDFDocument`, `LineWrapper` and `registerFile` as named exports from the main Node and browser entry points while preserving the default `PDFDocument` export
@@ -2222,8 +2222,8 @@ var ColorMixin = {
2222
2222
  }
2223
2223
  const hex = parseInt(color.slice(1), 16);
2224
2224
  color = [hex >> 16, hex >> 8 & 0xff, hex & 0xff];
2225
- } else if (namedColors[color]) {
2226
- color = namedColors[color];
2225
+ } else if (namedColors[color.toLowerCase()]) {
2226
+ color = namedColors[color.toLowerCase()];
2227
2227
  } else if (this.spotColors[color]) {
2228
2228
  return this.spotColors[color];
2229
2229
  }
@@ -4604,7 +4604,9 @@ var TextMixin = {
4604
4604
  }
4605
4605
  dy = dy / 1000 * this._fontSize;
4606
4606
  }
4607
- const renderedWidth = options.textWidth + wordSpacing * (options.wordCount - 1) + characterSpacing * (text.length - 1);
4607
+ const measuredWidth = options.textWidth ?? this.widthOfString(text, options) - characterSpacing * (text.length - 1);
4608
+ const measuredWordCount = options.wordCount ?? (text.trim() ? text.trim().split(/\s+/).length : 0);
4609
+ const renderedWidth = measuredWidth + wordSpacing * (measuredWordCount - 1) + characterSpacing * (text.length - 1);
4608
4610
  if (options.link != null) {
4609
4611
  const linkOptions = {};
4610
4612
  if (this._currentStructureElement && this._currentStructureElement.dictionary.data.S === 'Link') {
@@ -6214,7 +6216,11 @@ var AttachmentsMixin = {
6214
6216
  }
6215
6217
  };
6216
6218
  function isEqual(a, b) {
6217
- 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());
6219
+ 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);
6220
+ }
6221
+ function isSameDate(a, b) {
6222
+ if (a === undefined || b === undefined) return a === b;
6223
+ return a.getTime() === b.getTime();
6218
6224
  }
6219
6225
 
6220
6226
  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.browser.js', document.baseURI).href))).href;