ZUGFeRD and PDF/A-3: embedding the XML correctly
By evoicely · Last checked 20 October 2026
A ZUGFeRD or Factur-X invoice is a PDF/A-3 file with the CII XML attached as factur-x.xml, linked to the whole document, plus XMP metadata that announces it.
Concretely: the XML sits in the catalog's /AF array and in the embedded-files name tree, with MIME type text/xml and /AFRelationship /Alternative (for MINIMUM and BASIC WL it's /Data).
The XMP carries fx:DocumentType, fx:DocumentFileName, fx:Version and fx:ConformanceLevel, together with the PDF/A extension schema that declares them.
A file can look perfect in a PDF viewer and still get one of these wrong, so check it with a validator before you send it.
The examples below come from the PDFs evoicely generates, and the checks are ones we ran ourselves.
Why PDF/A-3
PDF/A is the ISO 19005 family of PDF profiles for long-term archiving: every font embedded, colours defined by an output intent, all metadata in XMP, and no encryption, JavaScript or external content. Part 3 (ISO 19005-3:2012, built on PDF 1.7, ISO 32000-1) is the first part that lets you embed any file type, as long as each one is declared as an "associated file". PDF/A-1 doesn't allow embedded files at all, and PDF/A-2 only allows embedded PDF/A files, so neither can carry an XML invoice. That's why the joint Factur-X / ZUGFeRD specification makes PDF/A-3 the container. Rule BR-HYBRID-02 also allows PDF/A-4f (ISO 19005-4, based on PDF 2.0) as an option.
The PDF/A conformance level (3a, 3b or 3u) doesn't matter to the specification. It recommends 3a, the tagged, accessible level, for readers with visual impairments. evoicely's PDFs are PDF/A-3b, the level that guarantees the page renders identically, without the tagging that 3a adds.
In Germany, the XML is the invoice. The specification's rule BR-FX-DE-03 says that when both seller and buyer are in Germany and the XML is valid and can be extracted, the file is a valid e-invoice: PDF/A errors then count only as warnings. The buyer may still ask for a corrected file, so treat PDF/A errors as bugs to fix all the same.
Source for this section and the rest of this page: the Factur-X / ZUGFeRD specification 1.07.2 (ZUGFeRD 2.3.2, FNFE-MPE and FeRD, 15 November 2024), chapter 6 and the BR-HYBRID rules in its annex. Download it from FeRD or FNFE-MPE; the current joint release is Factur-X 1.09.2 / ZUGFeRD 2.5.2. PDF/A rule numbers are from the veraPDF rules for PDF/A-2 and PDF/A-3.
The checklist
Each row is a requirement from the specification or ISO 19005-3, next to what an evoicely PDF actually contains. We read the file's objects with pypdf to fill in the last column.
| Requirement | What the specification says | evoicely's PDF |
|---|---|---|
| Container | PDF/A-3, any level; declared in XMP as pdfaid:part and pdfaid:conformance | PDF 1.7, pdfaid:part="3", pdfaid:conformance="B" |
| Embedded file name | factur-x.xml; xrechnung.xml for the XRECHNUNG profile. Only one invoice XML per PDF | factur-x.xml in both /F and /UF |
| Relationship to the document | Document level: the file specification is referenced from the /AF array in the catalog, not from a page | Catalog /AF |
/AFRelationship | Depends on the profile and country (table below) | /Alternative (EN 16931 profile) |
| MIME type | Always text/xml, as /Subtype of the embedded file stream | /text#2fxml (#2f is the escaped slash) |
/Params | Should include at least /ModDate | /ModDate, /CreationDate, /Size, /CheckSum |
| Name tree | The file must also be in the /Names → /EmbeddedFiles tree, so ordinary PDF tools list it | Yes |
| XMP | The fx properties and the PDF/A extension schema that declares them | Both (shown below) |
| Fonts | All fonts embedded; subsets are fine | Subsets of Schibsted Grotesk, embedded as TrueType |
| Colour | A PDF/A output intent | /GTS_PDFA1 with an sRGB ICC profile |
| Security | No encryption, no DRM, no JavaScript; the trailer must have an /ID | Not encrypted, /ID present |
The embedded file name, by version
The file name is fixed by the specification, and validators find the invoice by it. Older versions used other names, which is why receiving software still looks for all of them:
| Version | Embedded file | XMP namespace (prefix) |
|---|---|---|
| ZUGFeRD 1.0 | ZUGFeRD-invoice.xml | urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0# (zf) |
| ZUGFeRD 2.0 | zugferd-invoice.xml | A ZUGFeRD-specific namespace (zf), still accepted for backward compatibility |
| ZUGFeRD 2.1 and later = Factur-X 1.0 | factur-x.xml | urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0# (fx) |
| XRECHNUNG profile | xrechnung.xml, never factur-x.xml | Same fx namespace, fx:ConformanceLevel XRECHNUNG |
Sources: specification 1.07.2, sections 6.2, 6.3 and 7.7; the 1.0 and 2.0 names and namespaces as implemented in the
Mustang project's exporter.
The 1p0 in the namespace is the version of the extension schema, not of the invoice data, so it doesn't change with each new release of the specification.
Germany accepts ZUGFeRD only from version 2.0.1, so a ZUGFeRD 1.0 file no longer counts as an e-invoice there (see ZUGFeRD profiles explained).
If you generate files today, use factur-x.xml; the German and French versions of the format are the same file (see Factur-X vs ZUGFeRD).
AFRelationship: Alternative, Data or Source
ISO 19005-3 requires every associated file to say how it relates to the PDF (veraPDF rule 6.8-3), but leaves the value to the application. The Factur-X specification (section 6.2.2) defines what each value means for an invoice:
- Alternative: the XML and the visible PDF carry the same invoice content, as two equal representations. The XML is the one meant for machines.
- Source: the visible PDF was generated from the embedded XML.
- Data: the visible PDF contains more invoice information than the XML. That's the case for MINIMUM and BASIC WL, which carry no or few lines.
And then it narrows the choice down by profile:
| Profile | France | Germany |
|---|---|---|
| MINIMUM | Data | Data |
| BASIC WL | Data | Data |
| BASIC | Alternative, Source or Data | Alternative |
| EN 16931 | Alternative, Source or Data | Alternative |
| EXTENDED | Alternative, Source or Data | Alternative |
| XRECHNUNG | not applicable | Alternative |
Germany allows only Alternative, for legal reasons: everything on the visible invoice, including free text, must also be in the XML.
If you sell from Germany or to German customers, /Alternative with the EN 16931 profile is the combination that works in both countries.
The Mustang library makes the same choice: Alternative by default, Data for MINIMUM and BASIC WL.
Validators are lenient here. BR-HYBRID-11, the rule that checks the value against this table, is only a warning.
When we changed the relationship of an evoicely EN 16931 file to /Data as a test, veraPDF 1.30.3 and Mustang 2.26.0 both still reported the file as valid. Check this value yourself.
What the PDF objects look like
This is the embedded file stream from an evoicely PDF, exactly as written. The compressed XML stream that follows it is left out, and so is the checksum value:
10 0 obj
<</Type /EmbeddedFile/Subtype /text#2fxml/Params <</CheckSum <…>/Size 7524/CreationDate (D:20261020124906Z)/ModDate (D:20261020124906Z)>>/Filter /FlateDecode/Length 1547>>
stream
…
The file specification dictionary that points to it sits in a compressed object stream, so here it is as pypdf reads it, laid out by hand:
<< /Type /Filespec
/F (factur-x.xml)
/UF (factur-x.xml)
/Desc (Factur-X/ZUGFeRD invoice data \(EN 16931\))
/AFRelationship /Alternative
/EF << /F 10 0 R >>
>>
The catalog refers to this dictionary from two places: its /AF array, which makes the XML an associated file of the whole document, and the /Names → /EmbeddedFiles, under the name factur-x.xml.
We generate the PDF with WeasyPrint, which writes these objects from one call. Here is evoicely's code, shortened:
attachment = Attachment(string=xml, name="factur-x.xml",
description="Factur-X/ZUGFeRD invoice data (EN 16931)",
relationship="Alternative")
HTML(string=html).write_pdf(pdf_variant="pdf/a-3b", attachments=[attachment],
finisher=fix_xmp_and_af)
The finisher is there because of two details we found while writing this guide, in WeasyPrint 70. Its xmp_metadata option appends your XMP after WeasyPrint's own rdf:RDF block, so the metadata ends up with two of them, and a validator that reads only the first never sees the fx properties or their schema.
It also lists the embedded file twice in the catalog's /AF array. Neither tool complained about either. The finisher runs on the finished PDF objects just before they are written: it puts the fx descriptions inside the one rdf:RDF and removes the duplicate from /AF. If you use another generator, check the XMP and /AF in its output for the same problems.
The XMP metadata
PDF/A requires document metadata in XMP, and the Factur-X specification (section 6.3) adds four properties in its own namespace. They mark the PDF as a Factur-X invoice and say where the XML is:
| Property | Meaning | evoicely's value |
|---|---|---|
fx:DocumentType | Always INVOICE for Factur-X invoices | INVOICE |
fx:DocumentFileName | Must match /F of the file specification | factur-x.xml |
fx:Version | Version of the XML data schema; BR-HYBRID-10 says it should be 1.0 | 1.0 |
fx:ConformanceLevel | The profile: MINIMUM, BASIC WL, BASIC, EN 16931, EXTENDED or XRECHNUNG. Should match the profile in the XML (BR-HYBRID-15) | EN 16931 |
This is the block evoicely writes. The namespace URI must end with #:
<rdf:Description rdf:about="" xmlns:fx="urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#">
<fx:DocumentType>INVOICE</fx:DocumentType>
<fx:DocumentFileName>factur-x.xml</fx:DocumentFileName>
<fx:Version>1.0</fx:Version>
<fx:ConformanceLevel>EN 16931</fx:ConformanceLevel>
</rdf:Description>
That alone isn't enough. PDF/A allows only XMP properties from predefined schemas, or from extension schemas described inside the same metadata (veraPDF rule 6.6.2.3.1).
The fx schema is not predefined, so the PDF must also carry its description. This is the start of the one evoicely writes; the … stands for the other three properties, which follow the same pattern:
<rdf:Description rdf:about="" xmlns:pdfaExtension="http://www.aiim.org/pdfa/ns/extension/"
xmlns:pdfaSchema="http://www.aiim.org/pdfa/ns/schema#" xmlns:pdfaProperty="http://www.aiim.org/pdfa/ns/property#">
<pdfaExtension:schemas><rdf:Bag><rdf:li rdf:parseType="Resource">
<pdfaSchema:schema>Factur-X PDFA Extension Schema</pdfaSchema:schema>
<pdfaSchema:namespaceURI>urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#</pdfaSchema:namespaceURI>
<pdfaSchema:prefix>fx</pdfaSchema:prefix>
<pdfaSchema:property><rdf:Seq>
<rdf:li rdf:parseType="Resource"><pdfaProperty:name>DocumentFileName</pdfaProperty:name>
<pdfaProperty:valueType>Text</pdfaProperty:valueType><pdfaProperty:category>external</pdfaProperty:category>
<pdfaProperty:description>The name of the embedded XML document</pdfaProperty:description></rdf:li>
…
</rdf:Seq></pdfaSchema:property>
</rdf:li></rdf:Bag></pdfaExtension:schemas>
</rdf:Description>
When we removed the extension schema from a test file, veraPDF failed it on rules 6.6.2.3.1-1 and 6.6.2.3.1-2.
Common validation failures
We broke evoicely PDFs on purpose and ran them through veraPDF 1.30.3 and Mustang 2.26.0. Where a message is quoted, it's what the tool printed.
- A plain PDF with an XML attached. If the PDF isn't PDF/A at all, Mustang reports
Not a PDF/A-3andXML could not be extracted. veraPDF falls back to checking PDF/A-1b and lists a page of failures, such as 6.1.3-1 for a missing/IDin the trailer. Fix the generator: most PDF libraries need an explicit PDF/A-3 mode. - No
fxmetadata. The PDF/A part can pass, while Mustang reportsXMP Metadata: ConformanceLevel not found,DocumentType not found,DocumentFileName not foundandVersion not found. veraPDF doesn't notice, because PDF/A doesn't require these properties: only the Factur-X rules do. fxproperties without the extension schema. veraPDF fails the file on 6.6.2.3.1-1 and 6.6.2.3.1-2. Copy the whole extension schema from the specification, not only the four properties.- The wrong file name. With the XML embedded as
invoice.xml, veraPDF and Mustang's PDF/A check still pass, but Mustang reportsXML could not be extracted. BR-HYBRID-13 requires one of the defined names. Name the filefactur-x.xml, and setfx:DocumentFileNameto the same value. - The wrong AFRelationship. As shown above, neither tool flagged
/Dataon an EN 16931 file. Read the value from the file yourself. - Fonts not embedded. This is the classic PDF/A failure, rule 6.2.11.4.1-1: every font used for rendering must be embedded, including the standard fonts such as Helvetica. Use a generator that embeds fonts, and avoid system fonts you can't redistribute.
- Encryption or password protection. Forbidden by PDF/A (rule 6.1.3-2) and by the specification. Don't "protect" an e-invoice. If you need integrity, archive the original file.
- Transparency. PDF/A-1 forbade it, but PDF/A-3 allows transparency when the file has an output intent. A logo with an alpha channel is fine: our test suite renders one into a PDF/A-3b and veraPDF accepts it.
One trap in reading Mustang's report: it has a <summary> for the PDF part, one for the XML part and one at the end. In our test without fx metadata, the PDF summary said invalid while the final summary still said valid.
Check every summary, not only the last one. evoicely's test suite checks the PDF and XML results separately for that reason.
How to check a file
- Look inside. Most PDF viewers show attachments in a side panel. The invoice XML should be listed as
factur-x.xml. To extract it from the command line, use the Mustang CLI:java -jar Mustang-CLI-2.26.0.jar --action extract --source invoice.pdf --out factur-x.xml - Check the PDF/A part with veraPDF, the open-source PDF/A validator developed by the PDF Association and the Open Preservation Foundation. It reads the flavour from the file's metadata; force it with
--flavour 3bif you want to be sure what it tests:verapdf --flavour 3b --format text invoice.pdf - Check the whole hybrid with Mustang. It runs veraPDF, checks the
fxmetadata, extracts the XML and validates it against the schema and the EN 16931 / Factur-X rules:
Read eachjava -jar Mustang-CLI-2.26.0.jar --action validate --source invoice.pdf<summary>, as explained above. - Check the invoice data in your browser. Our free validator takes the PDF, extracts the embedded XML and checks it against the official EN 16931 rules, then shows the invoice in readable form. It doesn't check PDF/A conformance, so use veraPDF or Mustang for that part. Files are processed in memory and never stored.
- Check the profile.
fx:ConformanceLevelin the XMP should match the profile in the XML (BT-24); see ZUGFeRD profiles explained for the identifiers.
Related guides
- ZUGFeRD profiles explained: MINIMUM to EXTENDED and XRECHNUNG, and which count in Germany.
- Factur-X vs ZUGFeRD: one joint standard, two names and version numbers.
- XRechnung vs ZUGFeRD: when a pure XML file is the better choice.
- What is EN 16931?: the standard the embedded XML follows.
Where evoicely fits
evoicely turns your Stripe invoices into ZUGFeRD / Factur-X PDFs with the EN 16931 profile, built as described on this page: PDF/A-3b, factur-x.xml with /AFRelationship /Alternative, and the fx metadata. Our test suite checks them with Mustang, PDF/A included. XRechnung is included too. Get started, free for 10 e-invoices a month.
This is general information, not legal or tax advice. Check what applies to your business with your tax advisor.