For template authors: make every page of a generated contract, invoice or report look finished, with a repeating header and logo, a "Page 3 of 5" footer, page breaks in the right places and an optional watermark. This takes about 15 minutes on an existing template.
How you set it up depends on where you build the template:
- A Word file you upload: headers, footers, margins and orientation come from Word. Docs Made Easy fills in the tags.
- The Template Editor in Docs Made Easy: from v1.11.0, it has images, page breaks, headers and footers, with options to repeat the first page's header and footer. It also sets orientation, paper size and margins. It opens when you choose Start from scratch on the Add Template page (v1.25) or edit an existing Word template. It edits Word (.docx) templates only.
Before you begin
- A document solution with a template, or a new one. See Add a template four ways or Create a template with the Document Automation Wizard.
- The basics of merge fields. See Template syntax basics.
- A record with enough related data to fill more than one page, so you can check page 2 onward.
Add a header and footer
In a Word template:
- In Word, double-click the top or bottom margin (or use Insert → Header / Footer) to edit the header or footer.
- Add your company name, logo and any fixed text.
- In the footer, type
Page {{PAGE}} of {{NUMPAGES}}. In the generated document this becomes, for example,Page 3 of 5. See PAGE and NUMPAGES. - If the first page needs a different header, turn on Different First Page in Word. Otherwise leave it off, so the header repeats on every page.
- Remove any page numbers typed by hand, because they don't change when the page count does.
In the Template Editor:
- Add the header and footer content to the first page.
- Select Use first page header for all pages to repeat the header on the remaining pages.
- Select Use first page footer for all pages to repeat the footer.
Control where pages break
To start a section on a new page, type
{{_PageBreak_}}where the new page should begin. In the Template Editor, you can also use its page break option.To put each record on its own page, for example one certificate per contact, place
{{_PageBreak_}}directly afterTableStartin the table row:First name Last name {{TableStart:Account.r.Contacts}}{{_PageBreak_}}{{FirstName}}{{LastName}}{{TableEnd:Account.r.Contacts}}Don't put two page breaks next to each other: each one starts a new page, so you get blank pages.
See PageBreak.
Add images and a watermark
- A fixed logo: in a Word template, insert it as a normal picture. In the Template Editor, paste it or use Insert image; the supported formats are PNG, JPG and JPEG. For a logo you reuse across templates, use a static resource and
{{Image:StaticResource.Name}}. This tag works in a Word header and takesHandW, for example{{Image:StaticResource.Logo:H=50:W=100}}. - An image from a record:
{{Image:Object.Field}}inserts the image whose URL is in that field. AddHandWin pixels to size it, for example{{Image:Account.Description:H=50:W=100}}. Image tags work in headers, footers and table rows. Images work best from public URLs; Salesforce ContentVersion links also work. See Image and Image H and W. - A watermark from a field:
{{WATERMARK:Opportunity.StageName:Arial:400:100:45:#D3D3D3}}shows the opportunity's stage, such as "Closed Won", diagonally in light gray. Put the tag anywhere in the template body, not in a header or footer. The watermark appears on every page. See WATERMARK.
Set orientation, margins and fonts
In a Word template, set orientation, paper size and margins in Word (Layout → Orientation, Size, Margins). In the Template Editor, set them in the editor itself.
For PDF output, all major fonts are available for conversion on Docs Made Easy's servers. If your template uses a font that isn't available, ask Docs Made Easy support to add it; until then it's replaced, which can move line and page breaks. See The PDF looks different from my Word template.
Verify it worked
- Generate the document from your test record, in the output format you use, for example PDF. From version 1.25, you can check it first with the merge preview.
- Check page 2 and the last page: the header and footer repeat, the footer reads
Page 2 of 5andPage 5 of 5, and the logo is in place. - Check that sections start on new pages where you put page breaks, with no blank pages.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The watermark is missing | The WATERMARK tag is in a header or footer | Move the tag into the template body |
| The header or footer appears only on the first page | Different First Page or Link to Previous in Word; or the repeat options aren't selected in the Template Editor | Check each section in Word, or select Use first page header for all pages and Use first page footer for all pages |
| Page numbers are wrong or the same on every page | Page numbers typed by hand | Use {{PAGE}} and {{NUMPAGES}} |
| Blank pages | Two page breaks in a row, or a break at the end of the document | Remove the extra {{_PageBreak_}} |
| The logo or image is missing | Missing Image: prefix, a URL that isn't public, or an unsupported format | Images are missing or broken in the generated document |
| The PDF layout differs from Word | Fonts, section breaks or orientation | The PDF looks different from my Word template |
| "Document is too large" | Large images | Compress the images (DME-DOC-001) |