You are here:
Dynamic Images for Client-Side Document Generation
Using image tokens in a Microsoft Word or Microsoft PowerPoint document templates, you can insert dynamic images in generated .docx and .pdf files. With dynamic image tokens you can insert images such as product images, barcodes, pie charts in your document.
An image token must start with IMG_. The format is {{IMG_<imagetokenname>}}, for example, {{IMG_header}}. You can use of a single image, multiple images, and loop images. 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. The height and width of the images can be defined in a Omnistudio Data Mapper Transform.
You can store images as static resources, in Files, in the Documents tab, or in the Notes and Attachments of an object. The images pass through the image tokens using Data Mapper Transform, or Custom Class, or Omniscripts. Map the Id of the sObject (where the image is stored) to the image token. The sObject Id in the Data Mapper extracts the image from the org. For example, if you upload an image to Files, then you need to add the Content Version Id in the Data Mapper to extract the image from the org. Image tokens support image formats such as .png and .jpeg.
Dynamic images have several use cases:
-
In a generated quote, insert an image for every product that's been ordered. Images for products are stored in Salesforce.
-
In a generated contract, insert a unique barcode image. Barcodes are generated by a separate barcode generator.
-
In a generated document, insert a pie chart as an image.
The image shows an example of a Word document with a list of products, their names, and their images. For each product, a dynamic image is inserted.
In .pptx, if you want your text and image to render in the same line in a document, you need to put the text and the dynamic image token in separate text boxes in the same line.
- Upload Images for Use in Omnistudio Document Generation
You can store Omnistudio Document Generation images in Static Resources, the Files, the Documents tab, or the Notes and Attachments of an object. You can store the images in any location. You must ensure that all the images that you want to render in the same generated document must be stored in a single repository. - Create Custom Image Fields for Your Object
Create a custom text field for any object from where you want to fetch your image. You must map the image API name from your object using Omnistudio Data Mapper to render the image in the generated document. - Map Image Name to Custom Image Field in Your Object
After you’ve uploaded an image to your org and created a custom field in your object, map the image name in the object's custom field. Using Omnistudio Data Mapper you can render the image in the generated document. - Map Image Tokens in the Omnistudio Data Mapper
Using image tokens in the Microsoft Word or Microsoft PowerPoint document templates, you can insert dynamic images in the generated .docx and .pdf files. The image token must start with IMG_, for example, {{IMG_header}}. Salesforce supports the use of single image, multiple image, and loop image tokens. Using Data Mappers you can extract the images from the org and also define the height and width of the images. - Sample Custom Class To Retrieve Images
You can retrieve an image using custom logic with a custom class implementation. Instead of uploading an image to files, or static resources, you can use custom logic to retrieve an image using an image ID.

