Back to list
dev_to 2026年4月20日

Python で Factur-X PDF 伝票を生成する(無料、ライブラリ不要)

Generate a Factur-X PDF Invoice in Python (Free, No Library Needed)

Translated: 2026/4/20 13:01:55
factur-xpdf-a-3cii-xmlpythoninvoice-generation

Japanese Translation

ファクトゥラ-X 伝票をプログラム上生成しようとしてみたことがあれば、その苦痛を誰かがわかるはずです。公式ライブラリは重く、文書は 3 つの異なる規格団体に散らばっており、埋め込まれた XML を持った有効な PDF/A-3 を生成するのは非常に簡単ではありません。 本記事では、Python において 20 行未満のコードだけで完全に準拠したファクトゥラ-X 伝票を生成する方法を紹介します。これは無料の API を使用し、ローカル依存関係や Java ランタイムを必要としないためです。 ファクトゥラ-X は、CII XML ファイルを埋め込んだ Human-readable PDF/A-3 で構成されるハイブリッドな電子伝票形式です。これは、フランスとドイツ(ここで ZUGFeRD と呼ばれます)における電子請求書の標準であり、EU 全域で義務付けられるようになってきています。 埋め込まれた XML は、会計ソフトが請求書データを自動的に抽出できるようにし、手動入力や OCR エラーを排除します。 最も一般的なアプローチには以下のものがあります: - factur-x Python ライブラリ:Ghostscript、pdfrw、および動作する LaTeX または WeasyPrint のセットアップが必要です - Mustang Java ライブラリ:JVM が必要です。複雑な Maven セットアップが求められます - クォータリー API:月額 99€ minimum クイックな統合或小規模の使用例では、これらどれでも最適ではありません。 XMLBridge.com は、有効な Factur-X PDF/A-3 ファイルを生成する無料の REST API を提供しています。API キー、サインアップ、または適度な利用におけるレート制限はありません。 エンドポイント:POST https://api.xmlbridge.com/generate-facturx 埋め込まれた XML が有効であることを確認するために、Adobe Acrobat で PDF を開き、添付パネルをチェックしてください。factur-x.xml を見るはずです。さらに、PDF を xmlbridge.com/facturx にドラッグ&ドロップすることで、ブラウザ内で埋め込まれた XML を直接抽出および検査することも可能です。 API は生の PDF バイナリ(application/pdf)を返します。この PDF は: - PDF/A-3b に準拠しています - 埋め込まれた factur-x.xml(CII 形式)を含有しています - EN 16931 スキーマトロンルールを通過しています - Chorus Pro(フランスの公共調達プラットフォーム)と互換性があります 有効なファクトゥラ-X 伝票を作成する必要は、200MB の Java 依存関係や有料 SaaS サブスクリプションを伴うものにはなりませせん。多くの使用例(フリーランサー、小規模企業、内部ツールなど)では、シンプルな HTTP コールが全て必要なものです。 実際に試して見るには xmlbridge.com/facturx を訪問するか、API を直接ヒットしてください。 質問や問題は?コメント欄に投下してください。

Original Content

If you've ever tried to generate a Factur-X invoice programmatically, you know the pain. The official libraries are heavy, the documentation is scattered across three different standards bodies, and getting a valid PDF/A-3 with embedded XML is anything but straightforward. This article shows you how to generate a fully compliant Factur-X invoice in Python in under 20 lines of code - using a free API, no local dependencies, no Java runtime. Factur-X is a hybrid e-invoice format: a human-readable PDF/A-3 with an embedded CII XML file. It's the standard for electronic invoicing in France and Germany (where it's called ZUGFeRD), and it's becoming mandatory across the EU. The embedded XML allows accounting software to extract invoice data automatically - no manual data entry, no OCR errors. The most common approaches involve: factur-x Python library - requires ghostscript, pdfrw, and a working LaTeX or WeasyPrint setup Mustang Java library - requires a JVM, complex Maven setup Commercial APIs - €99/month minimum For a quick integration or a small volume use case, none of these are great. XMLBridge.com exposes a free REST API that generates valid Factur-X PDF/A-3 files. No API key, no signup, no rate limit for reasonable usage. Endpoint: POST https://api.xmlbridge.com/generate-facturx To confirm the embedded XML is valid, open the PDF in Adobe Acrobat and check the attachments panel - you should see factur-x.xml. You can also drag the PDF into xmlbridge.com/facturx to extract and inspect the embedded XML directly in the browser. The API returns a raw PDF binary (application/pdf). The PDF: Is PDF/A-3b compliant Contains an embedded factur-x.xml (CII format) Passes EN 16931 schematron rules Is compatible with Chorus Pro (French public procurement platform) Generating a valid Factur-X invoice doesn't have to involve a 200MB Java dependency or a paid SaaS subscription. For most use cases - freelancers, small businesses, internal tools - a simple HTTP call is all you need. Try it live at xmlbridge.com/facturx or hit the API directly. Questions or issues? Drop a comment below.