# 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 representation of the document.

- **Author:** Bjoern Meyer
- **Published:** 2020-11-10
- **Modified:** 2026-07-17
- **Description:** 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 representation of the document.
- **4 min read** (607 words)
- **Tags:**
  - ASP.NET
  - Electronic Invoice
  - PDF/A
  - Release
  - Windows Forms
  - ZUGFeRD
- **Web URL:** https://www.textcontrol.com/blog/2020/11/10/x19-sneak-peek-validating-zugferd-factur-x-invoices-with-tx-text-control/
- **LLMs URL:** https://www.textcontrol.com/blog/2020/11/10/x19-sneak-peek-validating-zugferd-factur-x-invoices-with-tx-text-control/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2020/11/10/x19-sneak-peek-validating-zugferd-factur-x-invoices-with-tx-text-control/llms-full.txt

---

### ZUGFeRD / Factur-X

The ZUGFeRD / Factur-X standard is a hybrid electronic invoice format that consists of two parts:

- A PDF visual, human-readable representation of the invoice.
- An XML file that contains invoice data in a structured form that can be processed automatically.

TX Text Control X19 supports not only the embedding of attachments in PDF documents (like the XML representation), but also the extraction of the XML attachment. Another new feature in TX Text Control X19 is the possibility to search within PDF text lines in a document.

### Search within PDF Documents

The namespace *TXTextControl.DocumentServer.PDF.Contents* contains the new class *Lines* that can be used to import text coordinates from a PDF document.

```
var clPDFInvoice = new TXTextControl.DocumentServer.PDF.Contents.Lines("ZUGFeRD.pdf");
```

The *Find* method can be used to search for strings and to get information about the location of that string:

```
List<ContentLine> lines = clPDFInvoice.Find("Amount");
var iPageNumber = lines[0].Page;
```

Other implementations of the *Find* method allows to search for a regular expression or to search for lines in a specific range such as a rectangle or a radius. The following code returns all lines within a radius of 200 points around a specific location and includes lines that are partically overlapping the given radius:

```
List<ContentLine> lines = clPDFInvoice.Find(new PointF(100,100), 200, true);
```

![Find strings in PDFs](https://s1-www.textcontrol.com/assets/dist/blog/2020/11/10/a/assets/check.webp "Find strings in PDFs")

### Validating Invoices

Now, let's bring these features together: Importing attachments and searching within the visual representation of the electronic invoice. To make our life easier, we are using a very well maintained NuGet package that implements the ZUGFeRD / Factur-X invoice object.

[ZUGFeRD-csharp](https://www.nuget.org/packages/ZUGFeRD-csharp/)

The following code uses TX Text Control to extract the XML representation of the invoice in order to load it into an *InvoiceDescriptor* object:

```
private InvoiceDescriptor ImportZUGFeRD(string filename) {

  // temporary ServerTextControl to load PDF
  using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) {
    tx.Create();

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

    // load the embedded file into LoadSettings
    tx.Load(filename, TXTextControl.StreamType.AdobePDF, ls);

    // convert the byte[] to a MemoryStream
    byte[] byteArray = (byte[])ls.EmbeddedFiles[0].Data;
    MemoryStream stream = new MemoryStream(byteArray);

    // return the invoice object structure
    return InvoiceDescriptor.Load(stream);
  }
}
```

The method *IsValidZUGFeRD* is searching for 3 key values in the XML representation: Total amount, tax total amount and invoice number. These values are matched within the PDF representation. If those values match, it is highly likely that the invoice is valid. In real-world applications, you would probably connect to your ERP system to retrieve specific information about the invoice number and match more values such as addresses and line item numbers.

```
private bool IsValidZUGFeRD(InvoiceDescriptor invoice, Lines pdfInvoice) {
  // add key values to a list for validation
  List<string> validationValues = new List<string>();
  validationValues.Add(invoice.TaxTotalAmount.ToString(new CultureInfo("de-DE")));
  validationValues.Add(invoice.GrandTotalAmount.ToString(new CultureInfo("de-DE")));
  validationValues.Add(invoice.InvoiceNo);

  // check, if key values exist in visible PDF
  foreach (string value in validationValues) {
    if (pdfInvoice.Find(value).Count == 0)
      return false;
  }

  // all good
  return true;
}
```

The above methods can be called like in the following code:

```
// create a new invoice 
InvoiceDescriptor invoice = ImportZUGFeRD("ZUGFeRD.pdf");

// import the visible PDF
var clPDFInvoice = new TXTextControl.DocumentServer.PDF.Contents.Lines("ZUGFeRD.pdf");

// check validity
var valid = IsValidZUGFeRD(invoice, clPDFInvoice);
```

We are working on more features that help integrating electronic document processing into your business workflows. Our goal is to provide you with libraries to integrate the complete workflow to automate documents in your applications. Let us know what else you are looking for.

Stay tuned for more document processing features of TX Text Control X19!

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Series

- [X19 Sneak Peek: Table of Contents](https://www.textcontrol.com/blog/2020/10/15/x19-sneak-peek-table-of-contents/llms.txt)
- [X19 Sneak Peek: Embedded Files in Adobe PDF Documents](https://www.textcontrol.com/blog/2020/10/16/x19-sneak-peek-embedded-files-in-pdf/llms.txt)
- [X19 Sneak Peek: Integrated Barcode Support](https://www.textcontrol.com/blog/2020/10/19/x19-sneak-peek-integrated-barcode-support/llms.txt)
- [X19 Sneak Peek: Processing AcroForm Fields in Adobe PDF Documents](https://www.textcontrol.com/blog/2020/10/29/sneak-peek-processing-acroform-fields-from-adobe-pdf-documents/llms.txt)
- [X19 Sneak Peek: Storing Document Revisions in PDF/A-3b](https://www.textcontrol.com/blog/2020/11/03/x19-sneak-peek-saving-document-versions-in-pdfa-3b/llms.txt)
- **X19 Sneak Peek: Validating ZUGFeRD / Factur-X Invoices with TX Text Control** (this article)
- [X19 Sneak Peek: Changes for Keyboard Layout and Spell Checking](https://www.textcontrol.com/blog/2020/11/12/x19-sneak-peek-changes-for-keyboard-layout-and-spell-checking/llms.txt)
- [X19 Sneak Peek: Manipulating MergeBlockInfo Objects](https://www.textcontrol.com/blog/2020/11/17/x19-sneak-peek-manipulating-mergeblockinfo-objects/llms.txt)

---

## Related Posts

- [Electronic Invoicing will Become Mandatory in Germany in 2025](https://www.textcontrol.com/blog/2024/04/10/electronic-invoicing-will-become-mandatory-in-germany-in-2025/llms.txt)
- [Creating ZUGFeRD Compliant PDF Invoices in C#](https://www.textcontrol.com/blog/2021/02/03/creating-zugferd-compliant-pdf-invoices-in-csharp/llms.txt)
- [X19 Sneak Peek: Storing Document Revisions in PDF/A-3b](https://www.textcontrol.com/blog/2020/11/03/x19-sneak-peek-saving-document-versions-in-pdfa-3b/llms.txt)
- [PDF/A-3: The Better Container for Electronic Documents](https://www.textcontrol.com/blog/2020/07/23/pdfa-the-better-container-for-electronic-documents/llms.txt)
- [Text Control Announces PDF/A-3 Support: The Future of Electronic Invoices](https://www.textcontrol.com/blog/2020/07/21/text-control-announces-pdf-a-3-support/llms.txt)
- [TX Text Control 34.0 SP4 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/05/20/tx-text-control-34-0-sp4-is-now-available/llms.txt)
- [TX Spell .NET 11.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/04/08/tx-spell-net-11-0-sp1-is-now-available/llms.txt)
- [TX Text Control 34.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/02/18/tx-text-control-34-0-sp2-is-now-available/llms.txt)
- [TX Text Control 34.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/12/03/tx-text-control-34-0-sp1-is-now-available/llms.txt)
- [Introducing TX Text Control 34.0: Your Next Leap in Document Processing](https://www.textcontrol.com/blog/2025/11/10/introducing-tx-text-control-34-0-your-next-leap-in-document-processing/llms.txt)
- [Sneak Peek: TX Text Control 34.0 Coming November 2025](https://www.textcontrol.com/blog/2025/10/02/sneak-peek-tx-text-control-34-0-coming-november-2025/llms.txt)
- [TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/08/14/tx-text-control-33-0-sp3-is-now-available/llms.txt)
- [TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/06/18/tx-text-control-33-0-sp2-is-now-available/llms.txt)
- [Service Pack Releases: What's New in TX Text Control 33.0 SP1 and 32.0 SP5](https://www.textcontrol.com/blog/2025/05/07/service-pack-releases-whats-new-in-tx-text-control-33-0-sp1-and-32-0-sp5/llms.txt)
- [The Wait is Over: TX Text Control for Linux is Officially Here](https://www.textcontrol.com/blog/2025/03/12/the-wait-is-over-tx-text-control-for-linux-is-officially-here/llms.txt)
- [Full .NET 9 Support in Text Control .NET Components for ASP.NET Core, Windows Forms, and WPF](https://www.textcontrol.com/blog/2024/11/11/full-net-9-support-in-text-control-net-components-for-asp-net-core-windows-forms-and-wpf/llms.txt)
- [TX Text Control 32.0 Service Pack 4 Released](https://www.textcontrol.com/blog/2024/09/02/tx-text-control-32-0-service-pack-4-released/llms.txt)
- [Service Pack 3: MailMerge Supports SVG Images](https://www.textcontrol.com/blog/2024/04/29/service-pack-3-mailmerge-supports-svg-images/llms.txt)
- [TX Text Control 32.0 Service Pack 3 Released](https://www.textcontrol.com/blog/2024/04/29/tx-text-control-32-0-service-pack-3-released/llms.txt)
- [32.0 Service Pack 2: Licensing, Unit Testing, and Azure DevOps](https://www.textcontrol.com/blog/2024/01/05/32-0-service-pack-2-licensing-unit-testing-and-azure-devops/llms.txt)
- [Service Pack 1 for TX Text Control 32.0 Released](https://www.textcontrol.com/blog/2023/11/22/service-pack-1-for-tx-text-control-32-released/llms.txt)
- [Service Pack 4 for TX Text Control 31.0 Released](https://www.textcontrol.com/blog/2023/09/19/service-pack-4-for-tx-text-control-31-released/llms.txt)
- [TX Text Control 32.0 Has Been Released](https://www.textcontrol.com/blog/2023/09/13/tx-text-control-320-has-been-released/llms.txt)
- [Sneak Peek 32.0: Modifying the Normal Stylesheet](https://www.textcontrol.com/blog/2023/07/04/sneak-peek-320-modifying-the-normal-stylesheet/llms.txt)
- [Sneak Peek 32.0: Introducing Footnotes](https://www.textcontrol.com/blog/2023/06/23/sneak-peek-320-introducing-footnotes/llms.txt)
