Problem: The "Java Trap"
Generating Factur-X in Python Without Java
Most e-invoicing libraries for Python are just wrappers around Java .jar files (Mustang, Konik).
They bring the JVM weight, slow startup times, and supply chain risks.
There is a better way.
Why avoid Java bridges?
The Java Way
- Requires installing JRE/JDK in Docker
- Slow "Cold Start" (bad for Serverless)
- Huge image sizes (>500MB)
- Log4j style vulnerabilities
The Factur-X Engine Way
- Pure Python + Compiled C/C++
- Instant startup (<100ms)< /span>
- Tiny footprint (~128MB RAM)
- 100% Air-gapped (No phone home)
The Solution
Factur-X Engine uses SaxonC (C/C++ XSLT processor) for
validation and a optimized Python pipeline for PDF/A-3 generation.
main.py
Python
import requests
# 1. Define your invoice data (Pure JSON)
payload = {
"invoice_number": "FAC-2024-001",
"profile": "en16931",
"seller": { "name": "Tech Corp", "country_code": "FR" },
"buyer": { "name": "Client Inc", "country_code": "DE" },
"items": [{ "name": "Dev Services", "price": 500.0 }]
}
# 2. Call the Engine (No Java needed locally)
response = requests.post(
"http://localhost:8000/v1/convert",
files={"pdf": open("template.pdf", "rb")},
data={"metadata": json.dumps(payload)}
)
# 3. Get compliant PDF/A-3
with open("invoice-fx.pdf", "wb") as f:
f.write(response.content)