![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@exzeo/pdf-diff
Advanced tools
Compares two PDFs and provides results on how they differ, including a diff image.
npm install exframe-pdf-diff
compare
function takes two PDFs as input and returns a Promise
that is fulfilled with the difference results when the comparison is complete.
const { compare } = require('exframe-pdf-diff');
(async () => {
const result = await compare('./one.pdf', './two.pdf', {
outputDirectory: './output'),
});
console.log(result);
})();
Output:
{
baseline: { pageCount: 2 },
actual: { pageCount: 2 },
diffs: [
{
pageNumber: 1,
numDiffPixels: 32563,
percentDiffPixels: 0.06718120749983494,
diffImageFileName: '/diff_1.png'
},
{
pageNumber: 2,
numDiffPixels: 0,
percentDiffPixels: 0,
diffImageFileName: '/diff_2.png'
}
]
}
chaiPlugin
is a function that can be passed to chai.use for convenient test assertions when verifying PDFs.
const chai = require('chai');
const { expect } = chai;
chai.use(require('exframe-pdf-diff').chaiPlugin);
describe('generated PDF', () => {
it('matches baseline', async () => {
await expect('./new.pdf').to.equalPdf('./baseline.pdf', {
outputDirectory: './output'),
});
});
});
Returns a Promise
that is either fulfilled with the difference results when the comparison is completed successfully, or rejected with an error.
Type: Buffer
| String
| Stream
PDF used in comparison. A provided String
is assumed to be a file name. A Buffer
and Stream
is assumed to contain binary PDF data. Note: Stream input will be read into a memory buffer prior to loading the document.
Type: object
Type: String
Default: '1-'
(all pages)
One or more pages to compare. Accepts a comma-separated list (i.e. '1,3,7'
), a range (i.e. '1-3'
), or combination ('1,5,8-'
).
Type: String
Default: (no output files)
When present, will be used to write files for the following cases:
Type: Boolean
Default: false
When true, all intermediate and diff images will be written to the outputDirectory
for each compared page, regardless of whether they matched.
Note: This option is ignored if outputDirectory
is not set to a valid path.
All input and options for the chai plugin are the same as the compare
function.
FAQs
PDF utilities for comparing PDF files
We found that @exzeo/pdf-diff demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 24 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.