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…UseSyntax
Is the same on every document and lives in one templateInsert 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 templatesA static resource{{Image:StaticResource.Name}}
Changes per record, such as a product photo or a signature imageAn 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:

  1. In Word, double-click the top margin (or use Insert → Header) to edit the header.
  2. Insert the logo as a normal picture (Insert → Pictures) and size it in Word.
  3. Leave Different First Page off, so the header and logo repeat on every page.
  4. Save the file and upload it to the solution again.

In the Template Editor:

  1. Add the logo to the first page's header: paste it, or use Insert image.
  2. Select Use first page header for all pages to repeat it on the remaining pages.

See Headers, footers and page setup.

  1. In Setup, enter Static Resources in Quick Find, click Static Resources under Custom Code, then click New.
  2. In Name, enter a name without spaces, for example CompanyLogo.
  3. Click Choose File, select the logo file, then click Save.
  4. 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.
  5. To set the size, add H, W or both in pixels, for example {{Image:StaticResource.CompanyLogo:H=60}}.
  6. 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

  1. Store a link to the image file in a field, for example a URL field Logo__c on 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.
  2. In the template, type {{Image:Account.Logo__c}}, using your field's API name.
  3. 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.
  4. 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

  1. 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.
  2. Check that the logo appears on page 1 and, if it's in the header, on page 2 and the last page.
  3. Check that the image is the size you expect and not stretched.

Troubleshooting

SymptomLikely causeFix
The image's URL is printed instead of the pictureThe tag is missing Image:Use {{Image:Object.Field}}. See Images are missing or broken.
An empty space or broken imageThe field is empty, or the URL isn't a direct link to the image or a ContentVersion linkTest a public URL in a private browser window. See Images are missing or broken.
The image is stretchedBoth H and W are setSet only one of them. See Image H and W.
The logo appears only on page 1Different First Page in Word, or the repeat option isn't selected in the Template EditorSee Headers, footers and page setup.
"Document is too large to process"The image file is largeCompress it. See DME-DOC-001.

Next steps