Object operations in DOCX templates

Modern templating engine

Still using Classic syntax? See the Classic documentation.

Learn the differences.

Object operations allow you to insert Word-specific objects into your document.

In this article, you’ll find a list of all the object operations you can use in DOCX templates. Each one comes with examples to help you see how you can use them in your documents.

barcode

Use the #barcode operation to generate barcodes in your template.

To see a full example, check how to create documents with barcodes from a template.

Syntax:

{{#barcode value "TYPE" width height}}

  • value — the token containing the barcode value

  • TYPE — barcode type (must be in quotes)

  • width — barcode width in pixels

  • height — barcode height in pixels

Example:

Template

Data

Result

{{#barcode value "CODE128" 300 100}}
{
    "value": "test barcode"
}

the barcode

#barcode operation result

This code generates a CODE128 barcode that is 300 pixels wide and 100 pixels high.

If you’d like to create a square barcode, you can leave out the height. This generates a barcode with a width and height of 300 pixels:

{{#barcode value "CODE128" 300}}

There are different types of the barcodes.

The following barcode types are supported:

Barcode type

Template

JSON data

CODE128

{{#barcode value "CODE128" 200 100}}

{
    "value": "12345678"
}

CODE11

{{#barcode value "CODE11" 200 100}}

{
    "value": "01234567"
}

CODE39

{{#barcode value "CODE39" 200 100}}

{
    "value": "ABC1234"
}

UPCA

{{#barcode value "UPCA" 200 100}}

{
    "value": "72527273070"
}

MSI

{{#barcode value "MSI" 200 100}}

{
    "value": "01234567"
}

ISBN

{{#barcode value "ISBN" 200 100}}

{
    "value": "9781234567897"
}

EAN13

{{#barcode value "EAN13" 200 100}}

{
    "value": "978020137962"
}

ITF14

{{#barcode value "ITF14" 200 100}}

{
    "value": "01234567890123"
}

qrcode

This operation allows you to insert a QR code into your template. You only need to set one parameter: the width in pixels. Since QR codes are always square, the height will match the width automatically.

Template

Data

Result

{{#qrcode value 150}}
{
    "value": "https://plumsail.com/"
}

the qrcode

#qrcode operation result

There are different types of QR codes, you can specify it in the JSON.

URL

To encode the text of a URL, for example, https://plumsail.com/, encode the https://plumsail.com/ URL text in the JSON. Include the http:// protocol to ensure it is recognized as a URL.

{
      "value": "https://plumsail.com/"
}

Telephone Numbers

To encode a telephone number, use a telephone URI to ensure that the digits are recognized as a telephone number and include prefixes which make the number internationally accessible.

{
      "value": "tel:+1-234-555-6677"
}

SMS

To encode an SMS short code or number, create an SMS URI. For example, to create a link to the 12345 number, encode sms:12345. You may use other URI forms, such as sms:number:subject, and other prefixes, such as smsto:.

{
      "value": "sms:12345"
}

Geolocations

To encode a point on the earth, including altitude, use a geo URI.

{
      "value": "geo:42.65049,23.37925,100"
}

Hint

Read this article to get inspired on how to enrich your documents with various QR codes.

checkbox

#checkbox - activates checkboxes in a DOCX template.

For example, a user fills out some online form and the #checkbox operation activates checkboxes in a DOCX template depending on the forms’ values.

The result DOCX document could be an application or questionnaire.

Find more information about using the operation in the article How to populate Word with checkboxes using Power Automate.

Template

Data

Result

{{#checkbox prop1}}
{{#checkbox prop2}}
{
    "prop1": true,
    "prop2": false
}

DOCX file with activated checkboxes

#checkbox operation result

picture

The #picture operation resolves URL or base64 string and converts it to an image. This operation doesn’t compress the source picture and keeps its original quality.

There are several parameters that you can use to customize how the image comes out in the final document:

Parameter

Description

Examples

width and height

Default sizing options.

For example, to fit your picture into a 300x300 square, use the operation as follows: {{#picture imageData 300 300}}

To calculate the height automatically, feel free to just leave out the height parameter like so: {{#picture imageData 300}}

rotate

Allows you to rotate your picture by 90, 180, 270, or 360 degrees. Only those values are supported.

{{#picture imageData 100 rotate:90}}

flip

Flips the image horizontally (X), vertically (Y), or both (XY).

{{#picture imageData 100 flip:X}}

{{#picture imageData 100 flip:Y}}

{{#picture imageData 100 flip:XY}}

Fit

Picture proportions are preserved and fit into the specified size.

{{#picture imageData 100 50 Fit}}

Stretch

This is the default behavior. The picture will be stretched according to the specified sizes.

{{#picture imageData 100 50 Stretch}}

Feel free to mix and match these parameters. For example, if you want to fit the image to a 400x350 resolution, rotated it by 90 degrees and flip it both ways, you’d write it like this: {{#picture imageData 400 350 Fit rotate:90 flip:XY}}

Refer to this article for more information on how to add pictures.

Examples

Template

Data

Result

{{#picture imageData}},

{{#picture imageData 300}},

{{#picture imageData 150 200}},

{{#picture imageData 200 300 flip:Y}},

{{#picture imageData 300 rotate:270}},

{{#picture imageData 100 50 flip:XY rotate:90}}

{{#picture imageData 100 50 Fit flip:XY rotate:90}}
{
    "imageData": "https://picturesite.com/pics/picture.png"
}


{
    "imageData": "iVBORw0KGgoAAAANSUhEUgAAAIAAAAA9CAYAAABlamFgAA"
}
the image

You can use the #picture operation in the Alt Text of your image. This lets you adjust the size of the inserted picture, too.

Using the #picture operation in a placeholder image

pictureCompress

The #pictureCompress operation resolves URL or base64 string and converts it to an image. This operation compresses the source picture.

There are several parameters that you can use to customize how the image comes out in the final document:

Parameter

Description

Examples

width and height

Default sizing options.

For example, to fit your picture into a 300x300 square, use the operation as follows: {{#pictureCompress imageData 300 300}}

To calculate the height automatically, feel free to just leave out the height parameter like so: {{#pictureCompress imageData 300}}

rotate

Allows you to rotate your picture by 90, 180, 270, or 360 degrees. Only those values are supported.

{{#pictureCompress imageData 100 rotate:90}}

flip

Flips the image horizontally (X), vertically (Y), or both (XY).

{{#pictureCompress imageData 100 flip:X}}

{{#pictureCompress imageData 100 flip:Y}}

{{#pictureCompress imageData 100 flip:XY}}

Fit

Picture proportions are preserved and fit into the specified size.

{{#pictureCompress imageData 100 50 Fit}}

Stretch

This is the default behavior. The picture will be stretched according to the specified sizes.

{{#pictureCompress imageData 100 50 Stretch}}

Feel free to mix and match these parameters. For example, if you want to fit the image to a 400x350 resolution, rotated it by 90 degrees and flip it both ways, you’d write it like this: {{#pictureCompress imageData 400 350 Fit rotate:90 flip:XY}}

Refer to this article for more information on how to add pictures.

Examples

Template

Data

Result

{{#pictureCompress imageData}},

{{#pictureCompress imageData 300}},

{{#pictureCompress imageData 150 200}},

{{#pictureCompress imageData 200 300 flip:Y}},

{{#pictureCompress imageData 300 rotate:270}},

{{#pictureCompress imageData 100 50 flip:XY rotate:90}}

{{#pictureCompress imageData 100 50 Fit flip:XY rotate:90}}
{
    "imageData": "https://picturesite.com/pics/picture.png"
}


{
    "imageData": "iVBORw0KGgoAAAANSUhEUgAAAIAAAAA9CAYAAABlamFgAA"
}
the image

html

The #html operation converts provided HTML code into DOCX text and elements.

When no parameter is passed or when the MixStyle parameter is explicitly used:

  • Document styles: Applied.

  • Inline HTML styles: Applied, and take precedence over document styles where properties overlap.

When DocumentStyle parameter is used:

  • Document styles: Applied.

  • Inline HTML styles: Ignored.

Note

Only styles saved under the Normal text formatting are applied.

You can refer to the following examples for a clear understanding of the differences.

Template

Data

Result

{{#html text}}
{
    "text": "<html><head><title></title></head>
    <body><p style=\"color: green; font-size: 20px\">
    This is HTML</p></body></html>"
}

DOCX file with converted HTML elements. Inline styles are applied.

HTML formatter result
{{#html text MixStyle}}
{
    "text": "<html><head><title></title></head>
    <body><p style=\"color: green; font-size: 20px\">
    This is HTML</p></body></html>"
}

DOCX file with converted HTML elements. Inline styles are applied.

HTML formatter result
{{#html text DocumentStyle}}
{
    "text": "<html><head><title></title></head>
    <body><p style=\"color: green; font-size: 20px\">
    This is HTML</p></body></html>"
}

DOCX file with converted HTML elements. Inline styles are ignored.

HTML formatter result

Here are the supported HTML tags:

  • <a>

  • <h1-h6>

  • <abbr> and <acronym>

  • <b>, <i>, <u>, <s>, <del>, <ins>, <em>, <strike>, <strong>

  • <br> and <hr>

  • <table>, <td>, <tr>, <th>, <tbody>, <thead>, <tfoot> and <caption>

  • <cite>

  • <div>, <span>, <font> and <p>

  • <pre>

  • <sub> and <sup>

  • <ul>, <ol> and <li>

  • <dd> and <dt>

  • <q> and <blockquote>

  • <article>, <aside>, <section> are considered like <div>

  • <img>: use either a URL or a Base64-encoded string for the image source.

Template

Data

Result

{{#html text}}
{
    "text": "<html><head><title></title></head>
    <body><p>This is HTML</p>
    <img width='300' src='https://picturesite.com/pics/picture.png'>
    </body></html>"
}
HTML formatter with img tag

Note

Images in DOCX documents won’t appear until you enable editing.

Javascript (<script>), CSS <style>, <meta> and other not supported tags does not generate an error but are ignored.

You can upload the source HTML file from any connector: SharePoint, OneDrive, etc, and use the dynamic content in Plumsail processes. Here’s an example in Power Automate:

HTML operation result

markdown

The #markdown operation converts provided Markdown code into DOCX text and elements.

Template

Data

Result

{{#markdown text1}}
{{#markdown text2}}
{{#markdown text3}}
{{#markdown text4}}
{{#markdown text5}}
{
    "text1": "# h1 Heading",
    "text2": "## h2 Heading",
    "text3": "**This is bold text**",
    "text4": "*This is italic text*",
    "text5": "~~Strikethrough~~"
}

DOCX file with the markdown text

Markdown operation result

You can upload the source markdown file from any connector: SharePoint, OneDrive, etc, and use the dynamic content in Plumsail processes. Here’s an example in Power Automate:

Markdown operation