Repository navigation
Semantic PDF Diff
SIDHARTH SINGH edited this page Dec 3, 2026
·
1 revision
Comparing contracts, quotes, or policy drafts with image/pixel diffs breaks whenever a paragraph wraps onto a new page or reflows downward by half an inch. Semantic diffing solves this purely in TypeScript without Poppler or ImageMagick.
- Text Diff: Runs word, character, or line Myers LCS comparisons per page while optionally ignoring whitespace churn.
-
Layout Move Detection: Compares coordinate boxes from
extractPositionedText()so identical blocks shifted beyondmoveThresholdPt(15 ptdefault) report accurately asmoved(blocksMoved) rather than noisy delete+insert pairs. - Resource Diff: Audits structural drift in page counts, embedded font names, image counts, and metadata properties.
import { diffPdfs, buildRedlinePdf } from 'onex-pdf';
const report = diffPdfs(oldPdf, newPdf, {
granularity: 'word',
ignore: { whitespace: true, metadata: true },
});
const redlinePdf = buildRedlinePdf(oldPdf, newPdf);buildRedlinePdf() overlays translucent green boxes onto added spans, red boxes + strikethrough rules onto removed spans, and amber outlines onto moved elements—isolated inside q ... Q graphics blocks with /ExtGState opacity.
- Home
- Architecture & Render Pipeline
- PDF Internals & Extraction
- Unicode 16, Fonts & Legacy Indic
- Security & SSRF Model
- Digital Signing (
signPdf) - True Redaction (
redactPdf) - Semantic Diff & Redlines (
diffPdfs) - Self-Auditing Renders (
renderVerified) - PDF/A-3b & E-Invoices (
renderEInvoice) - HTTP, MCP, CLI & Puppeteer
Handbook & Deep Analysis: bahubalisid.github.io/onex