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.
Image Info Tab
The Image Info tab offers two ways to add images:
Option A: Browse Server
Click Browse Server to search for existing images in your Salesforce documents folder
Select your desired image
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:
Navigate to the Documents object in Salesforce Classic
Find your image's Document record
Check the Externally Available Image checkbox
Save the record
Option B: Paste Image URL
Copy the full URL of your image (right-click the image → "Copy image address")
Paste the URL into the URL field in the Image Info tab
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:
Click the Upload tab
Click Browse to select a file from your computer
Select your image file
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:
Upload your image into a standard Salesforce rich text field on your record detail page
Open your template in the Template Editor
Click Insert Field
Select the rich text field
Check the Contains Rich Text checkbox
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:
Click Insert Field
Select the field
Check the Contains Rich Text checkbox
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
Navigate to the Page Settings tab in the Template Editor
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 orgsOrganize 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:
Navigate to Setup → type "Remote Site Settings" in Quick Find → click Remote Site Settings
Click New Remote Site
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.
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:
Navigate to the Documents object in Salesforce Classic (Click the + (All Tabs) symbol to find Documents)
Find the Document record for your image and click its name
Check the Externally Available Image checkbox
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.cominstead 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?


