GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - JoshData/pdf-diff: A PDF comparison utility in Python.

BranchesTags
Open more actions menu

Latest commit

 

History

60 Commits
60 Commits

Folders and files

NameName
Last commit message
Last commit date
pdf_diff
pdf_diff
 
 
.gitignore
.gitignore
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
example.png
example.png
 
 
setup.py
setup.py
 
 

Repository files navigation

pdf-diff

Finds differences between two PDF documents:

  1. Compares the text layers of two PDF documents and outputs the bounding boxes of changed text in JSON.
  2. Rasterizes the changed pages in the PDFs to a PNG and draws red outlines around changed text.

Example Image Output

The script is written in Python 3, and it relies on the pdftotext program.

Requirements

libxml2 >= 2.7.0, libxslt >= 1.1.23, poppler

Requirements installation for Ubuntu:

sudo apt-get install python3-lxml poppler-utils

Requirements installation for OS X:

brew install libxml2 libxslt poppler

Installation

From PyPI:

pip install pdf-diff

From source:

sudo python3 setup.py install

Running

Turn two PDFs into one large PNG image showing the differences:

pdf-diff before.pdf after.pdf > comparison_output.png

Maintainer Notes

To deploy:

python3 -m pip install --user --upgrade setuptools wheel twine
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*

Function flow diagram

compute_changes
│
├── serialize_pdf (called twice)
│    ├── pdf_to_bboxes
│    ├── mark_eol_hyphens
│    │    └── mark_eol_hyphen
│    └── Processes bounding boxes and text
│
├── perform_diff
│    └── Calls external `fast_diff_match_patch`
│
└── process_hunks
     ├── Iterates through diff hunks
     └── mark_difference (called multiple times)

render_changes
│
├── simplify_changes
├── make_pages_images
│    └── pdftopng (converts PDF pages to images)
├── realign_pages
│    ├── Splits pages into sub-pages
│    └── Adjusts box coordinates
├── draw_red_boxes
│    └── Annotates images with rectangles or lines
└── zealous_crop
     └── Crops the image to reduce unnecessary margins

stack_pages
│
└── Combines processed images into a final output

About

A PDF comparison utility in Python.

Resources

Readme
CC0-1.0 license

Contributing

Contributing
Activity

Stars

528 stars

Watchers

12 watching

Forks

77 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.