Skip to content

xml-to-pdf

Python reportlab CustomTkinter PyMuPDF XML CLI + GUI

Project Overview

A Python tool that converts XML invoice files into professionally formatted, multi-page PDF reports — with paginated tables, batch detail rows, and EAN-128 / GS1-128 barcode pages for each invoice line. Works headless from the command line for batch jobs, or via a CustomTkinter GUI for visual field mapping and one-click PDF generation.

The Problem

Different ERP exports produce different XML schemas. A practical converter has to handle that without code changes — and the output PDFs need to look like real invoices: multi-page tables that repeat headers correctly, barcode pages, branded headers, and Polish-character support.

The Solution

An XML reader that drives a reportlab rendering pipeline, with field mappings defined in JSON config files so a new XML schema only needs a config — not a code change. A CustomTkinter GUI sits on top for users who'd rather not touch the CLI; PyMuPDF handles preview and post-processing. DejaVu Sans is bundled for Polish character support.

Key Features

  • Multi-page PDF reports with auto-paginated item and batch tables (headers repeat on every page)
  • EAN-128 / GS1-128 barcode pages for each invoice item
  • Configurable XML→PDF field mapping via JSON config files (handles different XML schemas without code changes)
  • CustomTkinter GUI for visual mapping and one-click generation
  • CLI mode with single-file, batch (*.xml), and skip-barcode options
  • DejaVu Sans bundled for Polish character support

My Role

Whole project — XML parsing, ReportLab page templates and pagination, barcode generation, GUI design, JSON config schema, and CLI argument plumbing.

Technology Used

Python reportlab CustomTkinter PyMuPDF XML CLI + GUI

Challenges and Learning

Getting reportlab to paginate variable-length item and batch tables cleanly with repeated headers, and laying out barcode pages so the EAN-128 codes are scannable on real warehouse hardware. Designing the JSON mapping schema so a non-developer can configure a new XML format without seeing a stack trace.

Outcome / Value

A practical bridge between ERP XML exports and warehouse-ready PDF documents — the kind of unglamorous integration tool that quietly removes a daily manual task. Shows comfort moving across the stack: file format parsing, document layout, barcode standards, GUI and CLI ergonomics.

Screenshots