Products Technologies Demo Docs Blog Support Company

Electronic Invoicing will Become Mandatory in Germany in 2025

The German government has decided to make the ability to receive electronic invoices mandatory for all B2B transactions. This article explains what this means for you and how you can prepare for this change.

Electronic Invoicing will Become Mandatory in Germany in 2025

At the end of March, the German Federal Council (Bundesrat) passed a new law that makes it mandatory for companies to receive electronic invoices. The receipt of electronic invoices will be mandatory for domestic B2B transactions from January 1, 2025. The sending of electronic invoices is also mandatory, but there are exceptions and transitional rules that apply.

In addition to being more environmentally friendly than paper invoices, e-invoicing offers many benefits to businesses. For example, e-invoices can be processed automatically for time and cost savings. Moreover, electronic invoices are easier to archive and retrieve than paper invoices.

Electronic invoices are also safer and more secure than paper invoices. They are protected from unauthorized access and cannot be lost or damaged in the mail. To ensure authenticity and integrity, electronic invoices can also be digitally signed.

Creating Electronic Invoices

Electronic invoices can be created in various formats, such as ZUGFeRD, XRechnung, and Factur-X. These formats are based on the XML standard and can be read and processed by machines. This makes it easier for companies to automate their invoicing processes and reduce the risk of errors.

TX Text Control provides all the basic technologies required to create these PDF documents, as it fully supports PDF/A-3b, the required format for electronic invoices.

XRechnung or ZUGFeRD?

XRechnung is a pure XML format for processing digital invoices. ZUGFeRD combines the human-readable PDF format with a machine-readable XML format. Since the release of ZUGFeRD version 2.1, both the XML resulting from XRechnung and the way the XML is integrated into a PDF file can be combined.

A sample application discussed in another article implements the XRechnung class, which holds all the data needed to create the invoice, and also uses the ZUGFeRD-csharp library to generate the necessary XML.

Learn More

This article shows how to create valid XRechnung and ZUGFeRD invoices with ASP.NET Core C#. The invoice is created with the help MailMerge component and the ZUGFeRD-csharp library.

Creating Valid XRechnung / ZUGFeRD Invoices with ASP.NET Core C#

The following C# code shows how to embed the ZUGFeRD XML in a document and export it to a PDF/A file:

string xmlZugferd = xRechnung.CreateXML();
        
// load Xml file
string metaData = File.ReadAllText("metadata.xml");

TXTextControl.SaveSettings saveSettings = new TXTextControl.SaveSettings();

// create a new embedded file
var zugferdInvoice = new TXTextControl.EmbeddedFile(
   "ZUGFeRD-invoice.xml",
   Encoding.UTF8.GetBytes(xmlZugferd),
   metaData);

zugferdInvoice.Description = "ZUGFeRD-invoice";
zugferdInvoice.Relationship = "Alternative";
zugferdInvoice.MIMEType = "application/xml";
zugferdInvoice.LastModificationDate = DateTime.Now;

// set the embedded files
saveSettings.EmbeddedFiles = new TXTextControl.EmbeddedFile[] { zugferdInvoice };

A template is merged with the XRechnung object to generate the human readable version of the invoice.

using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
{
    tx.Create();
    // load the document
    tx.Load("template.tx", TXTextControl.StreamType.InternalUnicodeFormat);

    // merge the data
    using (MailMerge mm = new MailMerge())
    {
        mm.TextComponent = tx;
        mm.MergeObject(xRechnung);
    }

    // save the document
    tx.Save("test.pdf", TXTextControl.StreamType.AdobePDFA, saveSettings);
}

Opening the created PDF document in Acrobat Reader displays the visual representation and embedded XML in the Attachments pane:

ZUGFeRD XML Attachment

Extracting ZUGFeRD XML from PDF

TX Text Control provides a feature to extract attachments from PDF documents.

The following GetXmlAttachment method uses TX Text Control to load the PDF document using the Load method. The EmbeddedFiles property of the LoadSettings contains an array of EmbeddedFile objects after the PDF is loaded.

private string GetXmlAttachment(string Filename) {

  using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
    tx.Create();

    // load documment
    LoadSettings ls = new TXTextControl.LoadSettings() {
      PDFImportSettings = PDFImportSettings.LoadEmbeddedFiles
    };

    tx.Load(Filename, TXTextControl.StreamType.AdobePDF, ls);

    // all attachments
    var embeddedFiles = ls.EmbeddedFiles;

    // find the "alternative" xml representation
    foreach (EmbeddedFile embeddedFile in embeddedFiles) {

      if (embeddedFile.Relationship == "Alternative" &&
          embeddedFile.MIMEType     == "text/xml") {

        // return converted XML
        return Encoding.UTF8.GetString((byte[])embeddedFile.Data);
      }

    }

    return null; //something went wrong
  }
}

Each attachment is checked against the Relationship and MIMEType requirements to return the associated embedded XML document.

To extract the alternative XML invoice from a PDF/A-3b document, the above method can be called as in the code below:

var xml = GetXmlAttachment("facturx_invoice_pdfa3b_01.pdf");

Free Consulting

Do you have any questions about electronic invoicing or how to create electronic invoices with TX Text Control? Contact us for a free consultation. We are happy to help you with your project.

Contact Us

Conclusion

Electronic invoicing will become mandatory in Germany in 2025. Companies that are not yet prepared for this change should start planning now. TX Text Control provides all the necessary tools to create electronic invoices in various formats, such as ZUGFeRD and XRechnung. With TX Text Control, you can automate your invoicing processes and reduce the risk of errors.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETWindows FormsWPF

Creating ZUGFeRD Compliant PDF Invoices in C#

ZUGFeRD / Factur-X documents can be created and extracted using TX Text Control X19. This article shows how to create a valid ZUGFeRD compliant invoice PDF document from scratch.


ASP.NETWindows FormsElectronic Invoice

X19 Sneak Peek: Validating ZUGFeRD / Factur-X Invoices with TX Text Control

ZUGFeRD / Factur-X documents can be created and extracted using TX Text Control X19. This article shows how to validate these eletronic invoices by matching invoice elements with the visual PDF…


ASP.NETWindows FormsWPF

TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 3 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…


ASP.NETWindows FormsWPF

TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 2 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…


ASP.NETWindows FormsWPF

Document Lifecycle Optimization: Leveraging TX Text Control's Internal Format

Maintaining the integrity and functionality of documents throughout their lifecycle is paramount. TX Text Control provides a robust ecosystem that focuses on preserving documents in their internal…