---
source: https://carbone.io/examples/factur-x/
title: "Invoice Automation Examples with Factur-X"
description: "Learn how to generate PDF invoices with embedded XML data using Carbone's Factur-X feature. Create compliant electronic invoices by merging JSON data with templates in various formats including DOCX, PPTX, XLSX, and more."
generated_at: "2026-07-13"
---

# Invoice Automation / Factur-X

Generate Factur-X compliant electronic invoices with embedded XML using Carbone

[![factur-x thumbnail](/examples/factur-x/thumb-result.webp)](/examples/factur-x/result.pdf)

[Download Template](/examples/factur-x/template.docx)

[Download data sample](/examples/factur-x/data.json)

-   Template type document docx simple
-   Carbone min. v4.0.0+
-   Features factur-X
-   Target invoice contract custom

## Overview

This guide shows you how to create a Factur-X invoice - a PDF document with embedded XML data that follows international electronic invoicing standards - by:

-   Generating a PDF invoice
-   Embedding a structured XML file within the PDF

## Step-by-Step Solution

### 1\. Prepare the XML Data

First, you need an XML file that contains the structured invoice data. You have two options:

-   Create the XML file manually
-   Generate it using Carbone with an XML template

### 2\. Create the Invoice PDF

Design the template. You can get inspiration from our [basic invoice template](/examples/invoice-expert/index.md).

### 3\. Attach the XML File

Use the [:attachFile](/documentation/design/advanced-features/file-operations.md#attachfile-name-type) formatter to embed the XML:

-   Syntax: `:attachFile('factur-x.xml')`
-   The formatter automatically:
    -   Detects the Conformance Level from your XML ('MINIMUM', 'BASIC WL', 'BASIC', 'EXTENDED', 'EN 16931')
    -   Sets appropriate PDF metadata
    -   Uses PDF Version 3B (if not specified otherwise)

**Advanced Options:** You can specify the PDF relationship type using [:attachFile(filename, type)](/documentation/design/advanced-features/file-operations.md#attachfile-name-type):

-   Available types: "Source", "Data" (default), "Alternative", "Supplement", "Unspecified", "FormData", "Schema"

## Process Flow

```text

   1- Template                                            
  ┌─────────────────┐                                     
  │   *.docx        │       ┌─────────┐                   
  │                 ┼───┐   │         │                   
  │ :attachFile     │   │   │         │                   
  │ ('factur-x.xml')│   └───►         │     Export        
  └─────────────────┘       │ Carbone │    ┌───────┐      
                            │         │    │ *.pdf │      
             2- Data    ┌───►         ┼────►     ┌─┴┐     
            ┌───────┐   │   │         │    │     │┌┐│     
            │*.json ┼───┘   │         │    └─────┤│││     
            └───────┘     ┌─►         │          │ │      
                          │ │         │          └─┘*.xml 
             3- XML       │ │         │                   
            ┌───────┐     │ └─────────┘                   
            │*.xml  ┼─────┘                               
            └───────┘                                                                   
```

## Related Examples

[![invoice-simple thumbnail example](/examples/invoice-simple/thumb-result.webp)](/examples/invoice-simple/index.md)

## Trusted by 800+ paid customers in 40+ countries

## Related topics

- [Transport ticket](/examples/ticket/index.md)
- [Summary](/examples/summary/index.md)
- [Stock inventory spreadsheet](/examples/stock-inventory-spreadsheet/index.md)
- [Store Inventory](/examples/shoes/index.md)
- [Sensor readings](/examples/sensor-readings/index.md)
- [Real estate property document](/examples/real-estate-property-description/index.md)
