A ZUGFeRD file is technically a PDF/A-3 document with an embedded CII XML file. Accordingly, several layers must be checked during validation: is the PDF technically a valid PDF/A-3? Are the XMP metadata correct? Is the XML file embedded and valid? Does the XML profile satisfy the EN 16931 requirements? This guide walks you through all validation steps using free tools.
Overview: What Makes a Valid ZUGFeRD File
- PDF/A-3 conformance: The document must comply with ISO 19005-3 (PDF/A-3) – all fonts embedded, no external dependencies, no JavaScript.
- Correct XMP metadata: The PDF catalog must contain XMP metadata with the correct FacturX conformance level and DocumentType URI.
- Embedded XML file: A file named factur-x.xml (ZUGFeRD 2.x) or ZUGFeRD-invoice.xml (ZUGFeRD 1.0) must be present as PDF attachment.
- AFRelationship attribute: The embedded file must be tagged with AFRelationship = Alternative.
- XML schema conformance: The CII XML file must conform to the schema of the declared profile.
- EN 16931 Schematron (from profile EN 16931 onwards): The CII XML file must pass all EN 16931 business rules.
Step 1: Check PDF/A-3 Conformance with veraPDF
veraPDF (verapdf.org) is the official open-source validator for PDF/A. It is free, available as a desktop application and command-line tool, and supports all PDF/A profiles up to PDF/A-3.
- Download and install veraPDF from verapdf.org.
- Open veraPDF and load the ZUGFeRD file by drag-and-drop or file selection.
- Select as validation profile: PDF/A-3b (for basic conformance) or PDF/A-3u (for Unicode conformance).
- Start validation. veraPDF shows details for each error with page reference and technical description.
- Common errors: Fonts not embedded, missing color profiles (OutputIntent missing), external URL references.
Step 2: Check XMP Metadata
The XMP metadata contain the profile declaration of the ZUGFeRD file. You can extract and read the XMP metadata using Adobe Acrobat (File > Properties > Description > Additional Metadata) or a tool such as ExifTool (exiftool.org). For ZUGFeRD 2.1 EN 16931 the metadata must contain:
- fx:ConformanceLevel: EN 16931
- fx:DocumentType: INVOICE
- fx:DocumentFileName: factur-x.xml
- fx:Version: 1.0 (for Factur-X / ZUGFeRD 2.1)
Step 3: Extract the XML File from the PDF
You must extract the embedded CII XML file before you can validate it. Here is how:
- Adobe Acrobat Reader: View > Show/Hide > Navigation Panes > Attachments > right-click factur-x.xml > Save.
- Foxit Reader: View > Navigation > Attachments > select file > Save.
- Python (pikepdf): import pikepdf; pdf = pikepdf.open('rechnung.pdf'); xml = pdf.attachments['factur-x.xml'].read_bytes().
- Alternatively: Load the ZUGFeRD PDF into our Viewer – it automatically extracts and displays the XML component.
Step 4: Validate CII XML Against EN 16931
The extracted factur-x.xml file must be validated against the CII schema and the EN 16931 Schematron rules. Use one of the following approaches:
- Ecosio Validator (ecosio.com/de/peppol-und-xml-validator): Online validator for ZUGFeRD and XRechnung files, free for individual documents.
- Mustang Project (GitHub: ZUGFeRD/mustangproject): Java-based open-source tool for ZUGFeRD validation and generation.
- KoSIT online validator (validator.kosit.de): For ZUGFeRD XRECHNUNG profile additionally check the CIUS DE rules.
- Our XRechnung Viewer: Supports extraction and validation of the XML component from ZUGFeRD PDFs.
Common ZUGFeRD Validation Errors and Their Solutions
- Wrong filename: The embedded XML file is not named factur-x.xml. Solution: Rename the file correctly before embedding.
- Missing AFRelationship attribute: The attachment dictionary is missing the AFRelationship key with value Alternative. Solution: Configure the PDF creation library.
- Wrong conformance level in XMP: The XMP metadata declare a different profile than the one the XML actually satisfies. Solution: Keep XMP metadata and XML profile consistent.
- PDF is not PDF/A-3: The PDF was created as a normal PDF or PDF/A-1/2. Solution: Switch PDF creation to PDF/A-3.
- XML does not match declared profile: e.g. MINIMUM XMP metadata but EN 16931 mandatory fields are missing in XML. Solution: Use the XML schema for the correct profile.
Check PDF Content and XML Content for Consistency
A frequently overlooked but legally important check: do the amounts, names, and invoice numbers visible in the PDF match the values in the embedded XML file? In case of discrepancies, legally the XML is authoritative (it is the structured, machine-readable document) – but the discrepancy can lead to disputes. Check at minimum: invoice number, total amount, tax amount, and due date.
Integrate ZUGFeRD validation into your outgoing invoice check: every generated ZUGFeRD file should be validated before sending. A one-time validation when introducing a new software version is not enough – updates can change output quality.