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.
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 |
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 |
|
{
"value": "12345678"
}
|
CODE11 |
|
{
"value": "01234567"
}
|
CODE39 |
|
{
"value": "ABC1234"
}
|
UPCA |
|
{
"value": "72527273070"
}
|
MSI |
|
{
"value": "01234567"
}
|
ISBN |
|
{
"value": "9781234567897"
}
|
EAN13 |
|
{
"value": "978020137962"
}
|
ITF14 |
|
{
"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 |
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 |
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 |
|---|---|---|
|
Default sizing options. |
For example, to fit your picture into a 300x300 square, use the operation as follows:
To calculate the height automatically, feel free to just leave out the height parameter like so:
|
|
Allows you to rotate your picture by 90, 180, 270, or 360 degrees. Only those values are supported. |
|
|
Flips the image horizontally (X), vertically (Y), or both (XY). |
|
|
Picture proportions are preserved and fit into the specified size. |
|
|
This is the default behavior. The picture will be stretched according to the specified sizes. |
|
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.
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 |
|---|---|---|
|
Default sizing options. |
For example, to fit your picture into a 300x300 square, use the operation as follows:
To calculate the height automatically, feel free to just leave out the height parameter like so:
|
|
Allows you to rotate your picture by 90, 180, 270, or 360 degrees. Only those values are supported. |
|
|
Flips the image horizontally (X), vertically (Y), or both (XY). |
|
|
Picture proportions are preserved and fit into the specified size. |
|
|
This is the default behavior. The picture will be stretched according to the specified sizes. |
|
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
|
link
The #link operation creates a hyperlink in your document.
Here’s an example of its usage:
{{#link "https://google.com" "Link text"}}
It takes two parameters:
Link URL- the URL that will open when the text is clicked.Link text- the text that will be displayed for the hyperlink.
Both parameters can be dynamic.
Examples
Template |
Data |
Result |
|---|---|---|
{{#link url title}}
{{#link url "Link text"}}
{{#link "https://google.com" title}}
|
{
"url": "https://google.com",
"title": "Link text"
}
|
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 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 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. |
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>"
}
|
|
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:
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 |
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: