A 1-page contractual HR letter that shows features commonly used in letters.
Example in detail
This example letter uses Docmosis optional paragraphs, date functions, repeating sections, and dynamic images.
The letter also uses tables and tabs to align information in the main body, and in the header and footer.
Optional address lines
Typically, letters have address blocks that can vary in size based on the number of lines in the recipient's address.
The <<op: optional paragraph is handy in those situations where you want to allow for fewer address lines.
In this letter example, the <<op: feature is used for addressLine2.
If there is no value for addressLine2, this line is removed from the letter.
In this way, the use of <<op: overcomes problematic blank lines appearing in letters with fewer address lines.
Displaying the current date
A business letter often shows a date at the top. This example shows how to display the current date/time that the letter is generated.
Docmosis has a built-in variable called $nowUTC to get the current date/time in UTC (coordinated universal time).
By using the Docmosis dateAdd function, in combination with $nowUTC, it is possible to shift the date/time to the required time zone.
In this example, the number of hours to add to the UTC date/time is supplied through the data. The timeOffset is set to "1", and is used to add one hour to the UTC date/time, to localize it to British Summer Time.
Within the dateAdd function, the timeOffset is set to hours. The function formats the date, using ’EEEE, dd MMMM, yyyy’, as shown below.
The date the letter is generated appears at the top like this:
Refer to the Template Guide documentation for more on date formats and formatting codes.
Alignment using tables and tabs
A borderless table is used here, to align the key details of the contract.
Tip: When working with borderless tables, select View Gridlines in the Layout tab in the Ribbon.
A left-aligned tab is used to align the start times for the daily work shifts.
The <<rs_ repeating section directive is used to show the daily shifts that are part of this employment contract.
Each workDay, startTime and endTime is shown on a new line.
The table cell expands downwards to match the number of shifts worked in a week.
For further information on the <<rs_ directive, see Repeating Sections.
It’s simple to add a dynamic signature image to a letter like this one.
To understand how the placeholder image in the template uses the dynamic signature image, refer to the article Images – Part One.
In the data file, a stock image "directorSignature.png" is assigned to signature, and replaces the placeholder image.
For more detail on where to store image data and how to use it, refer to the article How to send image data or retrieve images from a file or URL.
Headers and footers
It's good practice to create a letter template with a header and footer, even if the template is only used to generate a simple 1-page letter. In this way, if the letter is ever extended, these details still feature on subsequent pages.
In this letter example, a simple 2-column table is used in the header to left-align the static image, and right-align the text.
Likewise, a 2-column table is used in the footer to left-align the address, and right-align the contact details.