Hybrid invoice
Create a ZUGFeRD invoice
Generate the human-readable invoice and inspect the machine-readable XML embedded in the PDF/A result.
One data modelBuild both representations
The invoice data feeds the visual template and the structured XML.
PDF/A-3
Visual layerMail Merge
Data layerFactur-X XML
RelationshipAlternative
ContainerPDF/A
Machine-readable resultEmbedded invoice XML
The generated alternative representation is shown here after export.
XML
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Combine a visual invoice with structured data
ZUGFeRD invoices are hybrid documents: people read the PDF representation while accounting systems process the embedded XML invoice.
This sample merges invoice data into a visual template, creates standards-oriented invoice XML, embeds it as an alternative representation, and exports the result as PDF/A.
API used
SaveSettings.EmbeddedFiles
Key members
EmbeddedFile and SaveSettings combine a human-readable PDF/A invoice with its machine-readable XML alternative.
var embeddedInvoice = new EmbeddedFile(
"factur-x.xml",
Encoding.UTF8.GetBytes(invoiceXml),
CreateInvoiceMetadata())
{
Relationship = "Alternative",
MIMEType = "application/xml"
};
var settings = new SaveSettings
{
EmbeddedFiles = [embeddedInvoice]
};
textControl.Save(out byte[] pdf, BinaryStreamType.AdobePDFA, settings);
How it works
The controller builds one invoice model, uses it for both mail merge and XML generation, attaches ZUGFeRD-invoice.xml through SaveSettings.EmbeddedFiles, and exports an Adobe PDF/A document.
NuGet packages
TXTextControl.TextControl.Core.SDK
34.0.4
Provides the core document model and server-side document processing APIs.
dotnet add package TXTextControl.TextControl.Core.SDK --version 34.0.4
Displays supported document and PDF formats in the browser.
dotnet add package TXTextControl.Web.DocumentViewer --version 34.2.0
Source files
See the implementation
The complete demo is encapsulated in Demos/Pdf/CreatingPdfs/ZugferdInvoice.