Application and Comparison
main.py contains the interface and the comparator's main engine
TECHNICAL RESOURCE · OPEN SOURCE
PDF / XML Comparator is an open-source tool that compares data from a PDF file and an XML file locally, helping identify values that cannot be found in one of the two representations.
PDF / XML Comparator is a local, open-source tool designed to compare data contained in a PDF file and an XML file.
It searches for values in both directions to identify those present in one representation but not found in the other.
The goal is to support an initial human review of both files without relying on APIs, external services or artificial intelligence.
PDF / XML Comparator runs directly on your machine. Documents are not sent to an external service.
The tool searches for values in both directions, from PDF to XML and from XML to PDF, highlighting differences that may require human review.
RESOURCE CONTENT
main.py contains the interface and the comparator's main engine
HOW IT WORKS
Values detected in the PDF are searched for in the extracted XML data. When a value cannot be found, it is flagged for further review.
Values contained in the XML file are also searched for in the text extracted from the PDF.
Different representations of numbers, dates, spaces and non-breaking spaces are taken into account to reduce false discrepancies. The application then distinguishes PDF values not found in the XML from XML values not found in the PDF.
The extracted PDF text, XML data and comparison report remain visible in the interface to facilitate human review.
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.
ELECTRONIC INVOICING
The repository includes French and English examples, each containing a PDF file and its associated Factur-X XML file. These can be used to test the comparator directly.
This type of comparison can help with an initial review of the data contained in both representations of a Factur-X electronic invoice.
A flagged value does not necessarily indicate an error. PDF / XML Comparator is not a compliance validator: it does not check invoicing standards, XSD schemas, Schematron rules, PDF/A compliance or the legal or accounting validity of a document.
Its purpose is to highlight differences that may require human review. Specialized validation remains necessary when compliance verification is required.
DEMONSTRATION
Demonstration of a local, bidirectional comparison between a PDF file and its associated Factur-X XML file, identifying values missing from either representation.
GETTING STARTED
The project requires Python 3.
The only external Python dependency currently required
is pypdf.
pip install pypdf
python main.py
In the interface, select the PDF file followed by the XML file, run the comparison and review the flagged values in the report.
OPEN SOURCE
PDF comparison relies on text that can be extracted from the document. Image-based scanned PDFs, documents without extractable text or certain complex PDF structures may produce incomplete results.
The comparator searches for matching values and equivalent representations, but it does not establish a semantic correspondence between a specific PDF field and a specific XML element.
The project is open source under the MIT license.
Was this page helpful?
Thank you for your feedback.