Text tags
A text tag is any data field of type, string, number, or date. For example, the following fields can become text tags:- id
- date
- customerId
- customerName
- currency
- amount
| Document template | Output document |
Invoice Invoice id: {{invoice.id}} Invoice date: {{invoice.date}}
{{invoice.currency}}{{invoice.amount}} | Invoice Invoice id: Inv1203 Invoice date: 13-03-2023
$5060.50 |
Optional tags
| Input format | Input data | Output data |
| {{invoice.customerName}} | - | {{invoice.customerName}} |
| {{invoice.customerName :: optional}} | - |
Default values
| Input format | Input data | Output data |
| {{invoice.customerName}} | - | {{invoice.customerName}} |
| {{invoice.customerName :: default(“Box Inc”)}} | - | Box Inc |
Formatting text tags
| Input format | Input data | Output data | Supported via script | Supported via Add-in |
| {{invoice.customerName :: uppercase}} | Acme Inc | ACME INC | Yes | No |
| {{invoice.customerName :: lowercase}} | Acme Inc | acme inc | Yes | No |
| {{invoice.date :: format( “dd-mm-yyyy”) }} | 13-03-2023 | 13-03-2023 | Yes | No |
| {{invoice.date :: format(“mm-dd-yyyy”) }} | 13-03-2023 | 03-13-2023 | Yes | No |
| {{invoice.date :: format(“dd-mmm-yy”) }} | 13-03-2023 | 13-Mar-22 | Yes | No |
| {{invoice.id :: format(“xxx-xxxx”) }} | Inv1203 | Inv-1203 | Yes | No |
| {{invoice.amount :: format(“EU-Number”) }} | 300000 | 300.000 | Yes | No |
| {{invoice.amount :: format(“US-Number”) }} | 300000 | 300,000 | Yes | No |
Rich text
Box Doc Gen allows you to generate documents with rich text. If the input JSON data contains HTML tags such as bold, italic, underline, line breaks, paragraphs, anchors, or images, Doc Gen automatically interprets them as rich text and applies the relevant formatting.| HTML Tags | JSON data | Output |
| Bold | { "company": "<b>Acme Inc.</b> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<b> 999-999-9999</b>" } | Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999 |
| Italic | { "company": "<i>Acme Inc.</i> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<i> 999-999-9999</i>" } | Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999 |
| Underline | { "company": "<u>Acme Inc.</u> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<u> 999-999-9999</u>" } | Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999 |
| Bold, Italic and Underline | { "company": "<b><i><u>Acme Inc.</u></i></b>A fictional company that features prominently in the Road Runner show as a running gag. Phone:<b><i><u> 999-999-9999</u></i></b>" } | Acme Inc*.* A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999 |
| Strong | { "company": "<strong>Acme Inc.</strong> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<strong> 999-999-9999</strong>" } | Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999 |
| Span | { "company": "<span>Acme Inc.</span> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<span> 999-999-9999</span>" } | Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999 |
| Emphasized | { "company": "<em>Acme Inc.</em> A fictional company that features prominently in the Road Runner show as a running gag. Phone:<em> 999-999-9999</em>" } | Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999 |
| Line breaks | { "company": "<b>Acme Inc.</b> \n A fictional company that features prominently in the Road Runner show as a running gag. \n Phone:<b> 999-999-9999</b>" } | Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999 |
| Paragraphs | { "company": "<b>Acme Inc.</b> <p> A fictional company that features prominently in the Road Runner show as a running gag. </p> <p> Phone:<b> 999-999-9999</b>"</p> } | Acme Inc. A fictional company that features prominently in the Road Runner show as a running gag. Phone: 999-999-9999 |
| Ordered list |
| |
| Unordered list |
|
Image tags
An image tag can be used to dynamically add and render images. Box Doc Gen supports images in base64 format. To add image tags to your Box Doc Gen template:- Insert a placeholder image, position it, and resize it to your needs
- Add a $image-path variable to the image under Alt text. Under the image path, refer to the variable in the JSON data that holds your image in base64.
For the sample JSON code below, we refer to contract.logo to have the base64:
Document Template

Output
Box Doc Gen replaces the placeholder image with the base64 value associated with the key identified. The output on the generated document will display as follows:
Table tags
An array from the input data can be used to generate and dynamically format a table. In the following example:- items is an array that can be rendered as a dynamic table.
- id, name, quantity, price, amount are the variables within the array that can be rendered as individual columns to the dynamic table.
Document Template
The document template with inserted tags will look as follows:| Id | Name | Qty | Price |
| {{tablerow item in invoice.items}} | |||
| {{item.id}} | {{item.name}} | {{item.quantity}} | {{item.price}} |
| {{endtablerow}} |
Output
Box Doc Gen automatically identifies the table tags added to the document template, matches them with the fields in the input JSON data, and performs a few iterations to generate a complete table for the input data. The output table on the generated document will look as follows:| Id | Name | Qty | Price |
| 1 | A4 Papers | 100 | 29 |
| 2 | Ink Cartridge | 40 | 39 |
| 3 | Adhesive tape | 20 | 30 |
List tags
An array from the input data can be used to dynamically generate an ordered or unordered list. In the following example:- items is an array that can be rendered as a dynamic list.
- id, name, quantity, price, amount are the variables within the array that can be rendered as a repetitive field in the list.
| Use case | Document template | Output document |
| Adding a bullet list | List of products: {{ for item in invoice.items }}
|
|
| Adding a bullet list with one or more variables | List of products: {{ for item in invoice.items }}
{{ endfor }} |
|
| Adding a squared bullet list with one or more variables | List of products: {{ for item in invoice.items }}
{{ endfor }} |
|
| Adding a white bullet list with one or more variables | List of products: {{ for item in invoice.items }}
{{ endfor }} | List of products:
|
| Adding a numbered list with one or more variables | List of products: {{ for item in invoice.items }}
{{ endfor }} |
|
| Adding a roman numbered list with one or more variables | List of products: {{ for item in invoice.items }}
{{ endfor }} |
|
| Adding an alphabetical list with one or more variables | List of products: {{ for item in invoice.items }}
{{ endfor }} |
|
Formatting lists
Box Doc Gen templates support a wide range of custom codes that you can use in the document template. Taking the following JSON input data as an example, you can introduce different separators and delimiters.| Type of list | Document template | Output document | |
| List - with comma separator | {{ items :: delimiter(“,”)}} | A4 Papers, Ink cartridge, Adhesive tape | |
| List - with semicolon separator | {{ items :: delimiter(“;”)}} | A4 Papers; Ink cartridge; and Adhesive tape | |
| List - with customer separator | {{ items :: delimiter(“~”)}} | A4 Papers~ Ink cartridge~ Adhesive tape | |
| List - with Comma and last delimiter | {{ items :: delimiter(“,”) , lastdelimiter (“, and”)}} | A4 Papers, Ink cartridge, and Adhesive tape | |
| List - with semicolon and last delimiter | {{ items :: delimiter(“;”) , lastdelimiter (“; and”)}} | A4 Papers; Ink cartridge; and Adhesive tape | |
| List - with custom separator and last delimiter | {{ items | delimiter(“~”)}}, lastdelimiter (“~ and”)}} | A4 Papers~ Ink cartridge~ and Adhesive tape |
Conditions
You can use conditions to add input to the output document. The Box Doc Gen Template Creator add-in can help you define these conditions within the document template.Supported conditions and operators
| Tag type | Conditions supported | Operators supported to chain conditions |
| String | ==(is equal to), !=(is not equal to), isPresent | AND, OR |
| Date | isPresent | AND, OR |
| Number | <, >, ==, !=, >=, <= | AND, OR |
| Use case | Document template | Output document |
| Introducing content based on payment method and payment terms | Payment terms: {{ if invoice.paymentMethod == “Online Transfer” AND invoice.paymentTerms == “Net30” }}
{{ elseif invoice.paymentMethod == “Cheque” AND invoice.paymentTerms == “Net60” }}
{{else}}
{{endif}} |
|
| Adding processing fees based on invoice amount, and payment method | Processing fees: {{ if invoice.amount > 1000 AND invoice.amount < 5000 AND invoice.paymentMethod == “Cheque” }}
{{ elseif invoice.amount > 5000 AND invoice.paymentMethod == “Cheque”}}
{{else}}
{{endif}} |
|
| Adding delivery terms based on delivery date on invoice | Delivery terms: {{ if invoice.deliveryDate isPresent }}
{{else}}
|
|
Conditions with tables
Doc Gen allows you to conditionally render any content including tables, images, and so on. {{ if invoice.customerId isPresent }}| Id | Name | Qty | Price |
| {{tablerow item in invoice.items}} | |||
| {{item.id}} | {{item.name}} | {{item.quantity}} | {{item.price}} |
| {{endtablerow}} |
Conditions inside tables
Doc Gen allows you to conditionally render content with a column in a table. Examples| Id | Name | Qty | Price |
| {{ tablerow item in invoice.items }} | |||
| {{ item.id}} | {{ item.name}} | {{ item.quantity}} | {{ if item.price isPresent}}{{item.price}}{{ else }}-{{ endif }} |
| {{ endtablerow }} |
Calculations
Box Doc Gen templates support dynamic calculations. You can either write the computation code to the tagging language manually, or use the Box Doc Gen Template Creator add-in.Sample code calculations include:
- Invoice: Determining the net invoice amount from individual line items.
Example: Sum (Individual Line item amounts in the invoice) - Purchase order: Capping the maximum sourcing amount.
Example: 5% * Net Order Value - Sales contracts: Defining penalty on SLA breach.
Example: 10% * Total Sales Value
| Arithmetic operations | Aggregation operations |
| % | Percent |
| + | SUM |
| * | AVERAGE |
| - | COUNT |
| Use case | Document template | Output document |
To calculate net amount from the given Gross Amount and Tax Amount Arithmetic calculation | Net Amount: {{ invoice.grossAmount + invoice.taxAmount}} | Net Amount: Annotation: |
To calculate net amount from the given Gross Amount, Tax Rate and Shipping Charge Arithmetic calculation | Net Amount: {{ invoice.grossAmount + invoice.taxAmount + invoice.shippingCharge}} | Net Amount: Annotation: |
To calculate tax amount from the given Tax Rate and Gross Amount Arithmetic calculation | Tax Amount: {{ invoice.taxRate % * invoice.grossAmount}} | Tax Amount: Annotation: |
To calculate gross amount from individual line item amounts Aggregation calculation | Gross Amount: {{ $sum(invoice.items.amount) }} | Gross Amount: Annotation: |
To calculate number of line items Count calculation | Count: {{ $count(invoice.items.amount) }} | Count: 3 |
| To calculate average of line items | Average Amount: {{ $average(invoice.items.amount) }} | Average Amount: 1686.66 |
To calculate net amount from the given Line Item Amount, and Tax Rate Arithmetic + Aggregation calculation | Net Amount: {{ $sum(invoice.items.amount) + invoice.taxRate % * $sum(invoice.items.amount)}} | Net Amount: Annotation: |
Box Sign template tags
Box Sign template tags can be added to the Box Doc Gen template for the output document created via Box Box Doc Gen to be sent for e-signature. Box Doc Gen supports Box Sign template tags. The table below lists the tags available in the Box Doc Gen Template Creator add-in and the tagging script.| Field | Box Sign’s template code | Supported via tagging script | Supported via add-in |
| Text field | [[t|0]] | Yes | Yes |
| Date field | [[d|0]] | Yes | Yes |
| Checkbox field | [[c|0]] | Yes | Yes |
| Signature field | [[s|0]] | Yes | Yes |
| Stamp field type | [[st|0]] | Yes | Yes |
| Initials field type | [[i|0]] | Yes | Yes |
| Name field type | [[n|0]] | Yes | Yes |
| First name field type | [[fn|0]] | Yes | Yes |
| Last name field type | [[ln|0]] | Yes | Yes |
| Company field type | [[co|0]] | Yes | Yes |
| Email field type | [[e|0]] | Yes | Yes |
| Title field type | [[ti|0]] | Yes | Yes |
| For an attachment field type | [[a|0]] | Yes | Yes |