Dynamically inserting an image in to a document requires two things:
- The template controlswherethe image will appear
- The datadetermineswhatimage is used
This article explains how to structure the data.
The Template
Please refer to this article to learnhow to use aplaceholder image in the templateto control where the imageappears in the final document.
The three options below assume the templatewill be using thedata item "logoImage".
The Data
The image that will appear in the finished document is determined by the data.
When calling the REST API of Cloud or Tornado, there are three different ways to provide image data.
Send the image in the data as a BASE64 encoded binary representation
In JSON format, the data would look like this:
"logoImage":"image:base64:iVBORw0KGgoAAAA... "
Note that the data must have"image:base64:"appended before the BASE64 data string.
Use an image file name, also called stock images
This approach is useful where the same image (eg: a signature or alogo) will be used multiple times, possibly in many different documents.
The image must be provided to Docmosis before the document generation occurs and the data contains a reference to that image.
CLOUD: The images should be loaded to the Images area either via the Cloud Console or using the API. If youuse folders to organise your images, the path should include those folders.
TORNADO: The images should be stored in the same folder used for the templates. You may choose to create a top level folder (for example: "Images") to help separate the images from your templates, in which case your would use:"[userImage:Images/...]"
In JSON format, the data should look like this:
"logoImage":"[userImage:customers/Meta-Logo-Long.png]"
Note the values are surrounded by square "[ ]" brackets. Thetext "userImage:" precedes the filename. The filename can also include a path to the image.
The URL of the image
In this case the image to be inserted will be provided by a URL. This approach may beuseful where the image is dynamically generatedor is specific toeach document.
"logoImage":"[imageUrl:http://metalegalfinance.com/resources/Meta-Logo-Long.png]"
Note the values are surrounded by square "[ ]" brackets. Thetext "imageUrl:" precedes the URL path.
The URL needs to be whitelisted, before it can be used.
CLOUD: To whitelist a URL please contact support to organize this.
TORNADO: To whitelist a URL you need to apply a Custom Setting on the Configurationpage of the Tornado Console. The setting is: "docmosis.external.resources.whitelist=https://example.com;http://another.com"(without the quotes). To whitelist multiple domains, seperate each URL with a semi-colon. Enter the URL in the Custom Setting textbox, then hit the Save button and then hit Restart (on the Status page).
Please refer to the Web Services Guide for further details on how to format/structure your image data.