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) {