pdf-lite 1.7.4-alpha.1 → 1.7.4-alpha.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.
@@ -46,7 +46,7 @@ export class PdfDefaultAppearance extends PdfString {
46
46
  return `/${this._fontName} ${this._fontSize} Tf ${this._colorOp}`;
47
47
  }
48
48
  static parse(da) {
49
- const fontMatch = da.match(/\/([\w-]+)\s+([\d.]+)\s+Tf/);
49
+ const fontMatch = da.match(/\/([\S]+)\s+([\d.]+)\s+Tf/);
50
50
  if (!fontMatch)
51
51
  return null;
52
52
  const fontName = fontMatch[1];
@@ -42,7 +42,15 @@ export class PdfFont extends PdfIndirectObject {
42
42
  throw new Error('PdfIndirectObject content must be a PdfDictionary');
43
43
  }
44
44
  this.content = fontObj.content;
45
- this.resourceName = fontObj.reference.key;
45
+ // Preserve resourceName from PdfFont sources; fall back to
46
+ // reference key for raw indirect objects already in a document,
47
+ // and finally generate a fresh name for unassigned objects.
48
+ this.resourceName =
49
+ fontObj instanceof PdfFont
50
+ ? fontObj.resourceName
51
+ : fontObj.objectNumber >= 0
52
+ ? fontObj.reference.key
53
+ : PdfFont.nextResourceName();
46
54
  return;
47
55
  }
48
56
  // Handle string parameter (simple fontName)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pdf-lite",
3
- "version": "1.7.4-alpha.1",
3
+ "version": "1.7.4-alpha.2",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "exports": {