A robust, high-performance web service to generate beautiful PDFs from Peppol BIS Billing 3.0 XML documents (Invoices and Credit Notes).
Built with FastAPI, SaxonC (for XSLT 3.0), and Microsoft Edge (for headless HTML-to-PDF rendering).
- Fast & Efficient:
- Pre-compiles XSLT stylesheets on startup using
SaxonCfor near-instant transformations (<10ms). - Efficient global caching of Saxon processors.
- Thread-safe architecture.
- Pre-compiles XSLT stylesheets on startup using
- Support for Peppol Documents:
- Invoices (
urn:oasis:names:specification:ubl:schema:xsd:Invoice-2) - Credit Notes (
urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2)
- Invoices (
- Multiple Output Formats:
- PDF Binary (Default)
- HTML via
Accept: text/html(Ultra-fast, skips PDF conversion) - JSON (
{"pdf_base64": "..."}) viaAccept: application/json - XML (
<pdf_base64>...</pdf_base64>) viaAccept: application/xml
- Flexible Deployment:
- Dockerized for easy deployment anywhere.
- Includes scripts for Azure VM deployment with Caddy reverse proxy for HTTPS.
- SEPA QR Code Integration:
- Generates EPC-compliant SEPA QR codes (v002) for instant mobile payments.
- Automatically extracts payment details (IBAN, BIC, Amount, Reference) from Peppol XML.
- Supports Belgian structured communication (
+++...+++) mapping. - Localizable instructions and payment disclaimers (EN, FR, NL, DE).
- Localized:
- Built-in support for multiple languages (EN, FR, NL, DE).
- Python 3.11+
- Microsoft Edge (Installed on the host/container for rendering)
- saxonche (Python bindings for Saxon-HE C++)
-
Clone the repository:
git clone https://github.com/yourusername/peppol-xml-visualizer.git cd peppol-xml-visualizer -
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
python -m app.main
The API will be available at
http://localhost:8000.
-
Build the image:
docker build -t peppol-visualizer . -
Run the container:
docker run -p 8000:8000 peppol-visualizer
Upload an XML file to convert it.
Query Parameters:
lang: (Optional) Language code (en,fr,nl,de). Default:en.watermark: (Optional) Text to overlay on the center of each page (e.g.,DUPLICATE).merge_attachments: (Optional) Boolean (true/false). Whether to append embedded PDF attachments found in the XML to the output. Default:false.
Curl Example:
curl -X POST "http://localhost:8000/render?lang=en&watermark=DUPLICATE" \
-H "accept: application/pdf" \
-F "file=@path/to/invoice.xml" --output result.pdfTo get the PDF as a Base64 string in JSON format (useful for API integrations), set the Accept header to application/json.
curl -X POST "http://localhost:8000/render?lang=en" \
-H "accept: application/json" \
-F "file=@path/to/invoice.xml"Response:
{
"pdf_base64": "JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZw..."
}The API returns custom headers to help you monitor performance:
| Header | Description |
|---|---|
X-Perf-Xslt-Sec |
Time taken for XSLT transformation (seconds) |
X-Perf-Pdf-Sec |
Time taken for PDF conversion (seconds, if applicable) |
X-Perf-Total-Sec |
Total processing time (seconds) |
X-Cache-Hit |
True if a pre-compiled XSLT was used from cache |
The application uses environment variables for configuration. Create a .env file based on .env.example.
| Variable | Description | Default |
|---|---|---|
PORT |
Port to run the server on | 8000 |
XSLT_INVOICE |
Path to Invoice XSLT | assets/styles/stylesheet-invoice.xslt |
XSLT_CREDITNOTE |
Path to CreditNote XSLT | assets/styles/stylesheet-creditnote.xslt |
EDGE_BIN |
Path to Edge executable | Auto-detected |
The scripts/deploy_to_azure.py script automates deployment to a Linux VM on Azure using SSH/SCP.
- Configure
.envwith your Azure credentials (AZURE_HOST,AZURE_USER,AZURE_PASS). - Run the script:
python scripts/deploy_to_azure.py
├── app/
│ ├── api/ # Routes and Controllers
│ ├── core/ # Config and Settings
│ ├── services/ # Business Logic (PDF, Saxon)
│ ├── main.py # App Entry Point
├── assets/ # XSLT Stylesheets
├── tests/ # Test Scripts
├── test_data/ # Sample Peppol XMLs
├── scripts/ # Deployment Scripts
├── Dockerfile # Docker Build
├── Caddyfile # Caddy Reverse Proxy Config
└── requirements.txt # Python Dependencies
MIT License. See LICENSE for details.
Maintained by Bytebrain Technology Solutions (BTC).
- Website: https://bytebraintechnologies.com/
- Company ID (BE): 0746.412.525
- Location: Sint-Joost-ten-Node, Brussels, Belgium
For commercial support or custom integration, please contact us via our website.