From 6619076a7373fbcab1694646a758c299f7e68720 Mon Sep 17 00:00:00 2001 From: Markus Ylisiurunen Date: Wed, 10 Jul 2024 17:35:10 +0300 Subject: [PATCH] generate the document ID on-demand and not in the class constructor --- packages/pdfkit/src/document.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/pdfkit/src/document.js b/packages/pdfkit/src/document.js index 2333d0f67..b87576bbf 100644 --- a/packages/pdfkit/src/document.js +++ b/packages/pdfkit/src/document.js @@ -115,9 +115,6 @@ class PDFDocument extends stream.Readable { }); } - // Generate file ID - this._id = PDFSecurity.generateFileID(this.info); - // Initialize security settings // this._security = PDFSecurity.create(this, options); @@ -133,6 +130,10 @@ class PDFDocument extends stream.Readable { } } + _id() { + return PDFSecurity.generateFileID(this.info); + } + addPage(options) { // end the current page if needed if (options == null) { @@ -300,11 +301,12 @@ class PDFDocument extends stream.Readable { } // trailer + const id = this._id(); const trailer = { Size: this._offsets.length + 1, Root: this._root, Info: this._info, - ID: [this._id, this._id] + ID: [id, id] }; // if (this._security) {