Skip to content

Commit

Permalink
generate the document ID on-demand and not in the class constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
markusylisiurunen committed Jul 10, 2024
1 parent 3f5bf67 commit 6619076
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/pdfkit/src/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6619076

Please sign in to comment.