
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@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
The npm package @exzeo/pdf-diff receives a total of 528 weekly downloads. As such, @exzeo/pdf-diff popularity was classified as not popular.
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
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.