4D Blog

Home Tips Use 4D Write Pro to Create & Print a Batch of Documents

Use 4D Write Pro to Create & Print a Batch of Documents

August 8, 2022

Tips

Whatever your business, you must create listings, inventories, tracking sheets, product sheets, invoices, and many other documents. These documents are usually printed or saved in PDF for archiving.

4D Write Pro is the ideal tool to create all your documents. Here is a list of several features available in 4D Write Pro that can help you make beautiful documents for printing:

  • page layout and margin management for printing,
  • pdf export,
  • document protection,
  • table creation,
  • table formatting with repeated headers,
  • definition of a data context,
  • inserting ORDA formulas in a table (new in 4D v19 R6).

 

Using these different features, here are some examples of documents produced.

a simple list like an inventory

To print a list of records, developers usually use the list form. The disadvantage of this form is that it does not benefit from the power of ORDA.

With 4D Write Pro, you can print the result of an ORDA query using a document template. This has become very easy to do, thanks to the data context.

In this example, we want to print the list of vehicles belonging to a rental agency. Thus, an Agency entity is passed as data context. Then the “cars” relation attribute from the Agency table to the Car table is defined as the table’s data source.

For example, to generate the PDF document from an entity selected by the customer, it is enough to write:

// $context: Entity selected by customer
var $context : cs.AgencyEntity
$context:=ds.Agency.query("ID = 1").first()

// Load write pro model
$doc:=WP Import document(File("/RESOURCES/wpModel/Inventory.4wp").platformPath)
// Defines the entity as the data context of the document
WP SET DATA CONTEXT($doc; $context)
// Generate the document
WP COMPUTE FORMULAS($doc)
// Export in PDF
WP EXPORT DOCUMENT($doc; Folder(fk documents folder).file("Inventory.pdf").platformPath; wk pdf)

A simple document like a contract or a letter

Another type of document that is often printed is legal documents like contracts. It is a template containing some formulas to retrieve the contractors’ name, surname, and address, for example.

blank

For example, to generate the PDF document from an entity selected by the customer, it is enough to write:

// $context: Entity selected by customer
var $context : cs.ReservationEntity
$context:=ds.Reservation.query("ID = 1").first()

// Load write pro model
$doc:=WP Import document(File("/RESOURCES/wpModel/CarRentContract.4wp").platformPath)
// Defines the entity as the data context of the document
WP SET DATA CONTEXT($doc; $context)
// Generate the document
WP COMPUTE FORMULAS($doc)
// Export in PDF
WP EXPORT DOCUMENT($doc; Folder(fk documents folder).file("Contract.pdf").platformPath; wk pdf)

A complex document

Another example, you use the Print form on detail forms to print complex forms with information and several lists in subforms. You can also create this type of document with 4D Write Pro. It is possible to insert several tables with different data sources.

In this example, for an agency, the list of actions of the day is displayed on two tables, one for cars picked up by customers and the other for cars to receive. An Agency entity is passed as data context. The two tables are filled by the computed attributes: Agency.reservationsDeparted and Agency.reservationsArrival. These two computed attributes return an entity selection from the Reservation table.

blank

For example, to generate the PDF document from an entity selected by the customer, it is enough to write:

// $context: Entity selected by customer
var $context : cs.AgencyEntity
$context:=ds.Agency.query("ID = 1").first()

// Load write pro model
$doc:=WP Import document(File("/RESOURCES/wpModel/DayAction.4wp").platformPath)
// Defines the entity as the data context of the document
WP SET DATA CONTEXT($doc; $context)
// Generate the document
WP COMPUTE FORMULAS($doc)
// Export in PDF
WP EXPORT DOCUMENT($doc; Folder(fk documents folder).file("DayAction.pdf").platformPath; wk pdf)

Next…

4D Write Pro is composed of many features, each more interesting than the other. You can find all the features and possibilities in the documentation and, of course, in the blog posts with the “4D Write Pro” tag. 

 

Discuss

Tags 4D Write Pro, Data context, Formula, ORDA, PDF, Printing, Table, v19 R6, v20, Word processor

Latest related posts

  • September 15, 2025

    Find the right spot in your 4D Write Pro document with AI

  • September 2, 2025

    Intelligent 4D Write Pro document analysis with AI

  • August 25, 2025

    ORDA – Constructor and touched event – Detailed behaviour through a network

Vanessa Talbot
Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 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 AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula 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-Analyzer 4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula 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