---
url: https://www.questpdf.com/examples/zugferd.md
---
# Creating ZUGFeRD-Compliant PDF Documents

## Introduction

ZUGFeRD (Zentraler User Guide des Forums elektronische Rechnung Deutschland) is a German standard for electronic invoicing that combines PDF documents with embedded XML data. It allows for both human-readable PDF invoices and machine-readable structured data in a single file, enabling automated processing while maintaining traditional PDF workflow compatibility.

A ZUGFeRD-compliant PDF document must meet the following requirements:

* Be PDF/A-3b compliant
* Include the invoice data as an XML attachment
* Contain specific XMP metadata

::: warning
ZUGFeRD comes in different versions with varying requirements.
This documentation covers ZUGFeRD 2.1, which is based on the UN/CEFACT Cross Industry Invoice (CII) standard.

When implementing ZUGFeRD support, ensure you're using the correct version for your needs and that all components (XML schema, metadata, and PDF/A version) align with that version.
:::

::: tip QUALITY ASSURANCE
The validation process can vary across different tools, often producing different results.

At QuestPDF, as part of our CI/CD pipeline, we use automated document validation with [veraPDF](https://verapdf.org/) (to verify PDF/A-3b compliance) and the [Mustang Project](https://www.mustangproject.org/) (to verify ZUGFeRD compliance).
Both tools are open-source and free to use.

In addition, we periodically perform manual validation using the Adobe Acrobat Pro Preflight tool to further ensure compliance.
:::

## Document Creation

Here's a complete example showing how to create a ZUGFeRD-compliant PDF document:

```csharp
Document
    .Create(document =>
    {
        document.Page(page =>
        {
            page.Content().Text("Your invoice content");
        });
    })
    .WithMetadata(new DocumentMetadata
    {
        Title = "Conformance Test: ZUGFeRD",
        Author = "SampleCompany",
        Subject = "ZUGFeRD Test Document",
        Language = "en-US"
    })
    .WithSettings(new DocumentSettings { PDFA_Conformance = PDFA_Conformance.PDFA_3B }) // PDF/A-3b
    .GeneratePdf("invoice-bbb.pdf");

DocumentOperation
    .LoadFile("invoice.pdf")
    .AddAttachment(new DocumentOperation.DocumentAttachment
    {
        Key = "factur-zugferd",
        FilePath = "resource-factur-x.xml",
        AttachmentName = "factur-x.xml",
        MimeType = "text/xml",
        Description = "Factur-X Invoice",
        Relationship = DocumentOperation.DocumentAttachmentRelationship.Source,
        CreationDate = DateTime.UtcNow,
        ModificationDate = DateTime.UtcNow
    })
    .ExtendMetadata(File.ReadAllText("resource-zugferd-metadata.xml"))
    .Save("zugferd-invoice.pdf");
```

::: tip
Find the full example here: [ZUGFeRD Example](https://github.com/QuestPDF/QuestPDF/tree/main/Source/QuestPDF.ZUGFeRD)
:::
