Managing HTML templates

Defining a HTML template format

The template can support the following types of parameters:
  1. 1.
    Text
Use case: include the company name and registration number in an offer document
Html template specifications:
1
<p><strong>Lorem ipsum: <span th:text=\"${companyName}\"></span></strong>, dolor sit amet <strong><span th:text=\"${cui}\"></span></strong>.</p>
Copied!
Data specifications:
1
{
2
"data": {
3
"companyName": "Test Company SRL",
4
"cui": "RO1234567"
5
}
6
}
Copied!
2. Dynamic tables - repeatable rows
Use case: display in a table as many rows as the elements of a generated list of objects; in the example below we are listing the name and value of all the benefits included in a commercial offer
Html template specifications:
1
<table>
2
<thead>
3
<tr class=\"headings\">
4
<th class=\"column-title\">Name</th>
5
<th class=\"column-title\">Value</th>
6
</tr>
7
</thead>
8
<tbody>
9
<tr class='even pointer' th:each=\"row: ${offerValuesRows}\" id=\"tablerow\">
10
<td th:each=\"header: ${offerValuesHeader}\" th:text=\"${row.get(header)}\" />
11
</tr>
12
</tbody>
13
</table>
Copied!
Data specifications:
1
"data": {
2
"offerValuesHeader": [
3
"Name",
4
"Value"
5
],
6
"offerValuesRows": [
7
{ "Name": "Price (USD/MWh)", "Value": "25" },
8
{ "Name": "Distribution rate (USD/MWh)", "Value": "C1 category: 27, C2 category: 29" },
9
{ "Name": "Subscription price / day / place of consumption", "Value": "C1 category: 1.25, C2 category: 1.32" },
10
{ "Name": "Period of validity of the price", "Value": "Validity time fixed price Monday, from the start date of delivery to the date of completion of delivery" },
11
{ "Name": "Payment term", "Value": "90 days" }
12
]
13
}
14
Copied!
3. Dynamic table - repeatable table
Use case: display a table as many times as the elements of a generated list of objects; in the example below we are listing the consumption points registered through the process
Html template specifications:
1
<p>Oferta Denumire oferta este aplicabila urmatoarelor locuri de consum:</p>
2
<div th:each=\"type: ${consumptionPoints}\">
3
<table>
4
<thead>
5
<tr>
6
<th> Loc de consum </th>
7
<th> Distribuitor </th>
8
<th> Cod CLC </th>
9
<th> Modalitatate introducere consum </th>
10
<th> Tip consum </th>
11
<th> Categorie consum \n(MWh) </th>
12
<th> Consum total anual \n(MWh) </th>
13
</tr>
14
</thead>
15
<tbody>
16
<tr th:if=\"${type.consumptionPoint.empty}\">
17
<td colspan=\"7\"> Acest loc de consum nu contine informatii! </td>
18
</tr>
19
<tr th:each=\"consumptionPoint : ${type.consumptionPoint}\">
20
<td><span th:text=\"${consumptionPoint.consumptionPoint}\"> Loc de consum </span></td>
21
<td><span th:text=\"${consumptionPoint.distribuitor}\"> Distribuitor </span></td>
22
<td><span th:text=\"${consumptionPoint.clcCode}\"> Cod CLC </span></td>
23
<td><span th:text=\"${consumptionPoint.consumerInputMethod}\"> Modalitatate introducere consum </span></td>
24
<td><span th:text=\"${consumptionPoint.consumerType}\"> Tip consum </span></td>
25
<td><span th:text=\"${consumptionPoint.consumerCategory}\"> Categorie consum \n(MWh) </span></td>
26
<td><span th:text=\"${consumptionPoint.totalAnnualConsumption}\"> Consum total anual \n(MWh) </span></td>
27
</tr>
28
</tbody>
29
</table>
30
</div>
Copied!
Data specifications:
1
"data": {
2
"consumptionPoints": [
3
{
4
"consumptionPoint": [
5
{
6
"consumptionPoint": "Lorem ipsum",
7
"distribuitor": "Distribuitor 1",
8
"clcCode": "123456",
9
"consumerInputMethod": "Lorem ipsum kghf",
10
"consumerType": "Lorem ipsum",
11
"consumerCategory": "Lorem ipsum",
12
"totalAnnualConsumption": "Lorem ipsum"
13
}
14
]
15
},
16
{
17
"consumptionPoint": [
18
{
19
"consumptionPoint": "Lorem ipsum",
20
"distribuitor": "Distribuitor 2",
21
"clcCode": "131313",
22
"consumerInputMethod": "Lorem ipsum tryuty",
23
"consumerType": "Lorem ipsum",
24
"consumerCategory": "Lorem ipsum",
25
"totalAnnualConsumption": "Lorem ipsum"
26
}
27
]
28
}
29
]
30
}
Copied!
4. Dynamic sections
Use case: display a paragraph only when a certain condition is met; in the example below, we display a section only if the client type is PJ
Html template specifications:
1
<span th:if=\"${pjCLient==true}\">
2
<p><b>PJ section, visible only if pjCLient = true</b></p>
3
<p><span th:text=\"${termTechnicalServices}\"></span></p>
4
</span>
5
<span th:if=\"${pjCLient==false}\">
6
<p><b>PF section, visible only if pjCLient = false</b></p>
7
<p><span th:text=\"${termInsuranceServices}\"></span></p>
8
</span>
9
Copied!
Data specifications:
1
"data": {
2
"pjCLient": true
3
}
Copied!
5. Images
Use case: include in the final document images that are generated throughout the process; in the example below, we are attaching to the document the holograph signature of the client
Html template specifications:
1
<td class='align'><img th:src=\"*{'data:image/png;base64,'+signature}\" alt=\"\" height='100px'/></td>
Copied!
Data specifications:
1
"data": {
2
"signature": "INSERT_BASE64_IMAGE"
3
}
Copied!
6. Barcodes
In order to opt for including a barcode, the parameter includeBarcode should be set as true.
7. Lists
Use case: display a bulleted list with values from selected items in a checkbox; in the example below we are listing the source of income:
Html template specifications:
1
<div th:if=\"${incomeSource != null}\">
2
<h3>Income source:</h3>
3
<ul>
4
<li th:each=\"item : ${incomeSource}\" th:text=\"${item}\"></li>
5
</ul>
6
</div>
Copied!
Data specifications:
1
{
2
"data": {
3
"incomeSource": [
4
"Income 1",
5
"Income 2",
6
"Income 3",
7
"Income 4"
8
]
9
}
10
}
Copied!

Managing HTML templates

REST API

POST {{documentUrl}}/internal/html/templates - create a template
PUT {{documentUrl}}/internal/html/templates - update the template
GET {{documentUrl}}/internal/html/templates - get all templates
GET {{documentUrl}}/internal/html/templates/HTML_TEMPLATE_NAME - get a template by name
DELETE {{documentUrl}}/internal/html/templates/HTML_TEMPLATE_NAME - delete a tempalte by name
POST {{documentUrl}}/internal/html/templates/generate - generate a new docs based on a template
POST {{documentUrl}}/internal/html/templates/convert - converts a docx file to html

Examples

example_html_template.html
121KB
Text
html template example
html_generated_document.pdf
76KB
PDF
pdf generated based on the html example