---
schema_version: "1"
id: 77849eefbe418858987d4e0a9de4ba4923ac4d6622e208669309583e4712c3d1
title: Dynamic Images in Server-Side Document Generation
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/doc_gen_serverside_dynamic_images_one.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.doc_gen_serverside_dynamic_images_one.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: c1c7225d4b497aea5fbc2a7a50f4585aa45267280a89e9a6501d025c269752c5
description: Insert images such as product photos, barcodes, or pie charts in your generated DOCX and PDF documents by using image tokens in a Microsoft Word or Microsoft PowerPoint document template.
products:
  - Omnistudio Doc Gen
release: "264"
---
# Dynamic Images in Server-Side Document Generation

Insert images such as product photos, barcodes, or pie charts in your generated DOCX and PDF documents by using image tokens in a Microsoft Word or Microsoft PowerPoint document template.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Professional</strong>, <strong>Enterprise</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions</td></tr></tbody></table>

![Warning](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/images/icon_warning.png)

Warning Dynamic images in server-side document generation may not work with [Omnistudio Standard](https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_standard.htm&type=5&language=en_US).

Place image tokens anywhere within a document template, such as in paragraphs, tables, and text boxes. Use a token in a header or footer or within a repeating content section to pass an array of images. Define the height and width of the images in Omnistudio Data Mapper Transform. By default, image tokens are supported within the Token Data and Token Data Content Document fields of the Document Generation Process. You can also use a custom Apex class to load a blob for dynamic image rendering using IDs, URsL, or other strings and identifiers. Store images in Files, on the Documents tab of a contract, or in the Notes and Attachments section of an object as a contract document, or in rich text fields.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/images/icon_note.png)

Note In PPTX, if you want your text and image to render on the same line in a document, you must give the text and the dynamic image token in separate text boxes on the same line.

![Tip](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/images/icon_tip.png)

Tip

If you don't have an OmniStudio license in your org, you can add dynamic images to generated documents by using [Context Service](https://help.salesforce.com/s/articleView?id=ind.sf_docgen_con_service_docgen_one.htm&language=en_US&type=5). Add image tokens to your document template using the `IMG_tokenname_src` format. To control image dimensions, use `IMG_tokenname_height` and `IMG_tokenname_width` tokens. The `src` field accepts a Salesforce Content Document ID or file name. When multiple files have the same name, the first match is used. See [Token Naming Conventions for Context Service Document Generation](https://help.salesforce.com/s/articleView?id=ind.sf_docgen_con_service_docgen_tokennaming.htm&language=en_US&type=5) and [Example: Generating a Contract Document by Using Context Service](https://help.salesforce.com/s/articleView?id=ind.sf_docgen_con_service_usecase_one.htm&type=5&language=en_US).

To use default image dimensions without manually specifying height and width, transform context data with Data Processing Engine (DPE) and Context Service. See[Transform Context Data for Document Generation](https://help.salesforce.com/s/articleView?id=ind.sf_docgen_ctxtransform_overview.htm&type=5&language=en_US). For an image-specific example, see [Sample Context Definitions for Context Transformation in Document Generation](https://help.salesforce.com/s/articleView?id=ind.sf_docgen_ctxtransform_samples.htm&type=5&language=en_US)

To set up your dynamic images using Data Mappers, follow these instructions:

- **[Upload Images in Salesforce for Server-Side Omnistudio Document Generation](https://help.salesforce.com/s/articleView?id=ind.doc_gen_serverside_dynamic_images_two.htm&release=264.0.0&type=5)**  
    Store images in the Rich Text field, Files, and Notes and Attachments of an object. You can save images in any location; however, for all images to render in the same generated document, make sure you store them in a single repository.
- **[Configure Custom Image Fields for Server-Side Omnistudio Document Generation](https://help.salesforce.com/s/articleView?id=ind.doc_gen_serverside_dynamic_images_three.htm&release=264.0.0&type=5)**  
    Create a custom text field for any object that you want to fetch your image from. To render the image in the generated document, you must map the image API name from your object by using Omnistudio Data Mapper.
- **[Map Image Name to Custom Image Field for Server-Side Omnistudio Document Generation](https://help.salesforce.com/s/articleView?id=ind.doc_gen_serverside_dynamic_images_four.htm&release=264.0.0&type=5)**  
    After you upload an image to the org and create a custom field on the object, map the image name to the custom field. Use Omnistudio Data Mapper to render the image in the generated document.
- **[Map Image Tokens in the Omnistudio Data Mapper for Server-Side Omnistudio Document Generation](https://help.salesforce.com/s/articleView?id=ind.doc_gen_serverside_dynamic_images_five.htm&release=264.0.0&type=5)**  
    Use image tokens in a Microsoft Word or Microsoft PowerPoint document template to insert dynamic images in generated DOCX and PDF files. The image token must start with IMG\_, such as {{IMG\_header}}. Salesforce supports single-image, multiple-image, and loop-image tokens. Use Data Mappers to extract images from the org and define their height and width.
- **[Retrieve Images During Server-Side Omnistudio Document Generation With Sample Custom Class](https://help.salesforce.com/s/articleView?id=ind.doc_gen_serverside_dynamic_images_six.htm&release=264.0.0&type=5)**  
    To retrieve images during server-side document generation, create an Apex class in your org that exposes the getImageContentBlob() method. During Server Side document generation, Salesforce calls this method to retrieve Base64-encoded image data. In your document generation request, pass image token data for each image token. Set the IMG\_ token’s src value to a lookup key that matches a key in the imageContentMap returned by getImageContentBlob(). Salesforce uses this mapping to resolve and insert the image during document generation.