Create a Form Letter
Create a form letter using the DynamicPDF Designer.
In this sample you create a simple form letter. The produced PDF is a one page form letter.
Sample Project
The form-letter
project is available from the DynamicPDF Portal Samples in the File Manager.
The project consists of the following two files.
form-letter.dlex
form-letter.json
Refer to the following for more information on the File Manager and on adding sample projects.
Sample Description
The sample consist of a Report containing a Header, Footer, and Body.
The header consists of static text containing the return address while the body consists of a single record containing a RecordArea
field.
{
"Name": "Alex Smith",
"Address": "456 Green Road\nSomewhere, Earth",
"Amount": 321.00
}
The RecordArea
consists of the Name
, Address
, a date, and Amount
.
Th date formats the current date and time using the CurrentDateTime
function.
The Amount
element formats the amount as follows.
#Format(Amount,"#,##0.00")#
The Footer contains a page number, which in this example is always one.
The report produces a single page PDF.
Modified Report
If we modified the JSON to contain multiple addresses then we could create multiple form letters, one page per customer. For example, assume the following JSON.
{
"Addresses": [
{
"Name": "Alex Smith",
"Address": "456 Green Road\nSomewhere, Earth",
"Amount": 321.00
},
{
"Name": "Joe Smith",
"Address": "456 Green Road\nSomewhere, Earth",
"Amount": 521.00
},
{
"Name": "Susan Smith",
"Address": "456 Green Road\nSomewhere, Earth",
"Amount": 21.00
}
]
}
Modify the Report so its dataName
is Addresses
.
Add a Page Break
so that only one record is printed per page. Also remove the page number from the footer, as a page number does not make sense when multiple pages are created.
When processed, it prints three letters, one per address.
More Information
For more information on using Designer refer to one of our many tutorials and the Users Guide documentation. Also refer to the Designer Examples documentation page in the Users Guide for numerous examples illustrating Designer's capabilities. Our blog also has numerous tips and tricks for using Designer.