{"id":66888,"date":"2026-11-11T16:51:30","date_gmt":"2026-11-11T16:51:30","guid":{"rendered":"https:\/\/help.pdf24.org\/en\/create-e-invoices-command-line\/"},"modified":"2026-11-11T19:10:59","modified_gmt":"2026-11-11T19:10:59","slug":"create-e-invoices-command-line","status":"publish","type":"post","link":"https:\/\/help.pdf24.org\/en\/create-e-invoices-command-line\/","title":{"rendered":"Create e-invoices automatically: command line, JSON and XML"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">With the free PDF24 Creator you can create e-invoices (ZUGFeRD, Factur-X, XRechnung, Peppol) without filling in a form: one call of the PDF24 Toolbox turns a JSON or XML file from your program into a finished e-invoice. This lets you connect e-invoicing to your ERP, inventory system, Access, Excel or your own script. Everything runs locally on your PC.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This page describes the command, all switches, the JSON format with its required fields, and a complete example you can copy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Contents<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#voraussetzungen\">What you need<\/a><\/li>\n\n\n<li><a href=\"#wege\">Which way suits your program?<\/a><\/li>\n\n\n<li><a href=\"#aufruf\">The -createInvoice command<\/a><\/li>\n\n\n<li><a href=\"#schalter\">All switches and output formats<\/a><\/li>\n\n\n<li><a href=\"#xml\">XML as input: an existing XRechnung or ZUGFeRD XML<\/a><\/li>\n\n\n<li><a href=\"#json\">JSON as input: the format<\/a><\/li>\n\n\n<li><a href=\"#beispiele\">Examples: batch file and PowerShell<\/a><\/li>\n\n\n<li><a href=\"#access-excel\">E-invoices from Access, Excel or your ERP system<\/a><\/li>\n\n\n<li><a href=\"#exit-codes\">Exit codes and error messages<\/a><\/li>\n\n\n<li><a href=\"#typische-fehler\">Common mistakes<\/a><\/li>\n\n\n<li><a href=\"#pruefen\">Check the result<\/a><\/li>\n\n<\/ul>\n\n\n\n<h2 id=\"voraussetzungen\" class=\"wp-block-heading\">What you need<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>PDF24 Creator for Windows<\/strong>, free: <a href=\"https:\/\/tools.pdf24.org\/en\/creator\">Download PDF24 Creator<\/a>. Use the current version; some options on this page only exist from a certain version on, which is then stated.<\/li>\n\n\n<li><strong>The \"OpenJDK\" component<\/strong> (Java). It is preselected during installation. If you choose a custom installation, leave it ticked: without it there are no e-invoices on the command line.<\/li>\n\n\n<li><strong>The path to the PDF24 Toolbox.<\/strong> With a standard installation it is:<\/li>\n\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\Program Files\\PDF24\\pdf24-Toolbox.exe<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you installed PDF24 in a different folder, use the path from there. Always put the path in quotes because it contains spaces.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The e-invoice is created on your PC; PDF24 doesn't upload anything for it. Only if you give a logo or an attachment as an internet address in the invoice data does PDF24 download that file from there.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The examples on this page use the folder <code>C:\\Rechnungen<\/code> (\"Rechnungen\" is German for invoices) and German sample data. Replace them with your own folders and data.<\/p>\n\n\n\n<h2 id=\"wege\" class=\"wp-block-heading\">Which way suits your program?<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Your program already creates an XML invoice<\/strong> (XRechnung, ZUGFeRD or Factur-X as CII or UBL). Then give the XML as input. PDF24 turns it into a readable PDF with the XML embedded, or embeds the XML in your own PDF invoice. This is the easiest way because your program has already calculated the amounts correctly. See <a href=\"#xml\">XML as input<\/a>.<\/li>\n\n\n<li><strong>Your program can write a text file but no e-invoice XML.<\/strong> Then write the invoice data as a JSON file. PDF24 calculates totals and taxes itself and creates the PDF and the XML. See <a href=\"#json\">JSON as input<\/a>.<\/li>\n\n\n<li><strong>You don't want to program<\/strong>, but you have many invoices, e.g. in an Excel sheet. Then serial invoices in the e-invoice tool are easier: <a href=\"https:\/\/help.pdf24.org\/en\/e-invoice-types-credit-notes-series\/\">Serial invoices without programming<\/a>.<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">For single invoices by hand, use the \"Create electronic invoice\" tool in the PDF24 Toolbox or online: <a href=\"https:\/\/tools.pdf24.org\/en\/create-electronic-invoice\">Create electronic invoice<\/a>. For an overview, see the page <a href=\"https:\/\/help.pdf24.org\/en\/create-e-invoices-with-pdf24\/\">Create e-invoices with PDF24<\/a>.<\/p>\n\n\n\n<h2 id=\"aufruf\" class=\"wp-block-heading\">The -createInvoice command<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\"C:\\Program Files\\PDF24\\pdf24-Toolbox.exe\" -createInvoice INPUTFILE OUTPUTFILE -outputType FORMAT [more switches]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">An example that turns a JSON file into a ZUGFeRD invoice:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"C:\\Program Files\\PDF24\\pdf24-Toolbox.exe\" -createInvoice \"C:\\Rechnungen\\RE-2026-001.json\" \"C:\\Rechnungen\\RE-2026-001.pdf\" -outputType zugferd:en16931<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Important:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Right after <code>-createInvoice<\/code> come <strong>two paths<\/strong>: first the input file, then the output file. If you forget the output file, the Toolbox takes the next word as the file name (you then get e.g. a file called \"-outputType\").<\/li>\n\n\n<li>The <strong>input file<\/strong> must end in <code>.json<\/code> or <code>.xml<\/code>.<\/li>\n\n\n<li>The <strong>output file<\/strong> is saved under exactly the name you give, and an existing file is overwritten. Use <code>.pdf<\/code> for PDF and ZUGFeRD output and <code>.xml<\/code> for pure XML invoices; PDF24 doesn't change the extension.<\/li>\n\n\n<li>Paths with spaces belong in quotes. Ideally give full paths; then it doesn't matter from which folder your program starts the command.<\/li>\n\n\n<li>Without <code>-outputType<\/code> you only get a normal PDF invoice <strong>without<\/strong> XML, i.e. not an e-invoice.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The description in the PDF24 Creator manual is here: <a href=\"https:\/\/creator.pdf24.org\/manual\/11\/#914-create-invoices\">Manual, section Create invoices<\/a>.<\/p>\n\n\n\n<h2 id=\"schalter\" class=\"wp-block-heading\">All switches and output formats<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Write the switches as shown here, with the hyphen. Since version 11.34.0 upper and lower case don't matter (<code>-outputtype<\/code> works like <code>-outputType<\/code>), and an unknown or mistyped switch stops the command with a message and exit code 3. Up to version 11.33.0 upper and lower case matter, and a mistyped switch is not reported but skipped (see <a href=\"#typische-fehler\">Common mistakes<\/a>).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">-outputType: the output format<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>zugferd:en16931<\/code> \u2013 PDF with the embedded file <em>factur-x.xml<\/em> in the EN 16931 profile (ZUGFeRD\/Factur-X). The usual format for invoices to businesses.<\/li>\n\n\n<li><code>zugferd:xrechnung<\/code> \u2013 PDF with the embedded file <em>xrechnung.xml<\/em> (ZUGFeRD in the XRechnung profile).<\/li>\n\n\n<li><code>xrechnung:cii<\/code> \u2013 the XML file only, XRechnung in CII syntax.<\/li>\n\n\n<li><code>xrechnung:ubl<\/code> \u2013 the XML file only, XRechnung in UBL syntax.<\/li>\n\n\n<li><code>en16931:cii<\/code> \u2013 the XML file only, according to EN 16931, CII syntax.<\/li>\n\n\n<li><code>en16931:ubl<\/code> \u2013 the XML file only, according to EN 16931, UBL syntax.<\/li>\n\n\n<li><code>peppol:ubl<\/code> \u2013 the XML file only, for the Peppol network (Peppol BIS Billing 3.0, UBL).<\/li>\n\n\n<li><code>pdf<\/code> \u2013 only a readable PDF invoice without XML. This is <strong>not<\/strong> an e-invoice. This value applies if you leave out <code>-outputType<\/code>.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Which format your recipient needs is explained on the page <a href=\"https:\/\/help.pdf24.org\/en\/create-e-invoices-with-pdf24\/#format\">Create e-invoices with PDF24<\/a>. In Germany, public authorities usually require XRechnung, businesses often accept ZUGFeRD.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">-pdfFile: use your own PDF<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>-pdfFile \"C:\\Rechnungen\\RE-2026-001.pdf\"<\/code> \u2013 PDF24 then doesn't create its own PDF but takes yours, converts it to PDF\/A-3 and embeds the XML. This way the invoice keeps your layout and letterhead. Only useful together with a <code>zugferd:<\/code> format.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">-pdfaFile: use your PDF\/A-3 file<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>-pdfaFile \"C:\\Rechnungen\\RE-2026-001.pdf\"<\/code> \u2013 like <code>-pdfFile<\/code>, but without conversion. Only for files that are already PDF\/A-3. If in doubt, use <code>-pdfFile<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>-pdfFile<\/code> and <code>-pdfaFile<\/code> must always be followed by a path. If the switch stands alone at the end, the Toolbox reports it as an unknown option since version 11.34.0 (exit code 3); up to version 11.33.0 it is skipped.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">-passthrough: take over your XML unchanged<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Only for a <strong>CII XML<\/strong> as input with a <code>zugferd:<\/code> format. PDF24 then creates the PDF from the data in the XML but embeds your XML file unchanged instead of rewriting it. With <code>-pdfFile<\/code> or <code>-pdfaFile<\/code> you don't need this switch; your CII XML is then embedded unchanged anyway.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">-regenerateXml: rewrite the XML<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Only together with an XML input and <code>-pdfFile<\/code> or <code>-pdfaFile<\/code>. PDF24 then doesn't embed your XML unchanged but reads it and writes it anew. Since version 11.29.0.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">-langCode: language of the PDF<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>-langCode en<\/code> \u2013 the labels of the created PDF (e.g. \"Invoice\", \"Invoice Date\") in this language, e.g. <code>de<\/code>, <code>en<\/code> or <code>fr<\/code>. Without the switch the PDF is in German, so add <code>-langCode en<\/code> for English invoices. The XML is not affected. Since version 11.29.0.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">-langFile: your own labels<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>-langFile \"C:\\Rechnungen\\beschriftungen.txt\"<\/code> \u2013 a file with your own texts for the labels of the PDF. You can get a template for this file on request at team@pdf24.org. Since version 11.29.0.<\/p>\n\n\n\n<h2 id=\"xml\" class=\"wp-block-heading\">XML as input: an existing XRechnung or ZUGFeRD XML<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Toolbox reads XML invoices in CII and UBL syntax (XRechnung, ZUGFeRD\/Factur-X from profile EN 16931 up, Peppol). This lets you do the following:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A readable PDF from an XML invoice<\/strong> (e.g. to print a received XRechnung):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"C:\\Program Files\\PDF24\\pdf24-Toolbox.exe\" -createInvoice \"C:\\Rechnungen\\RE-4711.xml\" \"C:\\Rechnungen\\RE-4711-ansicht.pdf\" -outputType pdf<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Combine your PDF and your XML into a ZUGFeRD invoice:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"C:\\Program Files\\PDF24\\pdf24-Toolbox.exe\" -createInvoice \"C:\\Rechnungen\\RE-4711.xml\" \"C:\\Rechnungen\\RE-4711-zugferd.pdf\" -outputType zugferd:en16931 -pdfFile \"C:\\Rechnungen\\RE-4711.pdf\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A <strong>CII XML<\/strong> is embedded unchanged, a <strong>UBL XML<\/strong> is converted to CII (since version 11.31.0). Marking and file name follow your XML, not <code>-outputType<\/code>: an XRechnung stays an XRechnung (<em>xrechnung.xml<\/em>), even with <code>zugferd:en16931<\/code>, and an XML in the EXTENDED profile is marked as EXTENDED. More on the page <a href=\"https:\/\/help.pdf24.org\/en\/convert-pdf-invoice-to-e-invoice\/#welche-xml\">Convert a PDF invoice to an e-invoice: Which XML works?<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Turn an XML into a ZUGFeRD PDF with an invoice page created by PDF24:<\/strong> as above, but without <code>-pdfFile<\/code>. With <code>-passthrough<\/code> your CII XML stays unchanged.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Convert UBL to CII<\/strong> (or the other way round): give the XML as input and as the format e.g. <code>en16931:cii<\/code> or <code>xrechnung:ubl<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A logo or other settings for the PDF can't be passed with an XML input; the XML has no fields for them. If you need a logo: use your own PDF with the logo (<code>-pdfFile<\/code>) or supply the data as <a href=\"#json\">JSON<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">How to combine PDF and XML without the command line, in the Toolbox or online, is described on the page <a href=\"https:\/\/help.pdf24.org\/en\/convert-pdf-invoice-to-e-invoice\/\">Convert a PDF invoice to an e-invoice<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Directly when printing from your program<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If your program prints the invoice and writes the XML to a file, the PDF24 printer can combine both in one step:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the PDF24 settings, section \"PDF Printer\".<\/li>\n\n\n<li>Set saving to \"Automatically save documents after printed\" and tick \"Recognize control codes in the printed document\".<\/li>\n\n\n<li>Enter under \"Execute the following command after saving\":<\/li>\n\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>\"C:\\Program Files\\PDF24\\pdf24-Toolbox.exe\" -createInvoice $cmdArgs -outputType zugferd:en16931 -pdfFile \"$file\"<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Have your program print a control code on the invoice that names the XML file and the target file, e.g. <code>@@cmdargs:\"C:\\Rechnungen\\RE-4711.xml\" \"C:\\Rechnungen\\RE-4711-zugferd.pdf\"@@<\/code>.<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><code>$file<\/code> is the PDF just saved, <code>$cmdArgs<\/code> the content of the control code. Control codes are described in the <a href=\"https:\/\/creator.pdf24.org\/manual\/11\/\">manual<\/a> in the chapter on the PDF printer.<\/p>\n\n\n\n<h2 id=\"json\" class=\"wp-block-heading\">JSON as input: the format<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The JSON file uses the same format that the e-invoice tool saves when you export an invoice. But you don't have to supply everything: PDF24 calculates totals, tax amounts and much more itself.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Tip: create an invoice in the tool and export it<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The quickest way to see the format:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open \"Create electronic invoice\" in the PDF24 Toolbox, or online <a href=\"https:\/\/tools.pdf24.org\/en\/create-electronic-invoice\">Create electronic invoice<\/a>.<\/li>\n\n\n<li>Fill in a sample invoice, ideally with logo, attachment and everything you need.<\/li>\n\n\n<li>Open the menu at the top right (next to it it says \"Import, export, load, save, ...\") and choose \"Export invoice\".<\/li>\n\n\n<li>Open the saved JSON file in a text editor.<\/li>\n\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">With \"Import invoice\" in the same menu you load a JSON file back into the form, e.g. to see whether your program wrote it correctly.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1150\" height=\"370\" src=\"https:\/\/help.pdf24.org\/en\/wp-content\/uploads\/sites\/3\/2026\/11\/einvoice-command-line-menu-export-invoice.png\" alt=\"The open menu at the top right of the generator with Load invoice, Save invoice, Import invoice and Export invoice\" class=\"wp-image-66903\" srcset=\"https:\/\/help.pdf24.org\/en\/wp-content\/uploads\/sites\/3\/2026\/11\/einvoice-command-line-menu-export-invoice.png 1150w, https:\/\/help.pdf24.org\/en\/wp-content\/uploads\/sites\/3\/2026\/11\/einvoice-command-line-menu-export-invoice-300x97.png 300w, https:\/\/help.pdf24.org\/en\/wp-content\/uploads\/sites\/3\/2026\/11\/einvoice-command-line-menu-export-invoice-1024x329.png 1024w, https:\/\/help.pdf24.org\/en\/wp-content\/uploads\/sites\/3\/2026\/11\/einvoice-command-line-menu-export-invoice-768x247.png 768w\" sizes=\"auto, (max-width: 1150px) 100vw, 1150px\" \/><figcaption class=\"wp-element-caption\">With \"Export invoice\" you save the invoice as a JSON file<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Important: use the \"Create electronic invoice\" tool. The JSON file from the \"Create invoice\" tool (normal invoice without XML) has a different format and doesn't fit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you use an exported file as a template: delete the <code>\"totals\"<\/code> and <code>\"taxes\"<\/code> sections and, for the line items, <code>\"netAmount\"<\/code>, <code>\"taxAmount\"<\/code> and <code>\"grossAmount\"<\/code>. These are the results of the sample invoice. If they stay, PDF24 also takes them over for new line items, and the totals no longer add up (see <a href=\"#betraege\">Specified amounts<\/a>).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">A complete example<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This file produces a valid e-invoice in all eight formats (for Peppol see the electronic addresses below). Save it as UTF-8, e.g. as <code>C:\\Rechnungen\\RE-2026-001.json<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"number\": \"RE-2026-001\",\n    \"typeCode\": \"380\",\n    \"issueDate\": \"2026-11-11\",\n    \"dueDate\": \"2026-11-25\",\n    \"deliveryDate\": \"2026-11-10\",\n    \"currencyCode\": \"EUR\",\n    \"buyerReference\": \"PO-4711\",\n    \"seller\": {\n        \"name\": \"Muster GmbH\",\n        \"vatId\": \"DE123456789\",\n        \"electronicAddress\": \"rechnung@muster-gmbh.de\",\n        \"address\": {\n            \"line1\": \"Hauptstra\u00dfe 1\",\n            \"postCode\": \"10115\",\n            \"city\": \"Berlin\",\n            \"countryCode\": \"DE\"\n        },\n        \"contact\": {\n            \"name\": \"Max Mustermann\",\n            \"phone\": \"+49 30 123456\",\n            \"email\": \"max@muster-gmbh.de\"\n        }\n    },\n    \"buyer\": {\n        \"name\": \"Beispiel AG\",\n        \"electronicAddress\": \"eingang@beispiel-ag.de\",\n        \"address\": {\n            \"line1\": \"Marktplatz 5\",\n            \"postCode\": \"80331\",\n            \"city\": \"M\u00fcnchen\",\n            \"countryCode\": \"DE\"\n        }\n    },\n    \"payment\": {\n        \"terms\": \"Zahlbar bis [due_date] ohne Abzug.\",\n        \"methods\": [\n            {\n                \"typeCode\": \"58\",\n                \"iban\": \"DE02120300000000202051\",\n                \"accountName\": \"Muster GmbH\"\n            }\n        ]\n    },\n    \"items\": [\n        {\n            \"name\": \"Beratung\",\n            \"quantity\": 2,\n            \"unit\": \"HUR\",\n            \"netUnitPrice\": 120.00,\n            \"vatRate\": 19\n        },\n        {\n            \"name\": \"Fachbuch\",\n            \"quantity\": 5,\n            \"unit\": \"H87\",\n            \"netUnitPrice\": 4.99,\n            \"vatRate\": 7\n        }\n    ]\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">From this PDF24 calculates: line items 240.00 and 24.95 EUR, net 264.95 EUR, VAT 45.60 EUR (19 %) and 1.75 EUR (7 %), total and amount due 312.30 EUR. <code>[due_date]<\/code> becomes \"25.11.2026\" (the default date format; you can change it in <code>outputOptions<\/code>, see below).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Structure of the file<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The file is a JSON object with these sections (in brackets the number in the EN 16931 standard):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Invoice header:<\/strong> <code>number<\/code> invoice number (BT-1), <code>issueDate<\/code> invoice date (BT-2), <code>typeCode<\/code> invoice type (BT-3, default 380 = invoice), <code>currencyCode<\/code> currency (BT-5, e.g. <code>EUR<\/code>), <code>dueDate<\/code> due date (BT-9), <code>buyerReference<\/code> buyer reference, in Germany also the Leitweg-ID (BT-10), <code>deliveryDate<\/code> delivery date (BT-72), <code>billingPeriodStart<\/code> and <code>billingPeriodEnd<\/code> billing period (BT-73, BT-74), <code>buyerOrderReference<\/code> purchase order number (BT-13), <code>contractReference<\/code> contract number (BT-12), <code>projectReference<\/code> project number (BT-11), <code>notes<\/code> notes (BT-22, a text or a list of texts).<\/li>\n\n\n<li><strong><code>seller<\/code>, the invoice issuer:<\/strong> <code>name<\/code> (BT-27), <code>vatId<\/code> VAT ID (BT-31), <code>taxId<\/code> tax number (BT-32), <code>id<\/code> seller identifier (BT-29), <code>tradeId<\/code> trade register number (BT-30), <code>electronicAddress<\/code> electronic address (BT-34), <code>address<\/code>, <code>contact<\/code> (BG-6) with <code>name<\/code>, <code>phone<\/code>, <code>email<\/code>, plus <code>logoFile<\/code> for the logo.<\/li>\n\n\n<li><strong><code>buyer<\/code>, the invoice recipient:<\/strong> <code>name<\/code> (BT-44), <code>id<\/code> customer number (BT-46), <code>vatId<\/code> (BT-48), <code>electronicAddress<\/code> (BT-49), <code>address<\/code>, <code>contact<\/code>.<\/li>\n\n\n<li><strong><code>address<\/code><\/strong> (for seller and buyer): <code>line1<\/code>, <code>line2<\/code>, <code>line3<\/code> street and additional lines, <code>postCode<\/code>, <code>city<\/code>, <code>countryCode<\/code> (two letters, e.g. <code>DE<\/code>).<\/li>\n\n\n<li><strong><code>payment<\/code>:<\/strong> <code>terms<\/code> payment terms (BT-20), <code>reference<\/code> remittance information (BT-83), <code>methods<\/code> a list of payment means with <code>typeCode<\/code> (BT-81, e.g. <code>58<\/code> SEPA credit transfer, <code>59<\/code> SEPA direct debit, <code>10<\/code> cash), <code>iban<\/code>, <code>bic<\/code>, <code>accountName<\/code> account holder, for direct debit <code>directDebitMandate<\/code> and <code>creditorId<\/code>.<\/li>\n\n\n<li><strong><code>items<\/code>, the line items<\/strong>, per item: <code>name<\/code> (BT-153), <code>description<\/code> (BT-154), <code>quantity<\/code> (BT-129), <code>unit<\/code> unit code (BT-130, e.g. <code>H87<\/code> piece, <code>HUR<\/code> hour, <code>C62<\/code> unit; default <code>H87<\/code>), <code>netUnitPrice<\/code> net price per unit (BT-146), <code>vatRate<\/code> tax rate in percent (BT-152), <code>vatCode<\/code> tax category (BT-151), <code>sellerId<\/code> item number (BT-155), <code>quantityUnitSymbol<\/code> abbreviation for the PDF (e.g. \"hrs\" instead of \"HUR\"), <code>allowances<\/code> and <code>charges<\/code> for allowances and charges on the item.<\/li>\n\n\n<li><strong><code>allowances<\/code> and <code>charges<\/code><\/strong> at invoice level: allowances (BG-20) and charges (BG-21) such as shipping costs.<\/li>\n\n\n<li><strong><code>attachments<\/code>:<\/strong> supporting documents (BG-24).<\/li>\n\n\n<li><strong><code>outputOptions<\/code>:<\/strong> settings for the PDF, see below.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Write dates as <code>2026-11-11<\/code> (<code>11.11.2026<\/code> is also read). Amounts and quantities are JSON numbers with a decimal point and without quotes.<\/p>\n\n\n\n<h3 id=\"pflichtfelder\" class=\"wp-block-heading\">Required fields<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">PDF24 doesn't check on the call whether all required details are there. If something is missing, a file is still created, which the recipient then rejects. Which details are required depends on the chosen format. For a normal invoice with VAT the following applies (tested with the official validation rules):<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>For all formats (ZUGFeRD <code>zugferd:en16931<\/code>, <code>en16931:cii<\/code>, <code>en16931:ubl<\/code>):<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>number<\/code>, <code>issueDate<\/code>, <code>currencyCode<\/code><\/li>\n\n\n<li><code>deliveryDate<\/code> or <code>billingPeriodStart<\/code>\/<code>billingPeriodEnd<\/code> (required for ZUGFeRD, recommended for XRechnung)<\/li>\n\n\n<li><code>dueDate<\/code> or <code>payment.terms<\/code><\/li>\n\n\n<li>for the seller <code>name<\/code> and <code>address<\/code> with <code>countryCode<\/code>, plus <code>vatId<\/code> (or, for invoices without VAT, <code>taxId<\/code> and <code>id<\/code>, see below)<\/li>\n\n\n<li>for the buyer <code>name<\/code> and <code>address<\/code> with <code>countryCode<\/code><\/li>\n\n\n<li>per line item <code>name<\/code>, <code>quantity<\/code>, <code>netUnitPrice<\/code> and <code>vatRate<\/code><\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The standard doesn't require the postcode (<code>postCode<\/code>) and city (<code>city<\/code>) yet; give them anyway, they belong in every complete address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Additionally for XRechnung (<code>xrechnung:cii<\/code>, <code>xrechnung:ubl<\/code>, <code>zugferd:xrechnung<\/code>), the German format:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>postCode<\/code> and <code>city<\/code> in the <code>address<\/code> of seller and buyer<\/li>\n\n\n<li><code>buyerReference<\/code>, for German public authorities the Leitweg-ID<\/li>\n\n\n<li><code>seller.contact<\/code> with <code>name<\/code>, <code>phone<\/code> and <code>email<\/code><\/li>\n\n\n<li><code>seller.electronicAddress<\/code> and <code>buyer.electronicAddress<\/code><\/li>\n\n\n<li><code>payment.methods<\/code> with at least one payment means, for credit transfer with <code>iban<\/code><\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If these details are missing, validators report XRechnung rules such as BR-DE-15 (buyer reference BT-10 missing), BR-DE-2 (seller contact BG-6 missing) or BR-DE-1 (payment instructions BG-16 missing). The XRechnung rule texts are in German, e.g. \"[BR-DE-15] Das Element \"Buyer reference\" (BT-10) muss \u00fcbermittelt werden.\". What such messages mean is explained on the page <a href=\"https:\/\/help.pdf24.org\/en\/e-invoice-validation-errors\/\">E-invoice validation errors and common problems<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Additionally for Peppol (<code>peppol:ubl<\/code>):<\/strong> like XRechnung, the electronic addresses, but with a Peppol scheme, see the next section. If the seller is based in Germany, additional German rules apply in Peppol which, among other things, require <code>postCode<\/code> and <code>city<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Electronic address and scheme<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Without further details, the electronic address (<code>electronicAddress<\/code>) is an e-mail address (scheme <code>EM<\/code>). That is enough for XRechnung and ZUGFeRD. Peppol doesn't allow <code>EM<\/code>; there you give the scheme with <code>electronicAddressScheme<\/code>, e.g. <code>9930<\/code> for a German VAT ID, <code>0204<\/code> for a Leitweg-ID or <code>0088<\/code> for a GLN:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"electronicAddress\": \"DE123456789\",\n\"electronicAddressScheme\": \"9930\"<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Which address and which scheme your recipient expects, you find out from them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What PDF24 calculates itself<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Leave these fields out and PDF24 calculates them:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>per line item the net amount (quantity \u00d7 price, minus allowances, plus charges), the VAT and the gross amount<\/li>\n\n\n<li>the tax category of a line item: <code>S<\/code> (standard rate) for a tax rate above 0, <code>E<\/code> (exempt) for 0<\/li>\n\n\n<li>the VAT breakdown per tax rate (BG-23)<\/li>\n\n\n<li>all totals: sum of line items, allowances, charges, net, VAT, gross and the amount due (BT-106 to BT-115)<\/li>\n\n\n<li>allowances and charges with <code>percent<\/code>: base amount and amount<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In the payment terms (<code>terms<\/code>) PDF24 replaces placeholders: <code>[due_date]<\/code> or <code>[F\u00e4lligkeitsdatum]<\/code>, <code>[due_amount]<\/code> or <code>[Endbetrag]<\/code>, <code>[invoice_number]<\/code> or <code>[Rechnungsnummer]<\/code>, <code>[issue_date]<\/code> or <code>[Rechnungsdatum]<\/code>, <code>[IBAN]<\/code>. In the remittance information (<code>reference<\/code>), <code>[invoice_number]<\/code> and <code>[Kundennummer]<\/code> work.<\/p>\n\n\n\n<h3 id=\"betraege\" class=\"wp-block-heading\">Specified amounts are not recalculated<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you supply amounts, such as the <code>netAmount<\/code> of a line item or the <code>totals<\/code> or <code>taxes<\/code> section, PDF24 takes them over <strong>as they are<\/strong> and doesn't recalculate them. If they don't match the line items, you get an invoice with wrong totals that validators reject, e.g. with \"[BR-CO-14] Invoice total VAT amount (BT-110) = \u03a3 VAT category tax amount (BT-117)\" or, with allowances, with Peppol rules such as R120 and R040.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So: <strong>either supply amounts that are consistent, or leave them out<\/strong> and let PDF24 calculate. Leaving them out is the safe way. Exception: if your program rounds differently and the invoice must show exactly your amounts, supply all amounts completely.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Allowances and charges<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A discount on a line item:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{ \"name\": \"Beratung\", \"quantity\": 2, \"unit\": \"HUR\", \"netUnitPrice\": 120.00, \"vatRate\": 19,\n  \"allowances\": [ { \"percent\": 10, \"reason\": \"Rabatt\" } ] }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Shipping costs as a charge on the whole invoice, at the same level as <code>items<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"charges\": [ { \"netAmount\": 5.90, \"reason\": \"Versand\", \"vatCode\": \"S\", \"vatRate\": 19 } ]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For allowances and charges at invoice level, <strong>always give <code>vatCode<\/code> and <code>vatRate<\/code><\/strong>. Unlike for line items, PDF24 doesn't derive the tax category from the tax rate there; without <code>vatCode<\/code> validators reject the invoice. Allowances on a line item take over the tax of the line item.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Logo and attachments<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On the command line, the logo and attachments may point to files on your PC; you don't have to base64-encode them:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"seller\": {\n    \"name\": \"Muster GmbH\",\n    \"logoFile\": \"C:\\\\Rechnungen\\\\logo.png\",\n    ...\n},\n\"attachments\": [\n    {\n        \"file\": \"C:\\\\Rechnungen\\\\Leistungsnachweis.pdf\",\n        \"filename\": \"Leistungsnachweis.pdf\",\n        \"description\": \"Leistungsnachweis Oktober\"\n    }\n]<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In JSON every backslash is doubled: <code>C:\\\\Rechnungen\\\\logo.png<\/code>.<\/li>\n\n\n<li>Instead of <code>logoFile<\/code> you can use <code>logoUrl<\/code> (internet address), instead of <code>file<\/code> you can use <code>url<\/code>. An exported file contains the logo and attachments base64-encoded (<code>logoData<\/code>, <code>base64<\/code>); that works too.<\/li>\n\n\n<li>Always give <code>filename<\/code> for an attachment. Without the name, the creation aborts.<\/li>\n\n\n<li>File paths and internet addresses are only read when called with <code>-createInvoice<\/code>. If you open such a JSON file in PDF24 Creator, the logo and attachments from file paths are left out (since version 11.31.0, so that someone else's invoice data can't bring files from your PC into a PDF).<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The attachments are embedded in the ZUGFeRD PDF as files next to the XML and are listed on the invoice under \"Attachments\" (with German labels \"Anlagen\").<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Appearance of the PDF: outputOptions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">With the <code>outputOptions<\/code> section you control the created PDF, e.g.:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"outputOptions\": {\n    \"addressWindowMode\": \"din5008\",\n    \"logoSizeMode\": \"large\",\n    \"noteSubjectCodeDisplayMode\": \"hidden\",\n    \"langCode\": \"en\"\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\"addressWindowMode\": \"din5008\"<\/code> \u2013 layout according to the German standard DIN 5008 for window envelopes<\/li>\n\n\n<li><code>\"logoSizeMode\"<\/code>: <code>\"large\"<\/code> or <code>\"xlarge\"<\/code> \u2013 larger logo; <code>\"logoDisplayMode\": \"right\"<\/code> \u2013 logo on the right above the payment details<\/li>\n\n\n<li><code>\"noteSubjectCodeDisplayMode\": \"hidden\"<\/code> \u2013 hide codes such as \"AAB\" in front of the notes<\/li>\n\n\n<li><code>\"quantityUnitDisplayMode\": \"hidden\"<\/code> \u2013 no unit after the quantity<\/li>\n\n\n<li><code>\"langCode\"<\/code> \u2013 language of the PDF, like the <code>-langCode<\/code> switch<\/li>\n\n\n<li><code>\"dateFormat\"<\/code> \u2013 date format of the PDF: <code>\"dd.mm.yyyy\"<\/code> (default), <code>\"dd\/mm\/yyyy\"<\/code>, <code>\"mm\/dd\/yyyy\"<\/code>, <code>\"yyyy-mm-dd\"<\/code> or <code>\"yyyy\/mm\/dd\"<\/code>; <code>\"decimalSeparator\"<\/code> \u2013 e.g. <code>\".\"<\/code> instead of the default comma in amounts on the PDF. The XML is not affected.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The easiest way is to set the output options in the tool, export an invoice and take the <code>outputOptions<\/code> section from the file. A completely custom layout isn't possible via JSON. For that, create the PDF yourself and pass it with <code>-pdfFile<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Invoice without VAT (e.g. small businesses in Germany)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For invoices without VAT, set <code>\"vatRate\": 0<\/code> for every line item (PDF24 then chooses category <code>E<\/code>, exempt) and give the reason at the top level. If the seller has no VAT ID, enter the tax number in <code>taxId<\/code> and a seller identifier in <code>id<\/code> (e.g. the company name), otherwise validation reports BR-CO-26. The example shows the wording used by small businesses in Germany (\u00a7 19 UStG):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"taxExemptionReason\": \"Kein Ausweis von Umsatzsteuer, da Kleinunternehmer gem\u00e4\u00df \u00a7 19 UStG\",\n\"seller\": {\n    \"name\": \"Muster GmbH\",\n    \"taxId\": \"12\/345\/67890\",\n    \"id\": \"Muster GmbH\",\n    ...\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Which tax category and which wording are right for your invoices, your tax advisor will tell you.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Notes on writing the file<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Character set UTF-8.<\/strong> In a file in the Windows character set (ANSI), umlauts and other special characters silently turn into wrong characters. UTF-8 with or without BOM both work.<\/li>\n\n\n<li><strong>Numbers without quotes and with a decimal point:<\/strong> <code>\"netUnitPrice\": 120.50<\/code>. An amount as text (<code>\"120.50\"<\/code>) is silently read as 0, a comma (<code>120,50<\/code>) makes the file invalid.<\/li>\n\n\n<li><strong>Texts with quotes or backslashes<\/strong> must be escaped: <code>\\\"<\/code> and <code>\\\\<\/code>. A line break in a text becomes <code>\\n<\/code>.<\/li>\n\n\n<li><strong>Only real JSON:<\/strong> no comments, no comma after the last entry of a list.<\/li>\n\n<\/ul>\n\n\n\n<h2 id=\"beispiele\" class=\"wp-block-heading\">Examples: batch file and PowerShell<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">All JSON files in a folder (batch file)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Save this as <code>erechnungen.cmd<\/code>. It creates a ZUGFeRD PDF with the same name in <code>C:\\Rechnungen\\pdf<\/code> from every JSON file in <code>C:\\Rechnungen\\json<\/code> and writes errors to a log file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@echo off\nset TOOLBOX=\"C:\\Program Files\\PDF24\\pdf24-Toolbox.exe\"\nfor %%f in (\"C:\\Rechnungen\\json\\*.json\") do (\n  %TOOLBOX% -createInvoice \"%%f\" \"C:\\Rechnungen\\pdf\\%%~nf.pdf\" -outputType zugferd:en16931 &gt;&gt; \"C:\\Rechnungen\\protokoll.txt\" 2&gt;&amp;1\n  if errorlevel 1 echo Error with %%~nxf &gt;&gt; \"C:\\Rechnungen\\fehler.txt\"\n)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In a batch file, Windows waits each time until the Toolbox has finished before the next invoice starts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Combine PDF and XML in pairs (batch file)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If a folder contains a PDF and an XML with the same name for each invoice (<code>RE-4711.pdf<\/code>, <code>RE-4711.xml<\/code>), this creates one <code>RE-4711-zugferd.pdf<\/code> each:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@echo off\nset TOOLBOX=\"C:\\Program Files\\PDF24\\pdf24-Toolbox.exe\"\nfor %%f in (\"C:\\Rechnungen\\paare\\*.xml\") do (\n  if exist \"%%~dpnf.pdf\" %TOOLBOX% -createInvoice \"%%f\" \"%%~dpnf-zugferd.pdf\" -outputType zugferd:en16931 -pdfFile \"%%~dpnf.pdf\"\n)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">All JSON files in a folder (PowerShell)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In PowerShell the simple call with <code>&amp;<\/code> does <strong>not<\/strong> wait until the Toolbox has finished. So use <code>Start-Process<\/code> with <code>-Wait<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$toolbox = 'C:\\Program Files\\PDF24\\pdf24-Toolbox.exe'\nGet-ChildItem 'C:\\Rechnungen\\json\\*.json' | ForEach-Object {\n    $out = Join-Path 'C:\\Rechnungen\\pdf' ($_.BaseName + '.pdf')\n    $p = Start-Process -FilePath $toolbox -Wait -PassThru -NoNewWindow `\n        -ArgumentList \"-createInvoice `\"$($_.FullName)`\" `\"$out`\" -outputType zugferd:en16931\"\n    if ($p.ExitCode -ne 0) { Write-Warning \"Error with $($_.Name)\" }\n}<\/code><\/pre>\n\n\n\n<h2 id=\"access-excel\" class=\"wp-block-heading\">E-invoices from Access, Excel or your ERP system<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There is no ready-made connection for Access or particular ERP systems, but the way is always the same: your program writes the invoice data as a JSON file (or an XML invoice) and then calls the Toolbox. It's important that your program <strong>waits<\/strong> until the Toolbox has finished and evaluates the exit code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Access and Excel (VBA)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A template is convenient: export a sample invoice from the e-invoice tool (see <a href=\"#json\">tip above<\/a>), delete <code>totals<\/code>, <code>taxes<\/code> and the amounts of the line items, replace the changing values with placeholders such as <code>\"{{NUMMER}}\"<\/code> and the line items with <code>\"items\": []<\/code>. Your fixed details (company, bank details, logo) stay in the template.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This module fills the template, saves the JSON file as UTF-8 and creates the ZUGFeRD invoice:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Private Const TOOLBOX As String = \"C:\\Program Files\\PDF24\\pdf24-Toolbox.exe\"\n\n' Escape text for JSON (without the surrounding quotes)\nPublic Function JsonText(ByVal text As String) As String\n    text = Replace(text, \"\\\", \"\\\\\")\n    text = Replace(text, \"\"\"\", \"\\\"\"\")\n    text = Replace(text, vbCrLf, \"\\n\")\n    text = Replace(text, vbLf, \"\\n\")\n    text = Replace(text, vbCr, \"\\n\")\n    text = Replace(text, vbTab, \"\\t\")\n    JsonText = text\nEnd Function\n\n' Number for JSON: always with a decimal point, whatever the regional settings\nPublic Function JsonNum(ByVal wert As Double) As String\n    JsonNum = Replace(Format(wert, \"0.00##\"), \",\", \".\")\nEnd Function\n\nPrivate Function LeseUtf8(ByVal pfad As String) As String\n    With CreateObject(\"ADODB.Stream\")\n        .Type = 2: .Charset = \"utf-8\": .Open\n        .LoadFromFile pfad\n        LeseUtf8 = .ReadText\n        .Close\n    End With\nEnd Function\n\nPrivate Sub SpeichereUtf8(ByVal pfad As String, ByVal inhalt As String)\n    With CreateObject(\"ADODB.Stream\")\n        .Type = 2: .Charset = \"utf-8\": .Open\n        .WriteText inhalt\n        .SaveToFile pfad, 2\n        .Close\n    End With\nEnd Sub\n\n' Starts the Toolbox, waits for it to finish and returns True if the file was created\nPublic Function ErzeugeERechnung(ByVal jsonDatei As String, ByVal pdfDatei As String) As Boolean\n    Dim befehl As String\n    befehl = \"\"\"\" &amp; TOOLBOX &amp; \"\"\" -createInvoice \"\"\" &amp; jsonDatei &amp; \"\"\" \"\"\" &amp; pdfDatei &amp; _\n             \"\"\" -outputType zugferd:en16931\"\n    ' 0 = no window, True = wait; the return value is the exit code\n    ErzeugeERechnung = (CreateObject(\"WScript.Shell\").Run(befehl, 0, True) = 0)\nEnd Function<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example for Access with a table <code>Rechnungen<\/code> (invoices) and a table <code>Positionen<\/code> (line items); adapt the field names to your database:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Public Sub RechnungAlsERechnung(ByVal rechnungId As Long)\n    Dim re As DAO.Recordset, pos As DAO.Recordset\n    Dim positionen As String, json As String, nr As String\n\n    Set re = CurrentDb.OpenRecordset(\"SELECT * FROM Rechnungen WHERE ID = \" &amp; rechnungId)\n    Set pos = CurrentDb.OpenRecordset(\"SELECT * FROM Positionen WHERE RechnungID = \" &amp; rechnungId)\n    nr = Nz(re!RechnungsNr, \"\")\n\n    Do Until pos.EOF\n        If Len(positionen) &gt; 0 Then positionen = positionen &amp; \",\"\n        positionen = positionen &amp; \"{\"\"name\"\": \"\"\" &amp; JsonText(Nz(pos!Bezeichnung, \"\")) &amp; \"\"\"\" &amp; _\n            \", \"\"quantity\"\": \" &amp; JsonNum(pos!Menge) &amp; _\n            \", \"\"unit\"\": \"\"H87\"\"\" &amp; _\n            \", \"\"netUnitPrice\"\": \" &amp; JsonNum(pos!Einzelpreis) &amp; _\n            \", \"\"vatRate\"\": \" &amp; JsonNum(pos!MwStSatz) &amp; \"}\"\n        pos.MoveNext\n    Loop\n\n    json = LeseUtf8(\"C:\\Rechnungen\\vorlage.json\")\n    json = Replace(json, \"{{NUMMER}}\", JsonText(nr))\n    json = Replace(json, \"{{DATUM}}\", Format(re!Rechnungsdatum, \"yyyy-mm-dd\"))\n    json = Replace(json, \"{{LEISTUNGSDATUM}}\", Format(re!Leistungsdatum, \"yyyy-mm-dd\"))\n    json = Replace(json, \"{{KUNDE}}\", JsonText(Nz(re!Kundenname, \"\")))\n    json = Replace(json, \"\"\"items\"\": []\", \"\"\"items\"\": [\" &amp; positionen &amp; \"]\")\n\n    SpeichereUtf8 \"C:\\Rechnungen\\\" &amp; nr &amp; \".json\", json\n    If Not ErzeugeERechnung(\"C:\\Rechnungen\\\" &amp; nr &amp; \".json\", \"C:\\Rechnungen\\\" &amp; nr &amp; \".pdf\") Then\n        MsgBox \"The e-invoice \" &amp; nr &amp; \" could not be created.\"\n    End If\nEnd Sub<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The same module works in Excel. Instead of the records, read the values from the cells, e.g. <code>Cells(zeile, 2).Value<\/code>, and leave out <code>Nz(...)<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Notes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Shell(...)<\/code> doesn't wait and returns no exit code. Use <code>CreateObject(\"WScript.Shell\").Run(befehl, 0, True)<\/code> as above.<\/li>\n\n\n<li><code>Print #<\/code> writes in the Windows character set, not in UTF-8. Use <code>ADODB.Stream<\/code> for writing as above.<\/li>\n\n\n<li><code>Format(wert, \"0.00\")<\/code> writes a comma with German and many other regional settings. That's why <code>JsonNum<\/code> replaces the comma with a point.<\/li>\n\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">ERP, inventory systems and your own programs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Any programming language that can write a file and start a program can create e-invoices this way. If your program can output XRechnung or ZUGFeRD XML (CII) itself, use this XML as input; then you don't have to write any JSON. If in doubt, ask the vendor of your software.<\/p>\n\n\n\n<h2 id=\"exit-codes\" class=\"wp-block-heading\">Exit codes and error messages<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Since version 11.33.0 the Toolbox reports the result via the exit code:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>0<\/code> \u2013 the output file was written.<\/li>\n\n\n<li><code>1<\/code> \u2013 no file was written. The message gives the reason, e.g. <code>Input file does not exist: \u2026<\/code> or <code>Invoice creation failed, no file written: \u2026<\/code>. Above it is the error message of the processing, e.g. for a typo in the JSON <code>MalformedJsonException: Unterminated object at line 3 column 6 path $.number<\/code> with line and column.<\/li>\n\n\n<li><code>3<\/code> \u2013 an unknown or mistyped switch (since version 11.34.0). The message names it, e.g. <code>pdf24-Toolbox.exe: unknown option: -ouputType<\/code>; no file is written.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In older versions the exit code was always 0. There, check whether the output file has been newly created, or update PDF24.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The messages appear in the console from which you start the Toolbox. Error messages from the processing go to the error output (stderr). In a batch file you redirect both into a file with <code>&gt;&gt; protokoll.txt 2&gt;&amp;1<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Important:<\/strong> exit code 0 only means that a file was created. Whether the e-invoice meets all rules is not checked by the command. See <a href=\"#pruefen\">Check the result<\/a>.<\/p>\n\n\n\n<h2 id=\"typische-fehler\" class=\"wp-block-heading\">Common mistakes<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A PDF is created, but without XML.<\/strong> Then <code>-outputType<\/code> is missing. Since version 11.34.0 the Toolbox points this out (<code>Note: no -outputType given - a plain PDF invoice is created, without e-invoice XML.<\/code>), reports a mistyped switch such as <code>-ouputType<\/code> as an unknown option with exit code 3 and accepts <code>-outputtype<\/code> or <code>-OutputType<\/code> in any upper and lower case. Up to version 11.33.0 the Toolbox skips unknown switches without a message and then creates a normal PDF; there the problem also occurs if <code>-outputType<\/code> is mistyped (e.g. <code>-ouputType<\/code>) or written differently (<code>-outputtype<\/code>, <code>-OutputType<\/code>). Check the spelling carefully or update to 11.34.0 or later.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A file called \"-outputType\" is created.<\/strong> The output file is missing in the command; the Toolbox took the next word as the file name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><code>-pdfaFile<\/code> or <code>-pdfFile<\/code> without a path.<\/strong> These switches must be followed by your PDF. If PDF24 should create the PDF itself, leave the switch out completely.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><code>-outputType zugferd<\/code> without a suffix.<\/strong> This gives ZUGFeRD in the XRechnung profile with <em>xrechnung.xml<\/em>. For the EN 16931 profile with <em>factur-x.xml<\/em>, write <code>zugferd:en16931<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The JSON file comes from \"Create invoice\".<\/strong> The tool for normal invoices uses a different JSON format. Export from \"Create electronic invoice\".<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Totals wrong although the line items are correct.<\/strong> The file still contains <code>totals<\/code>, <code>taxes<\/code> or <code>netAmount<\/code> from a template. Delete these fields (see <a href=\"#betraege\">Specified amounts<\/a>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A price is 0.<\/strong> The amount is in quotes. Write it as a number.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Umlauts or accents wrong.<\/strong> The file isn't saved as UTF-8.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Error \"Could not read invoice data file\".<\/strong> The input file doesn't end in <code>.json<\/code> or <code>.xml<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Error \"Unsupported date format\".<\/strong> A date has a format other than <code>2026-11-11<\/code> or <code>11.11.2026<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Abort with attachments.<\/strong> An attachment is missing <code>filename<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The program continues before the invoice is finished.<\/strong> PowerShell with <code>&amp;<\/code> or VBA with <code>Shell<\/code> don't wait. Use <code>Start-Process -Wait<\/code> or <code>WScript.Shell.Run \u2026 , True<\/code> (see <a href=\"#beispiele\">Examples<\/a> and <a href=\"#access-excel\">Access\/Excel<\/a>).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The recipient rejects the invoice.<\/strong> Required details of the format are missing, e.g. the Leitweg-ID or the contact for an XRechnung. See <a href=\"#pflichtfelder\">Required fields<\/a> and the page <a href=\"https:\/\/help.pdf24.org\/en\/e-invoice-validation-errors\/\">E-invoice validation errors and common problems<\/a>.<\/p>\n\n\n\n<h2 id=\"pruefen\" class=\"wp-block-heading\">Check the result<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check the first invoices your program creates, and again after every change to the process:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In the PDF24 Toolbox with the \"Validate e-invoice\" tool, or online: <a href=\"https:\/\/tools.pdf24.org\/en\/validate-e-invoice\">Validate e-invoice<\/a>. Both check XRechnung, ZUGFeRD\/Factur-X and Peppol, as XML or PDF, with the official rules and explain the messages.<\/li>\n\n\n<li>Whether a PDF contains an XML you can see in the PDF24 Reader under \"Attachments\" (in Adobe Acrobat Reader also under \"Attachments\", the paperclip). <em>factur-x.xml<\/em> or <em>xrechnung.xml<\/em> must be listed there.<\/li>\n\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If something doesn't work as described here, write to us at team@pdf24.org. Send the complete command, the input file (feel free to change names and amounts) and the messages from the console.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create ZUGFeRD, Factur-X and XRechnung on the command line: all -createInvoice switches, JSON format, XML input, examples for batch, PowerShell, Access.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,4],"tags":[],"class_list":["post-66888","post","type-post","status-publish","format-standard","hentry","category-creator","category-online-tools"],"_links":{"self":[{"href":"https:\/\/help.pdf24.org\/en\/wp-json\/wp\/v2\/posts\/66888","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.pdf24.org\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/help.pdf24.org\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/help.pdf24.org\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.pdf24.org\/en\/wp-json\/wp\/v2\/comments?post=66888"}],"version-history":[{"count":2,"href":"https:\/\/help.pdf24.org\/en\/wp-json\/wp\/v2\/posts\/66888\/revisions"}],"predecessor-version":[{"id":66921,"href":"https:\/\/help.pdf24.org\/en\/wp-json\/wp\/v2\/posts\/66888\/revisions\/66921"}],"wp:attachment":[{"href":"https:\/\/help.pdf24.org\/en\/wp-json\/wp\/v2\/media?parent=66888"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/help.pdf24.org\/en\/wp-json\/wp\/v2\/categories?post=66888"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/help.pdf24.org\/en\/wp-json\/wp\/v2\/tags?post=66888"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}