Python lib for Factur-X, the e-invoicing standard for France and Germany
Clone or download
Pull request Compare This branch is 36 commits ahead, 3 commits behind akretion:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin Implement Command Line Options (#35) Aug 9, 2018
LICENSE Initial check-in Sep 9, 2017
README.rst Update README.rst (#38) Oct 10, 2018


Factur-X Python library

Factur-X is a EU standard for embedding XML representations of invoices in PDF files. This library provides an interface for reading, editing and saving the this metadata.

Since there are multiple flavors of the embedded XML data, this library abstracts them into a Python dict, which can be used to load and save from/to different flavors.

This project was forked from Akretion and continues to be under the same license. We aim to make the library higher-level, make editing fields easier and support more standards and flavors.

Main features:

  • Edit and save existing XML metadata fields.
  • Create new XML representation from template and embed in PDF.
  • Add existing XML representation to PDF.
  • Validate existing XML representation.


pip install PyPDF2 lxml pyyaml pycountry
pip install --index-url --upgrade factur-x-ng


Load PDF file without XML and assign some values to common fields.

from facturx import FacturX

inv = FacturX('some-file.pdf')
inv['due_date'] = datetime(2018, 10, 10)
inv[''] = 'Smith Ltd.'
inv[''] = 'France'

Validate and save PDF including XML representation.


Load PDF with XML embedded. View and update fields via pivot dict.

inv = FacturX('another-file.pdf')
inv_dict = inv.as_dict()
inv_dict['currency'] = 'USD'

Save XML metadata in separate file in different formats.


To have more examples, look at the source code of the command line tools located in the bin subdirectory.

Command line tools

Several sub-commands are provided with this lib:

  • Dump embedded metadata: facturx dump file-with-xml.pdf metadata.(xml|json|yml)
  • Validate existing metadata: facturx validate file-with-xml.pdf
  • Add external metadata file: facturx add no-xml.pdf metadata.xml
  • Extract fields from PDF and embed: facturx extract no-xml.pdf

All these command line tools have a -h option that explains how to use them and shows all the available options.


This library is published under the BSD licence (same licence as PyPDF2 on which this lib depends).


  • Alexis de Lattre Initial version, PDF- and XMP processing.
  • Manuel Riel: Python 3 support, support for editing individual fields, separate support for different standards