Print ZUGFeRD compliant PDF invoices / PDF Printer
How you can create ZUGFeRD compliant PDF invoices (France Factur-X) with our PDF printer, we show you in this chapter of our manual.
The core application is, as always, our PDF printer, because as a basis for ZUGFeRD compliant PDF documents it offers the creation of PDF/A-1b files. This PDF specification is the basis for attaching further files to PDF documents, in the case of ZUGFeRD these are XML files.
7-PDF Printer and Mustang-CLI-x.x.x.jar
The process of attaching so-called XML invoices (eInvoices) to PDF files is as follows: 7-PDF Printer first prints the necessary PDF/A-1b document in PDF format 1.7, and with Mustang-CLI-x.x.x.jar
, a Java-based library (OpenSource / under Apache license) for generating ZUGFeRD-compliant data and PDF files, we attach the desired XML invoice file to the PDF. The JAR archive can be used as a console application. This is exactly the option we will use. With the VBScript Framework of the 7-PDF Printer we program, a few lines macro, which executes Mustang-CLI-x.x.x.jar
per console command automatically.
Invoice printing in the real world is usually done from an ERP system to 7-PDF Printer. We will let 7-PDF Printer read the print data from the ERP in order to automatically reference and attach a matching XML invoice file (eInvoice) provided by the ERP system via the extract of the invoice number contained therein. We also place this part of the programming in the VBScript macro. The necessary steps to this outlined solution we now illustrate for you in detail.
The screenshot below is purely for your information, and shows the possible parameters to control the JAR archive Mustang-CLI-x.x.x.jar
as a console application:
Mustang CLI in the Windows 11 command prompt.
All possible console parameters and further info about the Mustang project and a possibility to download the JAR archive Mustang-CLI-x.x.x.jar
for free can be found on this website.
IMPORTANT: Prerequisite for the successful attachment of files to PDF documents is, however, that you have a current OpenJDK installation on your system. OpenJDK can be downloaded and installed for free (GPL license) from this Microsoft download page. In our case documented here, we used microsoft-jdk-17.35.1-windows-x64.msi.
Use "Mustang-CLI-x.x.x.jar" with 7-PDF Printer
To now fully automatically print ZUGFeRD compliant PDF invoices with our PDF printer 7-PDF Printer, the application Mustang-CLI-x.x.x.jar
must be copied into the installation directory of our PDF printer beforehand. In the screenshot below this has already been done.
Mustang-CLI-x.x.x.jar
was copied to the installation directory of our PDF printer.
Create ZUGFeRD PDF automatically with 7-PDF Printer
If Mustang-CLI-x.x.x.jar
is copied to the installation directory, we still need the macro ZUGFeRD.vbs
needed for a fully automatic creation of ZUGFeRD compliant PDF files with 7-PDF Printer.
You will find below in the download table a ZIP archive with the name PlugIn_ZUGFeRD_7PDF_Printer.zip
which contains this macro and other files needed to test this chapter. As usual with our PDF printer the macro ZUGFeRD.vbs
belongs in the macros folder. So copy the VBS file into this directory.
ZUGFeRD.vbs macro must be placed in the macros folder of the 7-PDF Printer
The macro automatically calls Mustang-CLI-x.x.x.jar
after printing the required PDF/A-1b document and automatically appends the ZUGFeRD compliant XML invoice file to the printed PDF.
The really important line is the second to last line in the VB Script macro. Here Mustang-CLI-x.x.x.jar
is called from the 7-PDF Printer in Hidden Mode, and all the parameters necessary for appending the XML invoice (eInvoice). The path may need to be adjusted for older Windows versions and other OpenJDK installation paths to your system configuration.
Simulated invoice printing
As a simulation example we use the following sample calculation (downloadable below). For this test or example, the printing is done from Word, normally such a printing is done from an ERP system or a merchandise management to 7-PDF printer.
Example invoice with invoice number marked in red.
Note: The sample calculation is also available as a download below.
The invoice number is marked red in the invoice document for your pure illustration, because this part of the print data extracts the macro placed above ZUGFeRD.vbs
to pass the appropriate ZUGFeRD XML file for the print data, which was previously stored by the ERP system in C:\einvoices
, to Mustang-CLI-x.x.x.jar
so that it appends the XML to the generated PDF/A-1b file (finally this becomes a PDF/A-3U file). So there is a ZUGFeRD compliant XML file in this directory with the name 2021-09-1001.xml
.
In the above mentioned ZIP archive with the name PlugIn_ZUGFeRD_7PDF_Printer.zip
(download via download table below) you will also find a directory einvoices
which should enable you to run through our example shown here.
In this directory, the ERP has previously stored the XML ZUGFeRD data per invoice as an example. The file name is equal to the invoice number from the print data and is extracted by the macro ZUGFeRD.vbs
and passed to Mustang-CLI-x.x.x.jar
.
Start simulation
We hold: Mustang-CLI-x.x.x.jar
is in the InstallRoot of the installed 7-PDF Printer, ZUGFeRD.vbs
in the Macros
directory, and the einvoices
directory is unpacked directly under C:\
. OpenJDK is installed and the path adjusted to your system config in ZUGFeRD.vbs
if necessary. Then we print now to the simulation from Word our example calculation on the 7-PDF printer.
We will now print our sample calculation from Word on the 7-PDF printer for simulation.
The print dialog of our PDF printer is displayed, we press the "Save" button after selecting the location for the PDF/A-1b file to be created.
Print dialog of the 7-PDF Printer appears
The result
The result is a PDF/A-3U invoice document with an attached ZUGFeRD-compliant XML file, as Adobe's Acrobat Reader impressively shows us.
ZUGFeRD compliant PDF invoice in Acrobat Reader
Only a special PDF printer instance should print ZUGFeRD PDF documents
7-PDF Printer supports the installation of several PDF printer instances via the setup parameter /PRINTERNAME="[REQUIRED PDF PRINTER NAME]". Different PDF settings can then be made for each printer instance. However, macros such as ZUGFeRD.vbs
are placed globally in the macros folder, and actually apply to every installed printer instance. So, in plain language, the programming affects every printer instance based on 7-PDF Printer.
But you can query the variable PrinterName (line 15) in the VB Script code, and thus provide the ZUGFeRD.vbs
code only for a specific printer instance. In the code snippet below, in this case it is the default PDF printer instance with the familiar name "7-PDF Printer". Here, all the code has simply been bracketed into a VBScript IF
condition. So the code for ZUGFeRD documents is only executed if a print was done via the 7-PDF Printer.
ZUGFeRD documents are only created via the printer instance 7-PDF Printer.
Pay attention to printer driver
7-PDF Printer can be installed as a central PDF network printer in addition to a classic installation as a desktop application or a local PDF printer installation (default). The installation-parameter for this is /SHARE
.
After installation as a PDF network printer, it may be necessary to change the printer driver selected after installation to 7-PDF Printer, as shown in the screenshot below, to create ZUGFeRD PDF documents. For higher compatibility a Postscript driver of the operating system is used if necessary. In the case of ZUGFeRD, however, we need direct access to print data, and this is only possible if the PDF network printer instance (in the screenshot "PDF-EXP-Prt") is operated under the printer driver "7-PDF Printer". So you should have a look here, that the printer instance also uses the correct printer driver.
For ZUGFeRD the correct driver 7-PDF Printer must be used!
Note: Starting with Windows 10, you must temporarily disable printer sharing for the duration of the driver change, otherwise you will receive an operating system error message.
Conclusion
The simulation example listed here extracts print information via the supplied macro programming ZUGFeRD.vbs
. The stored programming expects a layout that corresponds to the invoice sample file from Word.
For your requirements the macro ZUGFeRD.vbs
would have to be adapted if necessary. With a little VB Script or programming knowledge under Visual Basic, the programming supplied here can be adapted quite quickly itself. If you have no programming experience, we also offer appropriate know-how. Just contact us via Support form, we will help you and try to realize your requirements.
Supported ZUGFeRD versions and Factur-X 1.0
Mustang-CLI-x.x.x.jar
supports the attachment of already ZUGFeRD compliant XML documents of the EU standard of EN 16931. This includes besides the ZUGFeRD versions 1.0, 2.0, 2.1 also Factur-X 1.0 (France). The abbreviation ZUGFeRD stands for the specification "Central User Guide of the Forum Electronic Invoice Germany" and is a format for the exchange of electronic invoice documents.
Downloads
Attachment | Size |
---|---|
PlugIn_ZUGFeRD_7PDF_Printer.zip | 7.93 KB |
Mustang-CLI v2.3.0 FREE (external Download; under Apache License) | 33.81 MB |
Microsoft OpenJDK Binaries FREE (external Download; under GPL) | ca. 160 MB |
Rechnungsbeispiel.doc.zip | 24.31 KB |
invoiceexample.doc.zip | 24.71 KB |