SERVICES
Custom Development Backend & Architecture Service provider analysis Research, analysis & investigationFREE TOOLS
Quote Generator Factur-X Generator SEO Analyzer Dependency Security Checker PDF Comparator PDF / XML ComparatorSERVICES
Custom Development Backend & Architecture Service provider analysis Research, analysis & investigationFREE TOOLS
Quote Generator Factur-X Generator SEO Analyzer Dependency Security Checker PDF Comparator PDF / XML ComparatorPDF / XML Comparator is an open-source tool designed to locally compare data contained in a PDF file and an XML file in order to identify values that are not found in one of the two representations.
PDF / XML Comparator is a local and open-source tool designed to compare data contained in a PDF file and an XML file.
It searches for values in both directions in order to highlight those that are present in one representation but are not found in the other.
The goal is to facilitate an initial human review of both files without relying on an API, external service or artificial intelligence system.
main.py contains the interface and the comparator's main engine
Values detected in the PDF are searched for within the data extracted from the XML file. When a value is not found, it is highlighted for verification.
Values contained in the XML file are also searched for within the text extracted from the PDF.
Different representations of numbers, dates, spaces and non-breaking spaces are taken into account to reduce false differences. The application then separates 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.
Processing is performed locally, without sending files to a third-party service or using an external API, an approach consistent with data security principles.
The repository contains examples in English and French consisting of a PDF file and its associated Factur-X XML file. They can be used to directly test how the comparator works.
This type of comparison can notably facilitate an initial review of the data contained in both representations of a Factur-X electronic invoice .
A highlighted value is not necessarily an error. PDF / XML Comparator is not a compliance validator: it does not verify an invoicing standard, an XSD schema, Schematron rules, PDF/A compliance or the legal or accounting validity of a document.
Its purpose is to highlight differences that may require human verification. A specialized validation tool remains necessary when compliance verification is required.
The demonstration shows the bidirectional data comparison and the identification of values not found in one of the two representations.
▶ Watch the demonstration on YouTube
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 values highlighted in the report.
PDF comparison relies on text that can be extracted from the document. A scanned image-based PDF, a document whose text cannot be extracted or certain complex PDF structures may therefore produce incomplete results.
The comparator searches for the presence of values and equivalent representations, but does not establish a business-level mapping between a specific area of the PDF and a specific XML element.
Was this page useful to you?
Thank you for your feedback.