4D Write Pro – Direct export to PDF!

What if I told you that with 4D v18 R4 you can export 4D Write Pro documents directly to PDF format (on both macOS and Windows), without needing to install any printer drivers or additional software? Now you can … and that’s not all! You’re also able to set several options for both the form and the content. Keep reading to learn more!

HDI: Export in PDF

Exporting in PDF format can be done in two ways:

  1. To a document on your hard drive or
  2. To a BLOB variable that can then be exported, archived, sent as an email attachment, etc.


You can also define a number of options in order to specify precisely what should be exported and how.

For example:

  • Does your document have headers and footers that don’t belong in your PDFs? No problem! Don’t export them.
  • Need control over images because your documents can be printed, but your PDFs are only intended to be previewed on screen? Choose the screen-optimized option.
  • Don’t need to export background images? Great! Your generated PDFs will be lighter!
  • What about links to bookmarks and external URLs? Worry not, they’re maintained.


Here’s some code to show you how easy setting up these options can be:

var $options : Object
var $Path : Text
$Path:=Get 4D folder(Database folder)+"Test.pdf"
$options:=New object
$options[wk visible background]:=False
$options[wk visible headers]:=False
$options[wk visible footers]:=False
$options[wk optimized for]:=wk screen
WP EXPORT DOCUMENT(WPsample;$Path;wk pdf;$options)

Something else worth mentioning, the command is thread-safe, so if you are handling multiple documents, the export will be faster since all the cores will be operational.
More information is available in the doc center. Happy exporting! 

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.