Package: factur-x-nolog
Factur-X and Order-X Python libraryFactur-X is the e-invoicing standard for France and Germany. The Factur-X specifications are available on theFNFE-MPE websitein English and French. The Factur-X standard is also calledZUGFeRD 2.1 in Germany.Order-X is the equivalent of Factur-X for purchase orders. The Order-X specifications are available onthe FNFE-MPE websitein 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 theFeRD website.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:extract the XML file from a Factur-X or Order-X PDF file,check a Factur-X or Order-X XML file against the officialXML Schema Definition.Some of the features provided by this lib also work for ZUGFeRD 1.0 (the ancestor of the Factur-X standard).InstallationThis library works both on python 2.7 and python 3.To install it for python 3, run:sudo pip3 install --upgrade factur-xTo install it for python 2.7, run:sudo pip2 install --upgrade factur-xUsagefrom facturx import generate_from_file

generate_from_file(regular_pdf_file, xml_file)The PDF fileregular_pdf_filewill be updated to Factur-X/Order-X. If you want to write the resulting Factur-X/Order-X PDF to another file, use the argumentoutput_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 thebinsubdirectory.Command line toolsSeveral command line tools are provided with this lib:facturx-pdfgen: generate a Factur-X or Order-X PDF file from a regular PDF file and an XML filefacturx-pdfextractxml: extract the XML file from a Factur-X or Order-X PDF filefacturx-xmlcheck: check a Factur-X or Order-X XML file against the official XML Schema DefinitionAll these commande line tools have a-hoption that explains how to use them and shows all the available options.WebserviceThis 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 usesFlask. To run the webservice, runfacturx-webserviceavailable in thebinsubdirectory of the project. To query the webservice, you must send anHTTP POSTrequest inmultipart/form-datausing the following keys:pdf-> PDF file (required)xml-> Factur-X or Order-X file (any profile, required)attachment1-> First attachment (optional)attachment2-> Second attachment (optional)…It is recommended to run the webservice behind an HTTPS/HTTP proxy such asNginxorApache. You will certainly have to increase the default maximum upload size (default value is only 1MB under Nginx!): use the parameterclient_max_body_sizefor Nginx andLimitRequestBodyfor Apache.You can usecurl, a command line tool to send HTTP requests (on Linux Ubuntu/Debian, just install thecurlpackage) 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_facturxA public instance of this webservice is available on a server ofFNFE-MPEat the URLhttps://ws.fnfe-mpe.org/generate_facturx.LicenceThis library is published under the BSD licence (same licence asPyPDF4on which this lib depends).ContributorsAlexis de Lattre <alexis.delattre@akretion.com>ChangelogVersion 2.5 dated 2023-03-24Add support for ZUGFeRD 1.0 in get_level()xml_check_xsd(): avoid warningUse specific ‘len(elem)’ or ‘elem is not None’ test instead.Version 2.4 dated 2023-03-13Update Factur-X XSD of all profiles to version 1.0.6Version 2.3 dated 2021-04-12Fix wrong flavor argument passed by generate_facturx_from_file() to generate_from_file()Version 2.2 dated 2021-04-08Make method generate_from_binary() accessible via the libVersion 2.1 dated 2021-04-07Update Order-X XSD to the latest version provided to me by FNFE-MPEVersion 2.0 dated 2021-04-04Add support forOrder-X. This implies several changes:methodcheck_facturx_xsd()deprecated in favor of the new methodxml_check_xsd()but still operates with a warningmethodget_facturx_flavor()deprecated in favor of the new methodget_flavor()but still operates with a warningmethodgenerate_facturx_from_binary()deprecated in favor of the new methodgenerate_from_binary()but still operates with a warningmethodgenerate_facturx_from_file()deprecated in favor of the new methodgenerate_from_file()but still operates with a warningnew optional argumentorderx_typefor methodsgenerate_from_file()andgenerate_from_binary()with default valueautodetectnew methodget_orderx_type()to get the Order-X type (order, order change or order response)new methodget_xml_from_pdf()that work both on Factur-X and Order-X (the method get_facturx_xml_from_pdf() still exists and only operates on Factur-X)scripts updatedAddlangargument to methodsgenerate_from_file()andgenerate_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:new argumentafrelationshipfor methodsgenerate_from_file()andgenerate_from_binary()new keyafrelationshipfor theattachmentsdict as argument ofgenerate_from_file()andgenerate_from_binary()Argumentadditional_attachmentswas deprecated in methodgenerate_facturx_from_file()in version 1.8: it doesn’t operate any more and only displays a warning.Replace theoptparselib by theargparselib in scripts.Version 1.12 dated 2020-07-16Compress attachments and XMP metadata using Flate compressionVersion 1.11 dated 2020-05-11Fix crash UnicodeEncodeError on Python 2.7Version 1.10 dated 2020-04-14Update XSD of all profiles to Factur-X version 1.0.5Version 1.9 dated 2020-02-11Improve Python3 support in get_facturx_xml_from_pdf()Version 1.8 dated 2020-01-16New 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:Possibility to set a filename for the attachment different from filename of the filepathPossibility to set creation dates for attachmentsUpdate script facturx-pdfgen to use the new attachments argumentVersion 1.7 dated 2020-01-13Fix bug in release 1.6 in XMP: variables were not replaced by their real valueVersion 1.6 dated 2020-01-09Generate XMP (XML-based PDF metadata) via string replacement instead of using XML libVersion 1.5 dated 2019-11-13Fix bug in generate_facturx_from_file() when using argument additional_attachmentsVersion 1.4 dated 2019-07-24Update Factur-X XSD to the final version of Factur-X v1.0.04Support XML extraction with ZUGFeRD invoices using ‘zugferd-invoice.xml’ filename (instead of the filename ‘ZUGFeRD-invoice.xml’ specified by the standard)Version 1.3 dated 2019-06-12Add XSD files for Extended profile in the Python packageVersion 1.2 dated 2019-06-12add support for the Extended profilevalidate XML for Minimum and Basic WL profiles with the XSD of profile EN 16931, as asked by Cyrille Sautereauminor improvements in the code for /KidsVersion 1.1 dated 2019-04-22Improve support for embedded files extraction by adding support for /KidsVersion 1.0 dated 2019-01-26Use PyPDF4 instead of PyPDF2, because there are no new releases of PyPDF2 since May 2016 (cfhttps://github.com/mstamy2/PyPDF2/wiki/State-of-PyPDF2-and-Future-Plans), and we need a recent version of PyPDF2 to be able to generate fully compliant PDF/A-3 files.Version 0.9 dated 2019-01-25Port to python 3 contributed by JoshuaJan (https://github.com/joshuajan)Fix path to ZUGFeRD 1.0 XSDVersion 0.8 dated 2018-06-10Make pretty_print work for XMP file, for better readability of that fileVersion 0.7 dated 2018-05-24Fix XMP structure under /x:xmpmeta/rdf:RDF/rdf:Description (use XML tags instead of XML attributes)declare PDF-1.6 instead of PDF-1.3 (still declared by default by pyPDF2)Version 0.6 dated 2018-05-01Now fully PDF/A-3 compliant with additionnal attachments (tested with veraPDF)facturx-pdfgen: don’t overwrite by default and add –overwrite optionAdd factur-x library version number in metadata creator entryVersion 0.5 dated 2018-03-29Fix XMP metadata structureNow fully PDF/A-3 compliant when the input PDF file is PDF/A compliant (tested with veraPDF). This implied copying /OutputIntents and /ID datas from source PDF to Factur-X PDF.Fix support for additionnal attachments: they can now all be saved with Acrobat ReaderImprove XML extraction from PDF Factur-x fileVersion 0.4 dated 2018-03-27Factur-x specs say /AFRelationship must be /Data (and not /Alternative)Update Factur-X XSD to v1.0 finalAdd support for additionnal attachmentsAdd factur-x lib version in Creator metadata tableAdd /PageMode = /UseAttachments, so that the attachments are displayed by default when opening Factur-X PDF invoice with Acrobat ReaderImprove and enrich PDF objects (ModDate, CheckSum, Size)