Factur-X Validation: Bridging the PDF/XML Mismatch Gap
By Sygnet Research, checked before publication

Key takeaways
- No mainstream Factur-X validator compares the visible PDF page against the embedded XML; peppolvalidator.com states plainly that "whether the visible PDF text matches the XML" is not checked, and neither do veraPDF, Mustang or the official Schematron.
- Schema plus Schematron catches arithmetic, not divergence: a file can pass XSD and still book a wrong amount, which is why a structurally perfect file with a grand total 100.00 too high is caught only by the Schematron layer, via BR-CO-15.
- A practical consistency pipeline has five gates: container (PDF/A-3), packaging (filename, /AF, XMP), schema, Schematron, then a semantic diff between XML values and text extracted from the rendered page.
- Setting
/AFRelationship = Alternativeis a legal assertion that both representations carry identical tax content, so if you set it, you need the diff to prove it.
Why doesn't a standard Factur-X validator catch a PDF/XML mismatch?
Because every published validation artefact operates on the XML or the container, never on the rendered page. A Factur-X invoice is considered valid if it is a valid PDF/A-3, has valid XMP, and the embedded XML passes the profile XSD and the profile Schematron. Nothing in that list reads pixels or page text. The same gap shows up one level down in the metadata: the XML's own profile is read separately from the XMP conformance level, and nothing in Mustang's validator compares the two, so BASIC in the XMP on an EN 16931 invoice draws no complaint.
The consequence is a file that is green everywhere and still wrong in production. A buyer's AP system books the XML; a human approver reads the page. If the page says €12,480.00 and the XML says €12,408.00, both parties are satisfied and the dispute surfaces at reconciliation, or at a VAT audit. Tool vendors acknowledge the limit rather than hide it: total and VAT consistency must never be inferred from the visual rendering alone.
Green on every official validator means the file is well formed, not that the two representations say the same thing.
What does AFRelationship=Alternative actually commit you to?
It is a factual claim about your data, enforceable in at least one jurisdiction. The spec assigns meaning to the key: Data when the visual representation carries more invoice data than the XML, Source when the visual representation was produced from the XML, Alternative when the two carry exactly the same invoice content in two forms. For France that choice is open, but for use in Germany the specification makes Alternative mandatory, on legal grounds, because the value asserts that the tax-relevant content of both representations is identical.
Two traps follow. First, libraries default badly: the Python factur-x library defaults to data and quietly downgrades alternative to data only for the two small profiles, so calling it with defaults for an EN 16931 invoice gives a structurally perfect file with the wrong relationship and nothing downstream objects. Second, when PDF and XML are independent inputs, nobody can vouch for the claim: if the PDF is rendered from HTML and the XML embedded separately, neither the vendor nor a validator can tell whether they agree, and Alternative is yours to make true. Historically this has been sloppy even in reference material: the ZUGFeRD 2.1 samples themselves contain a wrong /AFRelationship key, Data instead of the required Alternative or Source.
What are the layers of a Factur-X control pipeline?
Five, run in order, each rejecting for different reasons. The classic three are well documented: check PDF/A-3 conformance, validate the CII XML against the XSD, then check the profile's business rules with Schematron. Add a packaging gate and a page-versus-XML diff and you have something that actually protects the ledger.
| Gate | Checks | Typical tooling | Catches |
|---|---|---|---|
| 1. Container | PDF/A-3 (3a/3b/3u) | veraPDF | outer PDF is PDF/A-1, A-2 or plain PDF |
| 2. Packaging | filename, /AF array, XMP | Mustang, facturx-check | XMP says zugferd-invoice.xml while the embedded file is factur-x.xml |
| 3. Schema | profile XSD | lxml, Saxon | wrong elements, wrong order, wrong data types, with line and column |
| 4. Schematron | BR-, BR-CO-, FX-SCH-A-* | official profile artefacts | 200+ business rules including BR-CO-14 VAT arithmetic and BR-61 IBAN requirements |
| 5. Semantic diff | XML vs rendered page | your own code | the mismatch nobody else tests |
The outer container is PDF/A-3 and a single /EmbeddedFile stream under /Names/EmbeddedFiles holds the XML, with the attachment named factur-x.xml for every profile, listed under /Names/EmbeddedFiles and referenced from the catalog's /AF array. Gate 2 exists because that double declaration is easy to half-implement: the XML must additionally be declared as a regular PDF attachment via /EmbeddedFiles so that tools without associated-file support can process it.
How do you build gate 5, the semantic diff?
Extract the XML, extract the page text, normalise both to a canonical field set, then compare field by field with declared tolerances. Concretely: pull factur-x.xml (or zugferd-invoice.xml, or xrechnung.xml) out of the container, parse the BT values you care about, and render the page to text with a PDF text layer extractor, falling back to OCR only when the page has no text layer. Every Factur-X element maps to one EN 16931 BT or BG identifier, so the BT map is your comparison key, not an ad-hoc dictionary of labels.
Pick a tight field set. BT-1 (invoice number), BT-2 (issue date), BT-5 (currency), seller and buyer identifiers, BT-109 (total without VAT), BT-110 (total VAT), BT-112 (total with VAT), plus per-line quantity, unit price and line amount above BASIC. Compare amounts numerically after stripping thousands separators and normalising the decimal mark; compare dates as dates; compare identifiers after collapsing whitespace. For VAT amounts allow the tolerance the standard itself now allows: Factur-X 1.0.8 introduced rounding tolerances so that small deviations in calculated tax amounts are no longer treated as validation errors. Anything else, especially totals and SIREN/SIRET, should be exact-match or a hard fail.
Field-level comparison is an accuracy-measurement problem, so score it like one: per-field precision and recall on a labelled corpus rather than a single pass/fail rate. Our checklist for evaluating extraction accuracy covers the metric design, and line tables need their own treatment, which is where GriTS and TEDS are more informative than plain string equality.
Which failure modes should your test corpus contain?
At least eight, and most of them are not arithmetic. A useful starting fixture set: a clean EN 16931 file; the BR-CO-15 total defect; an ordinary PDF invoice with no attachment and no Factur-X metadata; an XMP/XML profile disagreement; a filename mismatch; a MINIMUM file (because MINIMUM and BASIC WL carry header data and totals only, with line detail existing solely on the human-readable page, so a parser requiring ram:IncludedSupplyChainTradeLineItem fails on both); a PDF/A-1 container; and one file where XML and page deliberately disagree on BT-112.
Real corpora are messier than you expect. Running a consistency checker over the 36 PDFs in the Mustang project's test resources produced 12 consistent files, 12 with no invoice, 4 with a real inconsistency (missing Factur-X XMP properties, unparseable XMP, a nonsense conformance level, a damaged cross-reference table) and 8 with warnings or notes. Note also that MINIMUM is a deliberate Data case, not a bug: MINIMUM and BASIC WL never carry a complete invoice, so both countries require Data there. Your diff must skip line-level comparison for those profiles instead of flagging every line as missing.
If your validator returns green on a file whose page and XML disagree on the grand total, you do not have a validator, you have a parser.
Where does this sit in a receiving pipeline?
Gate 5 is cheap on the send side and essential on the receive side, where you control neither generator nor profile. Incoming traffic will mix profiles, versions and generators: PDFs come from Mustangproject, the factur-x library, SAP Document Compliance, DATEV, Lexware, Sage, Quadient AP or in-house PDFBox pipelines. Version drift matters too: Factur-X 1.09.2 is applicable as of 1 September 2026, and current validator configurations pin EN16931 1.3.16 and Factur-X 1.09.2 / ZUGFeRD 2.5.2. Pin your artefact versions in CI and treat an artefact bump as a code change.
Policy matters as much as code. Decide in advance whether a diff failure quarantines the invoice, routes it to a human, or accepts the XML and flags the PDF. Mustang's maintainers describe one mode bluntly: automatically reject incomplete, inconsistent or arithmetically incorrect invoices from your vendors. For France, remember that technical conformance is not the end of the story: it proves neither the commercial truthfulness of the invoice nor its delivery, and within the reform it still has to go through the accredited platform. Sygnet works on the extraction side of this problem, reading the visible layer so it can be compared with structured data; the wider French context is covered on our e-invoicing France page, and whether to write the diff yourself is a classic build vs buy call.
FAQ
Can veraPDF check whether the XML matches the PDF?
No. veraPDF validates the container against ISO 19005-3 and reports things like pdfa1a violations when the outer PDF is the wrong PDF/A part. It has no notion of invoice semantics. The recommended split is explicit: a ZUGFeRD-aware invoice validator for the XML and business rules, plus a PDF/A validator such as veraPDF for the document container. Neither half reads the rendered page, so the diff is yours to build.
Should the diff use the PDF text layer or OCR?
Text layer first, OCR as fallback. Factur-X PDFs are generated, not scanned, so a text layer almost always exists and gives exact character data, including the decimal separators you need for amount comparison. OCR introduces digit confusions (8/B, 0/O, 1/7) that will produce false mismatches on totals. Reserve OCR for scanned re-exports, and raise the tolerance threshold accordingly. The tradeoffs between approaches are covered in our OCR vs VLM comparison.
Which profile should we emit for the French mandate?
EN 16931 or above. Only EN 16931 and EXTENDED are legal for France's B2B mandate; everything below fails the CIUS-FR overlay, and many PDF libraries default to MINIMUM or BASIC because those require the least data. If you serve French customers specifically, France publishes EXTENDED-CTC-FR, an EXTENDED variant carrying the extra fields the Plateforme Agréée needs for lifecycle reporting to the DGFiP.
Does passing EN 16931 Schematron mean the invoice is CIUS-FR compliant?
No. The layers are independent. France layers CIUS-FR on top of EN 16931 with extra mandatory fields such as SIRET and French tax codes and stricter cardinalities, and a Factur-X invoice can pass the EN 16931 layer and still fail CIUS. Many public validators also skip it: peppolvalidator lists the French EXTENDED-CTC-FR profile with its BR-FR rules among the things it does not check. Verify which artefact set your tool actually loads.
One email when we publish something worth your time.