Electronic invoicing is becoming an increasingly important part of business infrastructure across Europe.
In France, a national electronic invoicing reform is introducing new requirements for businesses, particularly for domestic B2B transactions. The reform is being implemented progressively and relies on structured invoice formats that can be processed automatically by different information systems.
One of these formats is Factur-X, a hybrid electronic invoicing format developed through French-German cooperation and based on the European EN 16931 semantic standard.
Unlike a traditional PDF invoice, a Factur-X document combines a human-readable invoice with an embedded structured XML file.
However, the challenge is not simply to produce a PDF and attach an XML file.
How can we ensure that the amounts displayed in the PDF match the data contained in the XML? How can applicable tax statements be determined without relying on users to enter potentially inconsistent information? How can a compliant document be generated without depending on an external platform for its production?
These questions are more closely related to software architecture than to document generation.
This article presents the technical approach behind a free Factur-X generator developed by Palks Studio, designed to produce hybrid invoices using the EN16931 profile.
The generator is specifically intended for invoice issuers established in France. It supports invoicing scenarios involving French and foreign customers, within the scope of the tax rules implemented by the system.
The objective is not to introduce a PDF or XML generation library, but to demonstrate how document compliance can be integrated directly into the design of an invoicing system.
1. Factur-X: One Document, Two Representations
A Factur-X invoice is based on a simple principle: combining a human-readable representation and a structured, machine-readable representation within a single file.
The final document contains:
- A PDF/A-3 document
- A structured XML file embedded within the PDF
- Metadata identifying the document and its Factur-X profile
The PDF preserves the traditional visual presentation of an invoice, while the XML contains the information required for automated processing.
Factur-X invoice
│
├── PDF/A-3
│ ├── Seller information
│ ├── Customer information
│ ├── Invoice line items
│ ├── VAT and totals
│ └── Legal statements
│
└── Embedded XML
├── Party identification
├── Invoicing data
├── Structured line items
├── Tax information
└── Monetary totals
The EN16931 profile, historically referred to as Comfort in Factur-X terminology, provides the information required to represent an electronic invoice according to the European semantic model.
EN 16931 defines the meaning and relationships of the core information contained in an electronic invoice. Factur-X provides a hybrid document format through which this information can be represented.
The value of the format therefore lies not simply in the presence of an XML file inside a PDF.
It lies in the ability of both representations to describe the same economic transaction.
2. Compliance Starts with the Data Model
One possible approach would be to generate a PDF invoice first, then reconstruct the data required to create the XML.
This organization immediately introduces a risk: both representations may evolve independently and eventually contain different information.
A change in VAT calculations within the PDF generator, for example, might not be reflected in the XML generator.
The approach adopted here places business data at the center of the process.
Invoicing data
│
▼
Controlled processing
│
▼
Consistent business data
│
├────────────────────┐
▼ ▼
PDF representation XML representation
│ │
└─────────┬──────────┘
▼
Factur-X invoice
Seller information, customer information, invoice line items, amounts, and tax rules must be established before the document representations are constructed.
The PDF and XML then become two representations of the same dataset.
This separation allows the visual presentation of an invoice to evolve without changing its underlying business meaning.
It also avoids treating the PDF as a data source from which structured information must subsequently be reconstructed.
3. Consistency Between Line Items, Amounts, and Totals
An electronic invoice contains more than descriptive information. It represents a financial transaction whose monetary values must remain consistent.
Consider a deliberately simple example:
Service A
Quantity : 2
Unit price excl. VAT : €100.00
Net amount : €200.00
VAT rate : 20%
VAT amount : €40.00
Total incl. VAT : €240.00
These values must be represented consistently in both the PDF and the XML.
A simplified representation of the underlying data model could look like this:
{
"currency": "EUR",
"lines": [
{
"description": "Service A",
"quantity": 2,
"unit_price": 100.00,
"net_amount": 200.00,
"vat_rate": 20.00
}
],
"totals": {
"net_amount": 200.00,
"vat_amount": 40.00,
"gross_amount": 240.00
}
}
This example illustrates the principle of a shared data model. It does not represent the actual internal structure of the generator.
The complexity increases when multiple invoice lines are subject to different VAT rates.
Service A: €200.00 excl. VAT | VAT 20%
Service B: €100.00 excl. VAT | VAT 10%
Taxable amount at 20% : €200.00
VAT at 20% : €40.00
Taxable amount at 10% : €100.00
VAT at 10% : €10.00
Total excl. VAT : €300.00
Total VAT : €50.00
Total incl. VAT : €350.00
The system must preserve not only the amounts associated with each invoice line, but also their distribution across the applicable tax categories.
In an invoicing architecture, centralizing these calculations is preferable to reproducing them independently in each document generation component.
Rounding rules are another important consideration. A difference of one cent between the PDF totals and the XML totals may be enough to make the document inconsistent.
The objective is therefore to establish a common monetary reference and use it to construct both representations.
4. Tax Statements as Business Rules
One of the most important aspects of the generator is the determination of legally required VAT statements.
In a traditional invoicing system, these statements may be entered manually by the user.
This approach has several limitations:
- A required statement may be omitted
- A statement may be incompatible with the seller's tax regime
- A statement may appear correctly in the PDF but be missing from the XML
- A change in the invoicing context may make a previously applicable statement incorrect
The generator adopts a different approach.
The applicable tax statement is determined automatically from the invoicing data and the rules configured within the system.
The generator is specifically designed for French invoice issuers. Its tax logic therefore starts from the French tax framework rather than attempting to support every possible national invoicing regime.
The decision takes into account several factors:
- The seller's tax regime
- The customer's location
- The customer's tax status
- The nature of the transaction
The principle can be represented as follows:
French seller's tax regime
│
Customer location
│
Customer tax status
│
Nature of the transaction
│
▼
Tax rules
│
▼
Applicable tax treatment
│
├──────────────────────┐
▼ ▼
Legal statement in PDF Tax data in XML
The result of this decision is integrated into both invoice representations.
The user does not need to reconstruct the tax logic manually every time an invoice is generated.
An Example: The French VAT Exemption Scheme
France has a VAT exemption scheme known as franchise en base de TVA, under which eligible businesses do not charge VAT on transactions covered by the scheme.
For an operation that falls within this regime, an invoice may contain the following statement:
TVA non applicable, article 293 B du CGI.
In English, this means that VAT is not applicable under Article 293 B of the French General Tax Code.
The statement must be visible to the recipient in the PDF.
In the XML, the corresponding tax treatment must be represented through the structured information defined by the invoicing model, including the applicable tax category and, where required, the exemption reason.
Adding a sentence at the bottom of a document is therefore not sufficient.
The system must correctly represent the tax treatment of the transaction in both formats.
This organization also makes it possible to distinguish an exempt transaction from one that is simply subject to a 0% VAT rate. These situations are not necessarily equivalent from a tax perspective.
Supporting International Customers
Although the generator is intended for French invoice issuers, the customer is not necessarily located in France.
A French business may invoice:
- A customer established in France
- A customer established in another European Union member state
- A customer established outside the European Union
These situations may require different tax treatments depending on the nature of the transaction and the status of the parties involved.
The generator therefore treats customer location as part of the business context rather than as a simple address field.
However, the scope remains important. The generator is not a universal international tax engine. Its rules are limited to the French issuer framework and the transactions supported by the system.
Tax automation cannot replace configuration appropriate to the seller's actual business activities.
5. Building the XML from Business Data
The XML embedded within a Factur-X invoice is not simply a textual copy of the PDF.
It follows a standardized structure that allows different software systems to understand the same information without necessarily sharing the same internal architecture.
Factur-X uses the UN/CEFACT Cross Industry Invoice syntax, commonly referred to as CII.
An invoice contains information relating to:
- Invoice identification
- The parties involved in the transaction
- Invoiced products or services
- Payment terms
- VAT categories and amounts
- Monetary totals
Building the XML involves mapping the generator's business data to the elements defined by this structure.
Business data model
│
▼
Mapping to the
EN16931 semantic model
│
▼
XML construction
│
▼
Structured representation
An amount, date, or identifier cannot be placed arbitrarily within the XML. Each piece of information has a specific meaning and must be represented according to the conventions of the format.
This distinction is important: an XML document may be perfectly readable by a parser while remaining incorrect according to electronic invoicing business rules.
Syntactic validity alone is therefore not sufficient to establish invoice compliance.
6. Different Levels of Validation
Factur-X compliance involves several levels of validation, each addressing a different requirement.
Structural Validation
XSD validation checks whether the XML follows the expected structure.
It verifies permitted elements, their organization, data types, and certain mandatory presence requirements.
A missing required element or a value incompatible with its expected type may therefore cause a validation error.
Business Rule Validation
Schematron rules allow checks that go beyond the basic structure of the document.
They can verify relationships between different pieces of information, monetary consistency, or the presence of data required in specific tax situations.
An XML document that is structurally valid may therefore fail business rule validation.
Hybrid Document Compliance
The final dimension concerns the Factur-X document itself.
The PDF must comply with PDF/A-3 requirements, contain the associated XML, and include the expected metadata and embedding information.
Structured XML
│
▼
Structural validation
│
▼
Business rule validation
│
▼
Embedding into PDF/A-3
│
▼
Hybrid document validation
This diagram represents the different levels of control required by a Factur-X compliance process. It does not describe the generator's private validation pipeline.
These checks must also be distinguished from consistency between the visible PDF and the XML data.
Even when an XML document satisfies its schemas and business rules, this does not automatically guarantee that the information displayed in the PDF matches its contents.
This is precisely why an architecture based on a shared data model is valuable.
7. Generating the PDF/A-3 and Embedding the XML
PDF/A-3 is a format designed for the long-term preservation of electronic documents. Unlike earlier versions of PDF/A, it also allows different types of files to be embedded within the document.
Factur-X uses this capability to combine the visual document with structured invoice data.
The process can be represented as follows:
Invoicing data
│
├────────────────────┐
▼ ▼
PDF generation XML generation
│ │
│ ▼
│ Factur-X XML
│ │
└─────────┬──────────┘
▼
XML embedding
│
▼
PDF/A-3 document
│
▼
Factur-X invoice
Embedding the XML must not be confused with attaching an arbitrary file to a conventional PDF.
The hybrid document must follow Factur-X conventions concerning the embedded file, its association with the document, and the metadata identifying the format.
The expected result is a single file that preserves the familiar presentation of an invoice while allowing automated processing.
The recipient can open the PDF using a compatible reader, while invoice processing software can extract the structured information.
This organization maintains continuity between human workflows and automated processing.
8. Why Not Separate Factur-X Generation from the Invoicing System?
One possible architecture would consist of producing a conventional invoice and then sending it to a service responsible for converting the document into Factur-X.
This approach can address certain integration requirements, particularly when an existing invoicing system cannot be modified.
However, it introduces an additional processing stage.
Invoicing system
│
▼
PDF invoice
│
▼
Conversion service
│
▼
Factur-X invoice
If the conversion service does not receive the original business data, it may need to reconstruct structured information from the visible document.
This reconstruction introduces a challenge that does not exist when the data is available from the beginning.
The approach adopted by the generator integrates Factur-X production directly into the invoicing process.
Invoicing system
│
▼
Controlled business data
│
▼
Native Factur-X generation
│
▼
Hybrid document
Compliance becomes a property of the generation system rather than a transformation applied after the document has been produced.
This allows the system to retain control over the data, tax rules, and information supplied to each representation.
The final format becomes the result of the business process rather than a correction applied to an existing document.
9. Autonomous Generation Without SaaS Dependency
The generator has been designed without a critical external service dependency for Factur-X invoice production.
The objective is not to eliminate every external library or software component. Using a library integrated into an application is not the same type of dependency as delegating every generation operation to a remote service.
In an architecture based on an external conversion API, the availability of that service may directly determine whether invoices can be produced.
Invoicing data
│
▼
External API
│
▼
Factur-X invoice
A service interruption, API modification, or change in its terms of use may therefore affect the invoicing system.
Controlling the generation process within one's own infrastructure reduces this dependency.
This approach offers several advantages:
- Control over the generation process
- The ability to evolve business rules
- Reduced data exchanges with third-party services
- A clearer understanding of the components required for system operation
However, this autonomy also introduces additional responsibilities.
Libraries, tax rules, XML schemas, and document requirements must be maintained over time.
The absence of a SaaS dependency does not eliminate the need for maintenance.
10. Generating a Compliant Invoice Is Not the Same as Transmitting It
This distinction is particularly important in the context of France's electronic invoicing reform.
For international readers, it is worth clarifying that Factur-X is a document format, while the French reform defines a broader regulatory framework for electronic invoicing and related reporting obligations.
The European EN 16931 standard provides a common semantic foundation for electronic invoices. It does not, by itself, define every national requirement concerning invoice transmission, reporting, or tax administration.
In France, the reform introduces a regulated exchange framework involving approved platforms, known as plateformes agréées (PA).
Generating a Factur-X invoice and transmitting it through this regulated framework are two separate responsibilities.
A generator produces a structured document.
A transmission system must also handle exchanges with the relevant participants, routing information, and statuses associated with the invoice lifecycle.
Factur-X generator
│
▼
Electronic invoice
│
▼
Transmission layer
│
▼
Approved platform
│
▼
Regulated exchange framework
The production of a Factur-X document does not therefore mean that all electronic invoicing obligations have automatically been fulfilled.
This distinction is also relevant to cross-border transactions, which may be subject to reporting requirements different from those applicable to domestic B2B electronic invoicing.
The generator presented in this article focuses on document production. It is not presented as an approved platform or a complete solution covering every obligation under the French reform.
This separation allows the generator to be designed as an autonomous component that can be integrated into broader business systems.
Document generation can evolve independently of transmission mechanisms, provided that the interfaces between these layers remain consistent.
This is a classic principle of separation of responsibilities applied to electronic invoicing.
11. A Free Generator as an Architectural Demonstration
The generator presented in this article illustrates a concrete approach to producing Factur-X electronic invoices.
Its scope covers hybrid document generation, consistency of invoicing data, and the application of the supported tax rules for French invoice issuers.
It demonstrates how a generation system can be organized around a deterministic process.
Invoicing data
│
▼
Business rule application
│
▼
Calculations and tax data
│
▼
PDF and XML generation
│
▼
Factur-X invoice
This organization makes the overall operation of the system and its responsibilities easier to understand.
It also provides a foundation for broader integrations, including internal invoicing tools, specialized business systems, and automated document generation workflows.
The generator does not attempt to reproduce every feature of a commercial management application.
Its value lies in controlling a specific operation: transforming invoicing data into a consistent hybrid electronic document.
Although the current implementation is designed for French invoice issuers, the underlying architectural principles are not limited to France.
Shared business data, separation of responsibilities, deterministic tax processing, and consistency between document representations are relevant to electronic invoicing systems in many regulatory environments.
Conclusion
Designing a Factur-X generator involves considerably more than producing a PDF and embedding an XML file.
The real challenge lies in how the system establishes business data, applies tax rules, maintains monetary consistency, and constructs the different invoice representations.
An architecture based on shared data allows these requirements to be addressed before document generation.
The PDF becomes the representation intended for human readers. The XML becomes the representation intended for automated processing. Both describe the same economic transaction.
This approach also distinguishes document compliance from the other responsibilities of an invoicing system, including regulated transmission, payment tracking, and accounting management.
In the context of France's electronic invoicing reform, this separation is particularly important. A compliant document is an essential component of the process, but it is not the entire regulatory framework.
The objective is not to multiply components or dependencies, but to build a process that remains understandable, controlled, and capable of evolving.
From this perspective, Factur-X is no longer simply an export format. It becomes the result of an invoicing architecture designed to produce consistent data from the outset.
Technical Documentation
The GitHub repository presents the generator, its approach to Factur-X compliance, and a concrete example of a hybrid electronic invoice.
The generator is intended for invoice issuers established in France, including invoicing scenarios involving domestic and international customers within the supported tax framework.
The repository contains documentation and demonstration materials. It does not contain downloadable source code or production files.
Explore the Free Factur-X Generator project on GitHub

Top comments (0)