4D Blog

Home Product 4D Write Pro: Export to PDF with Enclosures!

4D Write Pro: Export to PDF with Enclosures!

January 16, 2024

Product

As you already know, since 4D v20 R3, 4D Write Pro can export in PDF/A2 and PDF/A3 (BLOG) formats. Apart from the signature, the main difference between these two formats is that the PDF/A3 format can include attachments. The good news is that thanks to a new export option in 4D Write Pro, it is possible, with 4D v20 R4, to have attachments when exporting!

Archiving to the power of 10

The PDF/A signature means and guarantees that a document of this type will be readable for decades, as explained in this BLOG.
The PDF/A3 format allows attachments of any type (Word, Excel, PDF, Photoshop, etc.) to be inserted inside the PDF/A3.
The advantage is that you can store all the information you need on a specific subject in a single document.

Whether your area of interest is legal, technical, medical, accounting, security, construction, public works, or any other, if you need to archive documents containing attachments, PDF/A3 is the format you need!

one or more attachments

The PDF/A3 standard allows you to insert as many attachments as possible. This is why the new export option, .files, is of the collection type.

Each element of this collection is an object with a few simple properties, some of which are optional.

The first and most apparent is the .file property of type 4D.File indicates the physical file to be included in the PDF. It can, however, be replaced by the .data property of text or BLOB type. These two properties are exclusive: if the .data property is present, the .file property will be ignored.

The .description property is optional, as is .mimeType, which can generally be deduced from the content of .file or .data.

Finally, .name is the file name that will be extracted from the PDF. This one is only mandatory if the .data property has been used and not the .file property. Otherwise, by default, it will have the same name as the original file defined in .file!

a simple code sample

The code below shows how to insert two physical files plus a simple text sent as data.

$options:={}  // empty object
$options[wk files]:=[]  // empty collection

// 1st file (based on .file)
$fileInfo:={}
$fileInfo.description:="RTF formated text"
$fileInfo.file:=File(Folder(fk data folder).path+"Alpha.rtf")
$options[wk files].push($fileInfo)

// 2nd file  (based on .file)
$fileInfo:={}
$fileInfo.description:="Png picture"
$fileInfo.file:=File(Folder(fk data folder).path+"Bravo.png")
$options[wk files].push($fileInfo)

// 3rd file (based on .data)
$fileInfo:={}
$fileInfo.name:="Charlie.txt"  // will be used for extraction
$fileInfo.description:="raw text sent as data"
$fileInfo.data:="This is some raw text to be included as enclosure in the PDF and to be extracted as 'Charlie.txt'"
$options[wk files].push($fileInfo)

WP EXPORT DOCUMENT($document; "exportWithEnclosures.pdf"; wk pdf; $options)

Note: when you use the wk files attribute, the version of the generated PDF will automatically be PDF/A3, and the wk pdfa version option, if present, will be ignored.

Once executed, the PDF document will look like this (using Adobe Acrobat Reader™)

Conclusion (and to be continued!)

Attaching documents within a single PDF/A3 file means you can take full advantage of what this standard allows. But that’s not all! As you will soon see, it will also enable electronic invoices to be generated by inserting an XML document as the first file in the attachments! Stay tuned!

Discuss

Tags 21, 4D Write Pro, v20 R4, Word processor

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

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

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 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