Application and Comparison
pdf-compare.py contains the PDF comparison logic
TECHNICAL RESOURCE · OPEN SOURCE
PDF Comparator is an open-source tool for comparing the text content of two PDF files locally, making it easy to identify added or removed lines.
PDF Comparator is a local, open-source tool designed to quickly compare the text content of two PDF files.
It extracts text from both documents, applies light normalization and displays the differences detected between the two versions.
The goal is to provide a simple way to identify textual changes in a document without relying on an external platform, API or artificial intelligence system.
PDF Comparator runs directly on your machine. Documents are never sent to an external service.
The analysis focuses exclusively on extractable PDF text. It identifies added or removed lines without comparing the visual layout of the documents.
RESOURCE CONTENT
pdf-compare.py contains the PDF comparison logic
HOW IT WORKS
The pdf-compare.py script extracts the text
from the pages of both PDF files provided when it runs.
Light normalization is then applied before comparing the reference document with its updated version.
Differences are displayed directly in the terminal as added and removed lines.
If no textual differences are detected, the tool simply reports that no changes were found instead of generating an unnecessary report.
All processing takes place locally, without uploading files to a third-party service or using an external API, an approach consistent with data security principles.
DEMONSTRATION
Demonstration of a local comparison between two PDF files, including text extraction and identification of added or removed lines.
GETTING STARTED
The project requires Python 3 and the
pypdf library.
python -m pip install -r requirements.txt
python pdf-compare.py old.pdf new.pdf
The first file is the reference version. The second is the updated version to compare.
OPEN SOURCE
PDF Comparator compares extracted text content. It does not visually compare page rendering, images, fonts, colors or graphical layout.
Comparison quality also depends on the text that can actually be extracted from each PDF. Image-only documents or scanned files without a usable text layer cannot be compared reliably.
The project is open source under the MIT license.
Was this page helpful?
Thank you for your feedback.