ZUGFeRD / Factur-X Electronic Invoices | |
A hybrid electronic invoice is a PDF that a person can read and that also carries the same invoice as machine-readable XML, so the recipient's accounting software can book it without any re-keying. This is what the ZUGFeRD (Germany), Factur-X (France) and XRechnung standards describe - they are the same document format, and SelectPdf produces it with a single call.
Electronic invoice generation is available only in the full commercial SelectPdf library, and requires a PDF/A-3 document. See Accessible PDF and PDF/A for PDF/A generation. |
A hybrid electronic invoice is a PDF/A-3 document that a person can read and that also carries the same invoice as machine-readable XML, so that the recipient's accounting software can book it without any re-keying. This is what the ZUGFeRD (Germany), Factur-X (France) and XRechnung standards describe - they are the same document format, and SelectPdf produces it with a single call.
Create the document with one of the PDF/A-3 standards, then call AddZugferdInvoice(Stream, ZugferdProfile, PdfAttachmentRelationship) with the invoice XML. The XML is embedded and the document metadata is marked so that invoice software recognizes the file. The name of the embedded file is set for you - the standards fix it, and recipients look it up by name.
HtmlToPdf converter = new HtmlToPdf(); // ZUGFeRD / Factur-X requires a PDF/A-3 carrier. PdfA3A additionally makes the // visible invoice accessible, which the standards recommend. converter.Options.RenderingEngine = RenderingEngine.Chromium; converter.Options.PdfStandard = PdfStandard.PdfA3A; converter.Options.Title = "Invoice 2026-0042"; converter.Options.Language = "en-US"; PdfDocument doc = converter.ConvertUrl("https://www.example.com/invoice"); using (FileStream xml = File.OpenRead("invoice-data.xml")) { doc.AddZugferdInvoice(xml, ZugferdProfile.En16931, PdfAttachmentRelationship.Alternative); } doc.Save("invoice-zugferd.pdf"); doc.Close();
ZugferdProfile states how much of the invoice the XML carries - Minimum, BasicWL, Basic, En16931, Extended, or the German public-sector XRechnung reference profile.
PdfAttachmentRelationship states how the XML relates to the page the reader sees. Use Alternative when the two carry exactly the same invoice content - this is mandatory in Germany for the BASIC, EN 16931, EXTENDED and XRECHNUNG profiles. Use Data when the visible page carries more than the XML does (always the case for the MINIMUM and BASIC WL profiles), or Source when the page was generated from the XML.
An overload accepts a ZugferdSchema value. Use it only for recipients that still require the deprecated ZUGFeRD 2.0 metadata; new invoices should use the default. |