Embedding Images or PDFs Using comms-data Tag
Embedding Images Using comms-data Tag
Communication Cloud Service lets you include images from JSON payload into Content by using <comms-data> tag. Supported file types include JPG, PNG and SVG image types.
Example:
You may be using images from your system that you want included in your generated output along with other information. In the example below, a cancelled cheque image will be added to the communication to your customer.
{
{
"$$Id": "PackageName",
"Fields": [
{
"Name": "CancelledCheque",
"Path": "$.CancelledCheque"
}
]
}
Sample Content
Note:
To resize the image, you can use the Transform style attribute. For more information, refer topic Style Attributes in Communication Cloud Service
Dear User,
We are hereby enclosing the provided cancelled cheque for your confirmation.
<comms-data>$Data{"Id":"CancelledCheque", "Type":"Image"}</comms-data>
Thank You
{ "CancelledCheque": "replace this with the base64 encoded data of the image file" }
Embedding PDFs Using <comms-data> Tag
Communication Cloud Service allows you to embed PDF documents directly into your communication content using the <comms-data> tag with Type as PDF. The Base64-encoded PDF content must be provided as input. At runtime, the Communication Assembly decodes the Base64 data, converts it into a PDF and stitches it into the generated output. Each PDF is inserted on a new page within the final output, and subsequent content continues on a new page after the inserted PDF.
<comms-data>$Data{"Id":"SamplePDF", "Type":"PDF"}</comms-data>