Factur-X is the e-invoicing standard for France and Germany. The Factur-X specifications are available on the
FNFE-MPE website <http://fnfe-mpe.org/factur-x/> in English and French. The Factur-X standard is also called
ZUGFeRD 2.1 in Germany <https://www.ferd-net.de/standards/zugferd-2.1.1/index.html>.
Order-X is the equivalent of Factur-X for purchase orders. The Order-X specifications are available on
the FNFE-MPE website <https://fnfe-mpe.org/factur-x/order-x/> in English. The Order-X standard is also the fruit of a collaboration between France and Germany and you can find information about it in German on the
FeRD website <https://www.ferd-net.de/aktuelles/meldungen/order-x-ein-gemeinsamer-standard-fuer-elektronische-bestellungen-in-deutschland-und-frankreich.html>.
The main feature of this Python library is to generate Factur-X invoices and Order-X orders from a regular PDF document and a Factur-X or Order-X compliant XML file.
This lib provides additionnal features such as:
XML Schema Definition <https://en.wikipedia.org/wiki/XML_Schema_(W3C)>_.
Some of the features provided by this lib also work for ZUGFeRD 1.0 (the ancestor of the Factur-X standard).
This library works both on python 2.7 and python 3.
To install it for python 3, run:
sudo pip3 install --upgrade factur-x
To install it for python 2.7, run:
sudo pip2 install --upgrade factur-x
from facturx import generate_from_file
The PDF file regular_pdf_file will be updated to Factur-X/Order-X. If you want to write the resulting Factur-X/Order-X PDF to another file, use the argument output_pdf_file.
To have more examples, look at the docstrings in the source code or look at the source code of the command line tools located in the bin subdirectory.
Several command line tools are provided with this lib:
All these commande line tools have a -h option that explains how to use them and shows all the available options.
This project also provides a webservice to generate a Factur-X or Order-X PDF file from a regular PDF file, the XML file and additional attachments (if any). This webservice runs on Python3 and uses
Flask <https://www.palletsprojects.com/p/flask/>_. To run the webservice, run facturx-webservice available in the bin subdirectory of the project. To query the webservice, you must send an HTTP POST request in multipart/form-data using the following keys:
It is recommended to run the webservice behind an HTTPS/HTTP proxy such as
Nginx <https://www.nginx.com/> or
Apache <https://httpd.apache.org/>. You will certainly have to increase the default maximum upload size (default value is only 1MB under Nginx!): use the parameter client_max_body_size for Nginx and LimitRequestBody for Apache.
You can use
curl <https://curl.haxx.se/>_, a command line tool to send HTTP requests (on Linux Ubuntu/Debian, just install the curl package) to generate the request:
curl -X POST -F 'pdf=@/home/me/regular_invoice.pdf' -F 'xml=@/home/me/factur-x.xml' -F 'attachment1=@/home/me/delivery_note.pdf' -o /home/me/facturx_invoice.pdf https://ws.fnfe-mpe.org/generate_facturx
A public instance of this webservice is available on a server of
FNFE-MPE <http://fnfe-mpe.org/>_ at the URL https://ws.fnfe-mpe.org/generate_facturx.
This library is published under the BSD licence (same licence as
PyPDF4 <https://github.com/claird/PyPDF4/>_ on which this lib depends).
Version 2.3 dated 2021-04-12
Version 2.2 dated 2021-04-08
Version 2.1 dated 2021-04-07
Version 2.0 dated 2021-04-04
Add support for Order-X. This implies several changes:
Add lang argument to methods generate_from_file() and generate_from_binary() to set the lang of the PDF. This is one of the requirements for PDF accessibility, which is important for people with disabilities: it allows PDF speech synthesizers for blind people to choose the right language.
Add ability to choose the AFRelationship PDF property for the Factur-X/Order-X XML file and also for the additionnal attachments:
Argument additional_attachments was deprecated in method generate_facturx_from_file() in version 1.8: it doesn't operate any more and only displays a warning.
Replace the optparse lib by the argparse lib in scripts.
Version 1.12 dated 2020-07-16
Version 1.11 dated 2020-05-11
Version 1.10 dated 2020-04-14
Version 1.9 dated 2020-02-11
Version 1.8 dated 2020-01-16
New tool facturx-webservice which implements a REST webservice using Flask to generate a Factur-X PDF invoice via a simple POST request.
New argument 'attachments' for generate_facturx_from_file() which replaces argument additional_attachments:
Version 1.7 dated 2020-01-13
Version 1.6 dated 2020-01-09
Version 1.5 dated 2019-11-13
Version 1.4 dated 2019-07-24
Version 1.3 dated 2019-06-12
Version 1.2 dated 2019-06-12
Version 1.1 dated 2019-04-22
Version 1.0 dated 2019-01-26
Version 0.9 dated 2019-01-25
Version 0.8 dated 2018-06-10
Version 0.7 dated 2018-05-24
Version 0.6 dated 2018-05-01
Version 0.5 dated 2018-03-29
Version 0.4 dated 2018-03-27