4D Blog

Home Product 4D Write Pro: Electronic Invoice Generation!

4D Write Pro: Electronic Invoice Generation!

January 16, 2024

Product

4D v20 R4 introduces an exciting feature in 4D Write Pro—now, it empowers you to generate electronic invoices. But what exactly do we mean by e-invoices?

An electronic invoice (or e-invoice) is generated, transmitted, received, and stored electronically, enabling more efficient and environmentally friendly management of business transactions.

While they offer many advantages, they also come with their own specific constraints, particularly in terms of the complexity of the generation process. However, with 4D Write Pro, we’ve come to realize that managing this complexity is much more manageable than initially perceived!

HDI: Electronic Invoice Generation

Why electronic invoices?

Electronic invoices can take a variety of digital formats, such as PDF (which we’ll be using), and can be transmitted via online portals, CRMs, and so on. Their processing can be automated, reducing management time, the risk of errors, the need for printing, physical storage, ecological impact, etc.
It’s also known as an intelligent or hybrid format because it can be read by a human being and a computer.
It is also a format that will become mandatory and essential in the months or years to come in countries all over the world (Factur-x in Europe), particularly for all government-related matters.

4D Write Pro and the Factur-X/ZUGFeRD format

4D Write Pro already allows you to produce files in PDF format and, since 4D V20 R3, also in PDF/A2 and PDF/A3 formats. For e-invoices, the PDF/A3 format will be used, as it allows external files to be integrated. In the case of an electronic invoice, only one external file is needed, an XML file. This one must be the first one if many files are integrated.

To sum up, we can say that PDF/A3 + XML = Factur-X (in France)  / ZUGFeRD(in Germany) will be done in a single step by 4D Write Pro!

What content for XML?

The Factur-X/ZUGFeRD XML file contains structured information on the invoice, such as seller and buyer details, billing lines, amounts, taxes, etc.
European standard templates such as MINIMUM, BASICWL, EN 16931, BASIC, and EXTENDED are the most common ones.
“Custom” formats can also be used, but their validation (we’ll return to this) will be less obvious, and their use restricted.

Complete information about these formats can be found on the fnfe-mpe.org website: https://fnfe-mpe.org/factur-x/factur-x_en/

How do I generate a Factur-x/ZUGFeRD?

Let’s not forget that an electronic invoice is, first and foremost, a PDF in which new information is included. Two new attributes have been added to the existing ones for PDF export.

Let’s start with “facturx”

This attribute, facturX, is an object that contains only two optional attributes.
This means that the mere presence of this object, even empty, will be enough to generate a valid Factur-X/ZUGFeRD document.

$options:={}
$options.facturX:={}
$options.facturX.profile:="BASIC" // optional (when passed, it must match the first file XML content)
$options.facturX.version:="1.0" // default value

Then comes “files”

Many files can be included in a PDF/A3 document. That’s why the files attribute is a collection that will contain objects, each describing the file to be included.

They will have attributes that will differ according to the file function. In the case of an electronic invoice (reminder: first file in the list), most attributes are optional except, of course, for the XML content that can be sent either through a data attribute (as text) or a file attribute (as 4D.File).

Notes:
The XML must be pre-generated and meet all the requirements of the standard (the HDI demo shows an example of XML creation based on the BASIC profile). 4D Write Pro won’t check your XML file content, so ensure you validate your XML file before inserting it into the Factur-X / ZUGFeRD e-invoice.

$xmlFile:={} // creates the first file object
$xmlFile.name:="factur-x.xml"  // default value
$xmlFile.description:="Factur-X/ZUGFeRD Invoice"  // default value
$xmlFile.mimeType:="text/xml"  // default value
$xmlFile.data:=$xmlText  // MUST be valid, NOT checked by 4D
$xmlFile.relationship:="Data" // default value

$options.files:=[$file]  // more files could be added, the first one always is for facturX/ZUGFeDR

or (variation, instead of $xmlFile.data)

$xmlFile.file:=$xmlFile // actual file on disk that must be a valid xml file

Online validation

As mentioned above, 4D Write Pro does not validate content. Only the structure is checked. However, there are online validators. The most reliable seems to be veraPDF (https://demo.verapdf.org) and fnfe-mpe.org (https://services.fnfe-mpe.org/account/home). The second one has the double advantage of being able to validate the XML itself and, secondly, a complete invoice (See the HDI for a full example).

Conclusion

This new functionality responds to a growing demand for modernity and fills legal and administrative requirements.

Generating electronic invoices in series will be simple, thanks to generic templates and methods for generating correctly formatted XML.

Ultimately, the trickiest part may be choosing between the various possible profiles, but usage often dictates this choice.

Share your feedback and thoughts on this new feature in the 4D Forums.

More about this feature can be read in the documentation.

Discuss

Tags 21, 4D Write Pro, Factur-X, PDF/A Format, v20 R4, Word processor, ZUGFeRD

Latest related posts

  • February 3, 2026

    4D Write Pro – Adding a margin automatically when bullets are set using standard actions

  • January 22, 2026

    Transform Static Documents into Actionable Knowledge with AIKit

  • January 22, 2026

    Deploy Fluent UI effortlessly in your 4D applications

Roland Lannuzel
Roland Lannuzel
• Product Owner & 4D Expert • After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • Release infos
  • 4D View Pro
  • 4D Write Pro
  • Email, Microsoft 365, Gmail
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • 4D Qodly Pro
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 21 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy