For template authors: put your company logo on every quote, invoice or contract, and add images that change per record, such as a product photo. This takes about 10 minutes on an existing template.
Before you begin
- A template to edit, in a document solution. See Add a template four ways.
- The logo as a PNG or JPG file. The Template Editor supports PNG, JPG and JPEG (v1.11.0). Compress it first: a template file can be at most 5 MB, and large images are the most common reason a template goes over (DME-DOC-001).
- For a static resource: permission to create static resources in Setup, usually an admin.
Choose a method
| If the image… | Use | Syntax |
|---|---|---|
| Is the same on every document and lives in one template | Insert it in the template (Word, or the Template Editor) | None: it's a normal picture |
| Is the same on every document and is shared by many templates | A static resource | {{Image:StaticResource.Name}} |
| Changes per record, such as a product photo or a signature image | An image URL field | {{Image:Object.Field}} |
With a static resource, you upload the logo once in Setup and reference it from each template by name. {{Image:…}} tags work in Word headers, footers and table rows, and in PowerPoint and Excel templates.
Add a fixed logo to the template
In a Word template:
- In Word, double-click the top margin (or use Insert → Header) to edit the header.
- Insert the logo as a normal picture (Insert → Pictures) and size it in Word.
- Leave Different First Page off, so the header and logo repeat on every page.
- Save the file and upload it to the solution again.
In the Template Editor:
- Add the logo to the first page's header: paste it, or use Insert image.
- Select Use first page header for all pages to repeat it on the remaining pages.
See Headers, footers and page setup.
Use a static resource for a shared logo
- In Setup, enter
Static Resourcesin Quick Find, click Static Resources under Custom Code, then click New. - In Name, enter a name without spaces, for example
CompanyLogo. - Click Choose File, select the logo file, then click Save.
- In your template, type
{{Image:StaticResource.CompanyLogo}}where the logo should appear. To repeat it on every page, put the tag in the Word header. - To set the size, add
H,Wor both in pixels, for example{{Image:StaticResource.CompanyLogo:H=60}}. - Upload the template and generate a document to check the output.
Full steps: Create a static resource for document generation.
Add an image from a record field
- Store a link to the image file in a field, for example a URL field
Logo__con Account. Public URLs work best, and Salesforce ContentVersion links work too. A public link must open the image itself in a browser, not a web page that contains it. - In the template, type
{{Image:Account.Logo__c}}, using your field's API name. - To set the size, add the height, the width or both in pixels:
{{Image:Account.Logo__c:H=50:W=100}}. Set only one, for example{{Image:Account.Logo__c:W=200}}, to keep the original proportions. - Upload the template and generate a document.
Images in a rich text field show when you use the HTML parameter. See Image and Image H and W. Height and width work from v1.19.0.
Verify it worked
- Generate the document from a test record, in the format you use, for example PDF. From v1.25, you can check it first with the merge preview.
- Check that the logo appears on page 1 and, if it's in the header, on page 2 and the last page.
- Check that the image is the size you expect and not stretched.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The image's URL is printed instead of the picture | The tag is missing Image: | Use {{Image:Object.Field}}. See Images are missing or broken. |
| An empty space or broken image | The field is empty, or the URL isn't a direct link to the image or a ContentVersion link | Test a public URL in a private browser window. See Images are missing or broken. |
| The image is stretched | Both H and W are set | Set only one of them. See Image H and W. |
| The logo appears only on page 1 | Different First Page in Word, or the repeat option isn't selected in the Template Editor | See Headers, footers and page setup. |
| "Document is too large to process" | The image file is large | Compress it. See DME-DOC-001. |
Next steps
- Headers, footers and page setup: page numbers, page breaks and watermarks.
- WATERMARK to show a value such as the opportunity stage diagonally across the page. Put the watermark tag in the template body, not the header or footer; it appears on every page.
- Template syntax basics