For the complete documentation index, see llms.txt. This page is also available as Markdown.

Insert Images

What Are Images in S-Docs?

Images in S-Docs allow you to include visual elements in your generated documents, from company logos and product photos to signatures and watermarks. S-Docs supports both static images (that remain the same across all documents) and dynamic images (that change based on record data).

How Are Images Used in S-Docs?

Images enhance document professionalism and provide visual context that text alone cannot convey. Common use cases include:

  • Company logos and branding: Headers, footers, and letterheads

  • Product images: Catalogs, specifications, and proposals

  • Signatures: Contracts and approvals

  • Charts and diagrams: Reports and presentations

  • Watermarks: Draft stamps, confidential labels, and background branding


Static Images vs. Dynamic Images

Understanding the difference between static and dynamic images helps you choose the right approach for your needs.

Static Images

Static images are the same across all generated documents. Examples include company logos, standard headers, or consistent branding elements.

Use static images when:

  • The image never changes regardless of the record

  • You need consistent branding across all documents

  • The image is part of your document template design

Dynamic Images

Dynamic images change based on the record being used to generate the document. Examples include product photos, employee headshots, or custom signatures.

Use dynamic images when:

  • Different records need different images

  • Images are uploaded or selected by users

  • You want one template to handle multiple scenarios


Adding Static Images

There are several methods for embedding static images into your S-Docs templates.

Method 1: Using an Image URL

The simplest approach is to reference an image URL directly in your template source:

This method works well for:

  • Images hosted on public websites

  • Email templates (where the recipient needs to access the image at view-time)

  • Quick testing and prototyping

Important: If images are stored outside of Salesforce, you must create a Remote Site Setting for the image's URL domain (see "Troubleshooting" section below).

Method 2: Using the Template Editor Add Image Button

The template editor provides a visual interface for adding images with two tabs: Image Info and Upload.

1

Open the Template Editor

  1. Open your template in the Template Editor

  2. Click the Add Image button on the toolbar

2

Choose one of the following options

Select either the Image Info tab or the Upload tab (detailed below).

Image Info Tab

The Image Info tab offers two ways to add images:

Option A: Browse Server

1

Click Browse Server to search for existing images in your Salesforce documents folder

2

Select your desired image

3

Click to insert the image

Note: If you're sending documents externally (like email templates) and you selected an image using Browse Server, you need to ensure the Salesforce document record is set to externally available:

1

Navigate to the Documents object in Salesforce Classic

2

Find your image's Document record

3

Check the Externally Available Image checkbox

4

Save the record

Option B: Paste Image URL

1

Copy the full URL of your image (right-click the image → "Copy image address")

2

Paste the URL into the URL field in the Image Info tab

3

Click to insert the image

This works the same way as adding an image URL directly in the template source code.

Upload Tab

The Upload tab allows you to upload new images directly from your computer:

1

Click the Upload tab

2

Click Browse to select a file from your computer

3

Select your image file

4

Click to upload and insert the image

Important advantage: Images uploaded through the Upload tab are automatically set as externally available, so you don't need to manually configure the Externally Available Image checkbox.

Note: S-Docs also supports embedding images as Content Distribution URLs, which render consistently and securely across all generated documents, aligning with Salesforce best practices.

Method 3: Using Static Resources

You can embed static resources as images using the following code:

Example:

This method is ideal for:

  • Package development

  • Images that are part of your deployment

  • Version-controlled branding assets

Method 4: Adding Background Images or Watermarks

To add a background image or watermark that appears on every page:

Note: The background image/watermark will be the same for every page of the document. For different images on different pages, use the DOCX document format.


Adding Dynamic Images

Dynamic images allow a single template to display different images based on record data.

Method 1: Use a Rich Text Field

This is the easiest method for dynamic images:

1

Upload your image into a standard Salesforce rich text field on your record detail page

2

Open your template in the Template Editor

3

Click Insert Field

4

Select the rich text field

5

Check the Contains Rich Text checkbox

6

Click Insert

The document will now render the rich text content (including images) wherever you placed this field.

Note: This option is only available for PDF and DOCX documents. Rich text fields with many items or complex formatting may not render precisely. It's better practice to use the S-Docs editor to control document layout rather than inserting complex rich-text fields.

Method 2: Use a Text Field Containing Image Markup

You can use a standard Salesforce text field whose value contains the complete image element tag:

Example field value:

Then insert the field using the Template Editor:

1

Click Insert Field

2

Select the field

3

Check the Contains Rich Text checkbox

4

Click Insert

Use this method for:

  • Images controlled by administrators

  • Images that don't change frequently

  • Representative signatures or stamps

Limitations: Since this is a text field, users will see the markup text (not the image) when viewing the record in Salesforce, making it less user-friendly for frequently updated images.

Method 3: Use a Formula Field to Display an Image

Building on Method 2, you can use a Salesforce formula field to create the image path programmatically:

Then insert the formula field into your template with Contains Rich Text checked.

Benefits:

  • Image displays properly in Salesforce record detail pages

  • Programmatically builds the correct path

  • More user-friendly than text fields

Requirements: Image file names must follow a consistent, predictable pattern.

Method 4: Build an Image URL Within the S-Docs Template

This method creates the full image path within the S-Docs template itself, without requiring a formula field.

For S-Docs versions below 7.0:

The special notation (lt#, gt#, quot#) instructs S-Docs to evaluate the markup rather than render it literally.

For S-Docs version 7.0 and later:

Important: The field value should be a URL pointing to either:

  • An image in your Salesforce documents folder

  • An external image hosted on the public internet

The field should contain the entire path including the https:// prefix.

Best Practice: Build a full image URL in a custom field so the base URL can be changed in one place if needed, rather than updating every template. This is especially important when migrating templates between orgs.


Understanding Triple Curly Braces

When you insert a field marked as "Contains Rich Text," you'll see three sets of braces:

The extra pair of curly braces instructs S-Docs to interpret the field value as markup rather than display it as text.

Without triple braces:

Displays: <img src="//host/Product123Image.png" />

With triple braces:

Displays: The actual image


Working With Images in DOC Templates

For DOC templates, additional configuration is required to ensure images scale correctly.

Template Settings

1

Navigate to the Page Settings tab in the Template Editor

2

Check Embed Images

Image Format Requirements

Use the style attribute format:

Do NOT use:

Without the style attribute, images will appear as tiny squares in generated documents.

User Action Required

Users must click Enable Editing in Microsoft Word for images to download in the generated document.


Best Practices

  • Use the Upload tab for new images: When adding new images from your computer, use the Upload tab to automatically handle external availability

  • Point sandbox templates to production images: When working in sandbox, reference image URLs from your production org to avoid updating images when migrating templates

  • Use full URLs, not relative paths: Build complete URLs (e.g., https://na30.salesforce.com/servlet/...) instead of relative paths (e.g., /servlet/...) for better portability between orgs

  • Organize images logically: Use descriptive file names and folder structures for easy maintenance

  • Test across formats: Verify images render correctly in PDF, DOCX, and HTML formats

  • Consider file size: Large images can slow document generation; optimize images before uploading

  • Use static resources for packages: If developing managed packages, use static resources for version control and deployment


Troubleshooting

If images show up in the template editor but do not load in generated documents, there are four common causes and resolutions.

Issue 1: Image URL is From External Source

If your image URL is from outside Salesforce, you must allowlist the domain through Remote Site Settings.

Resolution:

1

Navigate to Setup → type "Remote Site Settings" in Quick Find → click Remote Site Settings

2

Click New Remote Site

3

Enter the following:

  • Remote Site Name: externalImageSDocs (or any descriptive name)

  • Remote Site URL: The image URL domain only

Example: If your full image URL is https://www.google.com/images/logo.png, enter https://www.google.com as the Remote Site URL.

4

Click Save

Your external image should now load correctly.

Issue 2: Image From Salesforce Documents is Not Externally Available

If your image was added from Salesforce documents using Browse Server (not uploaded through the Upload tab), it must be manually set to Externally Available.

Resolution:

1

Navigate to the Documents object in Salesforce Classic (Click the + (All Tabs) symbol to find Documents)

2

Find the Document record for your image and click its name

3

Check the Externally Available Image checkbox

4

Click Save

The image should now load correctly.

Note: Images uploaded through the Upload tab in the Add Image window are automatically set as externally available and do not require this manual step.

Issue 3: Images Not Appearing After Org Migration

Symptoms: Images worked in your original org but don't appear after migrating templates to a new org.

Causes:

  • Image URLs contain the old org's instance (e.g., na30.salesforce.com instead of the new instance)

  • Relative URLs aren't resolving correctly in the new org

Resolution:

  • Use full URLs with the correct instance

  • Consider using formula fields to build URLs dynamically

  • Update static image references to point to the new org's resources

Issue 4: Broken Image Icons Appear

Symptoms: Broken image icons appear instead of images in generated PDFs.

Common causes:

  • Missing Remote Site Settings for external URLs

  • Image not set as Externally Available

  • Incorrect or expired image URL

Resolution: Follow the troubleshooting steps for Issues 1 and 2 above.


Working with images in S-Docs allows you to create professional, visually engaging documents that enhance your brand and improve communication with customers and stakeholders. Whether using static images for consistent branding or dynamic images for personalized content, S-Docs provides flexible options to meet your needs.

Last updated

Was this helpful?