How pdf-diff works
primaryThe tool operates in two main stages:
- Text Comparison: It compares the text layers of two PDFs. It serializes the PDFs into bounding boxes, performs a diff using
fast_diff_match_patch, and identifies changed text hunks. - Visual Rendering: It rasterizes the changed pages into PNG images (using
pdftopng), realigns page coordinates, draws red outlines around the changed text, and crops the image to remove unnecessary margins before stacking the pages into a final output.