Image Syntax

To insert images in your template, you have two options:

  1. Use an image placeholder.
  2. Use an image text tag.

Image Placeholder

Image placeholders allow you to replace existing images in your template while preserving their size, position, and styling.

Consider the following template:

Image Placeholder Example
{{ FullName }}{{ JobTitle }}

To let TemplateDocs know you want to replace the placeholder image, insert a tag in its alt text:

  1. Right-click the placeholder image.
  2. Select "View Alt Text...".
  3. Insert the tag in the alt text ({{ProfilePicture}} in this example).
View Alt Text Context Menu
Alt Text Panel

Provide the image details in your JSON data using the image object structure shown below:

{
  "ProfilePicture": {
    "_type": "image",
    "format": "image/png",
    "source": "https://example.com/john.png"
  },
  "FullName": "John Smith",
  "JobTitle": "Real Estate Agent",
}

The resulting document will look like this:

Image Placeholder Example
John SmithReal Estate Agent

Image Text Tag

If you prefer, you can still use standard template tags to insert images into the document. Simply place the tag where you want the image to appear. For example:

{{ ProductImage }}

When you generate a document from the template, the tag will be replaced with the actual image.

Consider the following JSON data:

{
  "ProductImage": {
    "_type": "image",
    "source": "https://example.com/shoes.jpg",
    "format": "image/jpeg",
    "width": 230,
    "height": 230
  }
}

The resulting document will look like this:

Image Text Tag Example

Image Properties

PropertyTypeDescription
_typestringMust be set to "image"
sourcestringRequired. URL or Base64 encoded image data
formatstringRequired. One of: image/png, image/jpeg, image/bmp, or image/gif
widthnumberImage width in pixels. Required when using text tags, optional when using image placeholders
heightnumberImage height in pixels. Required when using text tags, optional when using image placeholders
altTextstringOptional. Alternative text for accessibility
transparencyPercentnumberOptional. Transparency level from 0 (opaque) to 100 (transparent)

Examples

URL Image Source

{
  "MyImage": {
    "_type": "image",
    "source": "https://example.com/image.png",
    "format": "image/png",
    "width": 200,
    "height": 200,
  }
}

Base64 Image Source

{
  "MyImage": {
    "_type": "image",
    "source": "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAYAAAB...",
    "format": "image/jpeg",
    "width": 300,
    "height": 300
  }
}

Transparency and Alt Text

{
  "MyImage": {
    "_type": "image",
    "source": "https://example.com/image.jpg",
    "format": "image/jpeg",
    "width": 250,
    "height": 250,
    "transparencyPercent": 30,
    "altText": "My Image"
  }
}