π¬π§ English | π«π· FranΓ§ais
A local, open-source tool for comparing data contained in a PDF file and an XML file.
The goal is simple: quickly identify values that are present in one representation but cannot be found in the other, making human review easier.
The program runs entirely locally, with no API, no external service, and no artificial intelligence.
pdf_xml_comparator/
β
βββ main.py β Main application
βββ requirements.txt β Python project dependencies
βββ LICENSE.md β MIT License
β
βββ README.md β English documentation
βββ README_FR.md β French documentation
β
βββ docs/
βββ images/
β βββ Palks_Studio.png β Palks Studio logo
β βββ pdf_xml_comparator.png β PDF / XML Comparator presentation image
β
βββ EN/
β βββ invoice.pdf β English invoice example
β βββ facturx.xml β English Factur-X XML example
β βββ xml_pdf_en.mp4 β English demonstration video
β
βββ FR/
βββ facture.pdf β French invoice example
βββ facturx.xml β French Factur-X XML example
βββ xml_pdf_fr.mp4 β French demonstration video
A PDF and an XML file can represent the same document while containing different information.
A reference may be different, an amount may have been changed, a value may exist only in the XML, or information visible in the PDF may not be found in the XML.
Manually checking both files can quickly become time-consuming.
PDF / XML Comparator automates a first comparison step by identifying potential differences between the two representations.
The program compares the files in both directions:
Values detected in the PDF are searched for in the XML.
If a value from the PDF cannot be found in the XML, it is flagged for review.
Values contained in the XML are searched for in the PDF text.
If an XML value cannot be found in the PDF, it is also flagged for review.
This bidirectional comparison can notably identify situations where a correct value exists somewhere in both files, while another different value appears only in one of the representations.
Some formatting differences are automatically taken into account to reduce false differences.
For example:
1000.00and1 000,0020260724and24/07/2026- spaces and non-breaking spaces
- some equivalent numeric representations
Normalization is intentionally kept lightweight and does not attempt to interpret the business meaning of the data.
After the comparison, the program displays two sections:
PDF VALUES NOT FOUND IN XML
et :
XML VALUES NOT FOUND IN PDF
Identical values reported multiple times on the XML side are deduplicated to make the report easier to read.
The interface also keeps a view of the content extracted from both files: the text detected in the PDF, the data extracted from the XML, and the report of the identified differences.
These three sections allow an initial comparison to be performed directly within the application, without constantly switching between the two files.
For a more detailed review, the original PDF and XML files remain the reference and can of course be opened and examined directly.
A flagged value is not necessarily an error.
The XML may contain technical codes, identifiers, or other information that is not intended to appear textually in the PDF.
Likewise, some information visible in the PDF may be represented differently in the XML.
The program therefore does not determine whether a difference is correct or incorrect.
It simply highlights elements that require human review.
PDF / XML Comparator is not a compliance validator.
It does not check:
- compliance with an invoicing standard
- XSD schemas
- Schematron rules
- PDF/A compliance
- the legal or accounting validity of a document
- the business consistency of a specific field
It does not replace a specialized validation tool.
Its sole purpose is to make data comparison between a PDF and an XML file easier.
The comparator is intentionally not built around a predefined list of business fields.
It does not assume that a particular XML tag represents an amount, an invoice number, a quantity, or any other specific type of data.
This approach keeps the tool simple and generic, without tying the comparison engine to a specific XML structure.
The repository includes two sets of example files that can be used to test the comparator directly.
An English version and a French version are available in the docs/ directory, each including a PDF file, its associated Factur-X XML file, and a short video showing their comparison using the tool.
These files provide a quick way to explore how the comparator works before using it with your own documents.
Python 3 is required to run the program.
pip install pypdf
python main.py
In the interface:
- select the PDF file
- select the XML file
- click
COMPARE PDF / XML - review the flagged values
No data is sent to any external service.
The project mainly uses:
- Python
- Tkinter
- pypdf
- xml.etree.ElementTree
- re
Tkinter, xml.etree.ElementTree, and re are part of the Python standard library.
The only external Python dependency currently required by the project is:
pypdf
The PDF comparison relies on text that can be extracted from the document.
A scanned PDF containing only images, a document with non-extractable text, or certain complex PDF structures may therefore produce incomplete results.
The program searches for the presence of values and equivalent representations, but does not establish business-level mappings between a specific area of the PDF and a specific XML tag.
This limitation is intentional: the tool prefers to flag a value for review rather than infer a correspondence that could be incorrect.
Processing is performed locally on the user's machine.
No external API is used, and no file is sent to any third-party service.
This project is distributed under the MIT License.
Β© Palks Studio β see LICENSE.md
