@libpdf/core 0.2.4 → 0.2.5

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/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ import { createCMSECDSASignature } from "pkijs";
9
9
  import { base64 } from "@scure/base";
10
10
 
11
11
  //#region package.json
12
- var version = "0.2.4";
12
+ var version = "0.2.5";
13
13
 
14
14
  //#endregion
15
15
  //#region src/objects/pdf-array.ts
@@ -26469,7 +26469,15 @@ var PDFPage = class PDFPage {
26469
26469
  return;
26470
26470
  }
26471
26471
  if (existingContents instanceof PdfRef) {
26472
- this.dict.set("Contents", new PdfArray([newContent, existingContents]));
26472
+ const resolved = this.ctx.resolve(existingContents);
26473
+ if (resolved instanceof PdfArray) {
26474
+ const newArray = new PdfArray([newContent]);
26475
+ for (let i = 0; i < resolved.length; i++) {
26476
+ const item = resolved.at(i);
26477
+ if (item) newArray.push(item);
26478
+ }
26479
+ this.dict.set("Contents", newArray);
26480
+ } else this.dict.set("Contents", new PdfArray([newContent, existingContents]));
26473
26481
  this._contentWrapped = true;
26474
26482
  return;
26475
26483
  }
@@ -26506,7 +26514,17 @@ var PDFPage = class PDFPage {
26506
26514
  const qStream = this.createContentStream("q\n");
26507
26515
  const QStream = this.createContentStream("\nQ");
26508
26516
  if (existingContents instanceof PdfRef) {
26509
- this.dict.set("Contents", new PdfArray([
26517
+ const resolved = this.ctx.resolve(existingContents);
26518
+ if (resolved instanceof PdfArray) {
26519
+ const newArray = new PdfArray([qStream]);
26520
+ for (let i = 0; i < resolved.length; i++) {
26521
+ const item = resolved.at(i);
26522
+ if (item) newArray.push(item);
26523
+ }
26524
+ newArray.push(QStream);
26525
+ newArray.push(newContent);
26526
+ this.dict.set("Contents", newArray);
26527
+ } else this.dict.set("Contents", new PdfArray([
26510
26528
  qStream,
26511
26529
  existingContents,
26512
26530
  QStream,