From e48002df757dafc729f27433b35962c089a0cbef Mon Sep 17 00:00:00 2001 From: Sota Hatakeyama Date: Fri, 23 Dec 2022 13:12:02 +0900 Subject: [PATCH 1/7] Fix doc about creation of pdf document --- docs/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_started.md b/docs/getting_started.md index 7a26097e..468721f8 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -14,7 +14,7 @@ in your JavaScript source file and create an instance of the `PDFDocument` class. const PDFDocument = require('pdfkit'); - const doc = new PDFDocument; + const doc = new PDFDocument(); `PDFDocument` instances are readable Node streams. They don't get saved anywhere automatically, but you can call the `pipe` method to send the output of the PDF document to another From 4d6ffc70ee326ff465d81afe5ef53cffbb20a748 Mon Sep 17 00:00:00 2001 From: James Blackburn Date: Mon, 1 Apr 2024 16:40:02 +0100 Subject: [PATCH 2/7] Update webpack complete example link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 10f74396..c197eaf2 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ complex documents with a very small amount of code. For more, see the `demo` fol There are three ways to use PDFKit in the browser: - Use [Browserify](http://browserify.org/). See demo [source code](demo/browser.js) and [build script](https://github.com/foliojs/pdfkit/blob/master/package.json#L56) -- Use [webpack](https://webpack.js.org/). See [complete example](https://github.com/blikblum/pdfkit-webpack-example). +- Use [webpack](https://webpack.js.org/). See [complete example](examples/webpack). - Use prebuilt version. Distributed as `pdfkit.standalone.js` file in the [releases](https://github.com/foliojs/pdfkit/releases) or in the package `js` folder. In addition to PDFKit, you'll need somewhere to stream the output to. HTML5 has a From 76cdedd967aef28eae3072d08d270a92500d1123 Mon Sep 17 00:00:00 2001 From: Andrei Augustin <36695484+andreiaugustin@users.noreply.github.com> Date: Tue, 16 Jul 2024 17:36:34 +0300 Subject: [PATCH 3/7] Update acroform.js Updated error text document.initForms() to document.initForm() as correct method name is initForm() --- lib/mixins/acroform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mixins/acroform.js b/lib/mixins/acroform.js index 9249aa4e..41064eda 100644 --- a/lib/mixins/acroform.js +++ b/lib/mixins/acroform.js @@ -181,7 +181,7 @@ export default { _fieldDict(name, type, options = {}) { if (!this._acroform) { throw new Error( - 'Call document.initForms() method before adding form elements to document' + 'Call document.initForm() method before adding form elements to document' ); } let opts = Object.assign({}, options); From f2e9b168e06537b92ed4cad0685238893826b9fa Mon Sep 17 00:00:00 2001 From: Noah Date: Tue, 13 Aug 2024 16:39:57 -0700 Subject: [PATCH 4/7] Bugfix: File Cache Equality Check Incorrectly Compares Dates (#1544) * refactors to correctly check if dates are equal * Update attachments.js * fixes lint error --------- Co-authored-by: utanapishtim --- lib/mixins/attachments.js | 4 ++-- tests/unit/attachments.spec.js | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/mixins/attachments.js b/lib/mixins/attachments.js index 862fd9a8..412f9563 100644 --- a/lib/mixins/attachments.js +++ b/lib/mixins/attachments.js @@ -109,7 +109,7 @@ function isEqual(a, b) { a.Subtype === b.Subtype && a.Params.CheckSum.toString() === b.Params.CheckSum.toString() && a.Params.Size === b.Params.Size && - a.Params.CreationDate === b.Params.CreationDate && - a.Params.ModDate === b.Params.ModDate + a.Params.CreationDate.getTime() === b.Params.CreationDate.getTime() && + a.Params.ModDate.getTime() === b.Params.ModDate.getTime() ); } diff --git a/tests/unit/attachments.spec.js b/tests/unit/attachments.spec.js index a2386583..86bc8b2a 100644 --- a/tests/unit/attachments.spec.js +++ b/tests/unit/attachments.spec.js @@ -192,6 +192,41 @@ describe('file', () => { (file2.txt) 11 0 R ] >> +>>` + ]); + }); + + test('attach the same file multiple times', () => { + const docData = logData(document); + + document.file(Buffer.from('example text'), { + name: 'file1.txt', + creationDate: date, + modifiedDate: date + }); + document.file(Buffer.from('example text'), { + name: 'file1.txt', + creationDate: new Date(date), + modifiedDate: new Date(date) + }); + document.end(); + + const numFiles = docData.filter((str) => typeof str === 'string' && str.startsWith('<<\n/Type /EmbeddedFile\n')) + + expect(numFiles.length).toEqual(1) + + expect(docData).toContainChunk([ + `2 0 obj`, + `<< +/Dests << + /Names [ +] +>> +/EmbeddedFiles << + /Names [ + (file1.txt) 10 0 R +] +>> >>` ]); }); From 831179e0674076a7b7775991620f26065967b250 Mon Sep 17 00:00:00 2001 From: "Libor M." Date: Tue, 20 Aug 2024 18:25:49 +0200 Subject: [PATCH 5/7] Fix browserify transform sRGB_IEC61966_2_1.icc file --- CHANGELOG.md | 2 ++ lib/mixins/pdfa.js | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 555817ab..535db5b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Unreleased +- Fix browserify transform sRGB_IEC61966_2_1.icc file + ### [v0.15.0] - 2024-03-23 - Add subset for PDF/UA diff --git a/lib/mixins/pdfa.js b/lib/mixins/pdfa.js index f06dfc4a..703560e4 100644 --- a/lib/mixins/pdfa.js +++ b/lib/mixins/pdfa.js @@ -16,11 +16,11 @@ export default { endSubset() { this._addPdfaMetadata(); - this._addColorOutputIntent(`${__dirname}/data/sRGB_IEC61966_2_1.icc`); + this._addColorOutputIntent(); }, - _addColorOutputIntent(pICCPath) { - const iccProfile = fs.readFileSync(pICCPath); + _addColorOutputIntent() { + const iccProfile = fs.readFileSync(`${__dirname}/data/sRGB_IEC61966_2_1.icc`); const colorProfileRef = this.ref({ Length: iccProfile.length, From 5223809602f329eb5756760ea87da9b4d067cbeb Mon Sep 17 00:00:00 2001 From: "Libor M." Date: Wed, 30 Oct 2024 09:24:08 +0100 Subject: [PATCH 6/7] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 535db5b1..bf329695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Unreleased - Fix browserify transform sRGB_IEC61966_2_1.icc file +- Fix time comparison check equality embedded files ### [v0.15.0] - 2024-03-23 From 2554c088ca1824119d77a27944eace83ed54d6b4 Mon Sep 17 00:00:00 2001 From: "Libor M." Date: Wed, 30 Oct 2024 14:31:55 +0100 Subject: [PATCH 7/7] v0.15.1 --- CHANGELOG.md | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf329695..a085df2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,9 @@ ## pdfkit changelog -### Unreleased +### [v0.15.1] - 2024-10-30 - Fix browserify transform sRGB_IEC61966_2_1.icc file -- Fix time comparison check equality embedded files +- Fix time comparison check equality embedded files ### [v0.15.0] - 2024-03-23 diff --git a/package.json b/package.json index 0bbbf212..857e9c4f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "document", "vector" ], - "version": "0.15.0", + "version": "0.15.1", "homepage": "http://pdfkit.org/", "author": { "name": "Devon Govett",