Object operations in DOCX templates

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.

List of object operations

barcode

This operation allows you to create barcodes in your template. See an example below:

{{#barcode value CODE128 200 100}}

This code creates a barcode of type CODE128 with a width of 200 pixels and a height of 100 pixels.

Template

Data

Result

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

the barcode

#barcode operation result

You need to specify the barcode type in the token.

If you’d like to create a square barcode, you can leave out the height, like so:

{{#barcode value CODE128 300}}

This will create a 300x300 barcode.

There are different types of the barcodes.

CODE128

Template:

{{#barcode value CODE128 200 100}}

JSON:

{
      "value": "12345678"
}

CODE11

Template:

{{#barcode value CODE11 200 100}}

JSON:

{
      "value": "01234567"
}

CODE39

Template:

{{#barcode value CODE39 200 100}}

JSON:

{
      "value": "ABC1234"
}

UPCA

Template:

{{#barcode value UPCA 200 100}}

JSON:

{
      "value": "72527273070"
}

MSI

Template:

{{#barcode value MSI 200 100}}

JSON:

{
      "value": "01234567"
}

ISBN

Template:

{{#barcode value ISBN 200 100}}

JSON:

{
      "value": "9781234567897"
}

EAN13

Template:

{{#barcode value EAN13 200 100}}

JSON:

{
      "value": "978020137962"
}

ITF14

Template:

{{#barcode value ITF14 200 100}}

JSON:

{
      "value": "01234567890123"
}

See this article for more information on barcodes.

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: - width and height - your 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, or 270 degrees. Here’s how you’d create a 100x100 image rotated by 90 degrees:

{{#picture imageData 100 rotate:90}}

Note

Rotation supports only the following values: 90, 180, 270, 360.

  • flip - flips the image horizontally (X), vertically (Y), or both (XY). Here are a few examples:

{{#picture imageData 100 flip:X}}

{{#picture imageData 100 flip:Y}}

{{#picture imageData 100 flip:XY}}

Feel free to mix and match these parameters. For example, if you want to create a 400x350 image that’s rotated by 90 degrees and flipped both ways, you’d write it like this: {{#picture imageData 400 350 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}}
{
    "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: - width and height - your 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, or 270 degrees. Here’s how you’d create a 100x100 image rotated by 90 degrees:

{{#pictureCompress imageData 100 rotate:90}}

Note

Rotation supports only the following values: 90, 180, 270, 360.

  • flip - flips the image horizontally (X), vertically (Y), or both (XY). Here are a few examples:

{{#pictureCompress imageData 100 flip:X}}

{{#pictureCompress imageData 100 flip:Y}}

{{#pictureCompress imageData 100 flip:XY}}

Feel free to mix and match these parameters. For example, if you want to create a 400x350 image that’s rotated by 90 degrees and flipped both ways, you’d write it like this: {{#pictureCompress imageData 400 350 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}}
{
    "imageData": "https://picturesite.com/pics/picture.png"
}


{
    "imageData": "iVBORw0KGgoAAAANSUhEUgAAAIAAAAA9CAYAAABlamFgAA"
}
the image

html

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

Template

Data

Result

{{#html text}}
{
    "text": "<html><head><title></title></head>
    <body>This is HTML</body></html>"
}

DOCX file with the HTML:

#html operation 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>

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

You can also upload the source HTML from any connector: SharePoint, OneDrive, etc, and use the dynamic content in Plumsail actions.

HTML operation result