# Extract ZUGFeRD/Factur-X XML Attachments from Adobe PDF/A-3b Documents

> This article explains how to extract ZUGFeRD/Factur-X XML attachments from Adobe PDF/A-3b documents using TX Text Control programmatically.

- **Author:** Bjoern Meyer
- **Published:** 2021-01-18
- **Modified:** 2026-07-17
- **Description:** This article explains how to extract ZUGFeRD/Factur-X XML attachments from Adobe PDF/A-3b documents using TX Text Control programmatically.
- **2 min read** (319 words)
- **Tags:**
  - Angular
  - ASP.NET
  - Attachments
  - Factur-X
  - PDF
  - ZUGFeRD
- **Web URL:** https://www.textcontrol.com/blog/2021/01/18/extract-zugferd-facturx-attachments-from-adobe-pdf-documents/
- **LLMs URL:** https://www.textcontrol.com/blog/2021/01/18/extract-zugferd-facturx-attachments-from-adobe-pdf-documents/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2021/01/18/extract-zugferd-facturx-attachments-from-adobe-pdf-documents/llms-full.txt

---

Several standards define electronic invoice formats that allows the integration of electronic XML data in Adobe PDF documents. PDF/A-3 allows attachments in any format to be added to PDF documents.

### PDF/A-3b

The standard itself doesn't standardize the embedded documents, but the way how they are embedded in the PDF structure. This enables applications to reliably extract the attached document from the PDF document which enables readers to extract only the embedded documents without having to open the complete PDF document itself.

Using TX Text Control, you can create those documents by adding attachments to existing or new documents that are then exported as PDF/A documents. TX Text Control can be also used to import and extract those attachments from existing PDF documents.

By standard, the attachments have several parameters that control the document. An XML attachment in the standards *ZUGFeRD*, *ZUGFeRD 2.1*, *Factur-X 1.0* and *XRechnung* have the following parameters:

| Parameter | Value |
|---|---|
| Relationship | Alternative |
| MIMEType | text/xml |

### Import the Attachments

The following method *GetXmlAttachment* 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 has been 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 for the requirements *Relationship* and *MIMEType* in order to return the associated, embedded XML document.

The above method can be called like in the code below to extract the alternative XML invoice from a PDF/A-3b document:

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

---

## 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)

---

## Related Posts

- [Why Structured E-Invoices Still Need Tamper Protection using C# and .NET](https://www.textcontrol.com/blog/2026/03/24/why-structured-e-invoices-still-need-tamper-protection-using-csharp-and-dotnet/llms.txt)
- [Visualize and Preview XRechnung, ZUGFeRD, and Factur-X Documents in .NET C#](https://www.textcontrol.com/blog/2025/01/02/visualize-and-preview-xrechnung-zugferd-and-factur-x-documents-in-net-csharp/llms.txt)
- [Creating ZUGFeRD 2.3 (XRechnung, Factur-X) Documents with .NET C#](https://www.textcontrol.com/blog/2025/01/02/creating-zugferd-2-3-xrechnung-factur-x-documents-with-net-c-sharp/llms.txt)
- [Streamline Document Workflows: Harness the Power of Embedded Attachments in PDFs in .NET C#](https://www.textcontrol.com/blog/2024/11/15/streamline-document-workflows-harness-the-power-of-embedded-attachments-in-pdfs-in-net-c-sharp/llms.txt)
- [How to Extract Attachments from PDF Documents in C#](https://www.textcontrol.com/blog/2024/10/07/how-to-extract-attachments-from-pdf-documents-in-csharp/llms.txt)
- [Creating Advanced Tables in PDF and DOCX Documents with C#](https://www.textcontrol.com/blog/2024/09/30/creating-advanced-tables-in-pdf-and-docx-documents-with-csharp/llms.txt)
- [Customizing Electronic Signature Fonts for Typed Signatures in Angular and ASP.NET Core](https://www.textcontrol.com/blog/2024/03/11/customizing-electronic-signature-fonts-for-typed-signatures-in-angular-and-asp-net-core/llms.txt)
- [How to Choose the Best C# Library for your Document Processing Needs](https://www.textcontrol.com/blog/2023/08/07/how-to-choose-the-best-library-for-your-document-processing-needs/llms.txt)
- [Add and Extract Attachments from PDF Documents in C#](https://www.textcontrol.com/blog/2023/07/07/add-and-extract-attachments-from-pdf-documents-in-csharp/llms.txt)
- [Adding Attachments to Adobe PDF Documents using C#](https://www.textcontrol.com/blog/2022/02/25/adding-attachments-to-adobe-pdf-documents-using-csharp/llms.txt)
- [Smart Documents: Embedding Documents in PDF Containers](https://www.textcontrol.com/blog/2021/06/24/smart-document-containers-embedding-documents-in-pdf/llms.txt)
- [Creation of Custom Electronic Signature Boxes](https://www.textcontrol.com/blog/2021/06/15/creation-of-custom-electronic-signature-boxes/llms.txt)
- [Don't Print Your Documents! Streamlined Document Processes in Your Applications](https://www.textcontrol.com/blog/2021/06/09/dont-print-your-documents/llms.txt)
- [Creating PDF Documents from MS Word DOCX in C#](https://www.textcontrol.com/blog/2021/02/26/creating-pdf-documents-from-ms-word-docx-in-csharp/llms.txt)
- [Creating Adobe PDF Forms in C#](https://www.textcontrol.com/blog/2021/02/10/creating-adobe-pdf-forms-in-csharp/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)
- [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)
