Skip to content

Commit

Permalink
Merge branch 'foliojs:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 authored Oct 30, 2024
2 parents a8eef0a + 2554c08 commit b3a057c
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 10 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +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

### [v0.15.0] - 2024-03-23

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,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
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/mixins/acroform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions lib/mixins/attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}
6 changes: 3 additions & 3 deletions lib/mixins/pdfa.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"document",
"vector"
],
"version": "0.15.0",
"version": "0.15.1",
"homepage": "http://pdfkit.org/",
"author": {
"name": "Devon Govett",
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/attachments.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
>>
>>`
]);
});
Expand Down

0 comments on commit b3a057c

Please sign in to comment.