Writting Templates | Documentation | Advicement

Overview

As mentioned previously, the templates are written in latex with additional custom functions to assist getting dynamic content into the documents. The dynamic content is pulled from the JSON data payload using the functions described on this page.

JSON Data Payload

The JSON data payload contains data which is dynamic in the document. There are no JSON schemas that your data has to pass, the only requirement is that is it a valid JSON. To test your template and compile with a sample JSON data payload, you can access it underneath the 'JSON Dataload Test' heading.

Registration-Page-Screenshot

Clicking on the data.json will open your JSON data payload for editing.

Functions to Create Dynamic Content

To include dynamic data into the document we use the following set of functions. We break down the functions by the type of data which they output. Currently, the output of such functions can be in a form of text, number, date, complete table and base64 encoding images.

Include Dynamic Text - AdvGetStrValue

To include dynamic data into the document we use the following set of functions. We break down the functions by the type of data which they output. Currently, the output of such functions can be in a form of text, number, date, complete table and base64 encoding images.

Usage

\advGetStrValue{key = key, format = "none"}

Arguments

key - a key which corresponds to the location of the text located in the JSON Data Payload, e.g 'clientDetails.Name'

format - describes the format into which the string should be changed into. The following options exist: 'none', 'uppercase', 'lowercase', 'sentence' (sentence case) and 'titlecase'.

Examples

The following example shows how to use the advGetStrValue function:

{ "clientDetails": { "name": "Nelson Mandela" } }
\documentclass[a4paper]{article} \usepackage[top=1cm, bottom=1cm, left=1cm, right=1cm,]{geometry} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} % Font setup \usepackage[default,scale=0.95]{opensans} \begin{document} \advGetStrValue{key = clientDetails.name, format = uppercase} \end{document}
advGetStrValue-PDF-Screenshot

Include Dynamic Number - advGetNumValue

Usage

\advGetNumValue{key, decimalPlaces = 2, decimalSeparator = fullstop, thousandsSeparator = none}

Arguments

key - a key which corresponds to the location of the text located in the JSON Data Payload, e.g 'clientDetails.Age'

decimalPlaces - a numeric parameter which determines the number of decimal places to show for numeric values, e.g. '4'

decimalSeparator - a string parameter which determines how to show a decimal separator in numbers. Possible values are 'fullstop', 'comma' and 'dash'.

thousandsSeparator - a string parameter which determines how to separate thousands in numbers. Possible values are 'none', 'space', 'fullstop', 'comma' and 'dash'.

Examples

The following example shows how to use the advGetNumValue function:

{ "accountDetails": { "amount": "12345.6789" } }
\documentclass[a4paper]{article} \usepackage[top=1cm, bottom=1cm, left=1cm, right=1cm,]{geometry} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} % Font setup \usepackage[default,scale=0.95]{opensans} \begin{document} \advGetNumValue{key = accountDetails.amount, decimalPlaces = 2, decimalSeparator = fullstop, thousandsSeparator = space} \end{document}
AdvGetNumValue-PDF-Screenshot

Include Dynamic Date - advGetDateValue

Usage

\advGetDateValue{key, formatIn = Y-m-d, formatOut = d-B-Y}

Arguments

key - a key which corresponds to the location of the text located in the JSON Data Payload, e.g 'clientDetails.Name'

formatIn - describes the format of the date in the data JSON.

formatOut - describes the output of the date required in the document.

Examples

The following example shows how to use the advGetDateValue function:

{ "reportDetails": { "date": "2020-12-06" } }
\documentclass[a4paper]{article} \usepackage[top=1cm, bottom=1cm, left=1cm, right=1cm,]{geometry} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} % Font setup \usepackage[default,scale=0.95]{opensans} \begin{document} \advGetDateValue{key = reportDetails.date, formatIn = Y-m-d, formatOut = d B Y} \end{document}
AdvGetDateValue-PDF-Screenshot

Include Dynamic Table - advGetTableData

Usage

\advGetTableData{key, columnNames = NULL, horizonalLines = "none", rowWidth = NULL, includeEmptyLastColumn = FALSE, columnStyle = NULL, prefix = NULL, suffix = NULL, decimalPlaces = NULL, decimalSeparator = fullstop, thousandsSeparator = none}

Arguments

key - a key which corresponds to the location of the table data located in the JSON Data Payload, e.g 'table.data'.

columnNames - an array of column names in order which you want it to appear in your tablem, e.g '{Currency, Amount, Description}'

horizonalLines - a string value descibing type of horizonal lines for the table. The options are: 'none', 'solid', 'dash'.

rowWidth - a value to describe the height for the row in the table, e.g '0.5cm'.

includeEmptyLastColumn - a boolean parameter whether to include an empty column at the end of each row, e.g. 'TRUE'.

columnStyle - an array which indicates the style of each column, e.g. '{bold, emph, underline, italics}'.

prefix - an array of string characters which need to be added to each column at the start, e.g. {,,R}

suffix - an array of string characters which need to be added to each column to the end, e.g. {,,c}

decimalPlaces - a numeric parameter which determines the number of decimal places to show for numeric values, e.g. '4'

decimalSeparator - a string parameter which determines how to show a decimal separator in numbers. Possible values are 'fullstop', 'comma' and 'dash'.

thousandsSeparator - a string parameter which determines how to separate thousands in numbers. Possible values are 'none', 'space', 'fullstop', 'comma' and 'dash'.

Examples

The following example shows how to use the advGetTableData function:

{ "invoiceDetails": [ { "Description": "Jan-2019 Project Start - 120 Hours", "Currency": "USD", "Amount": 9600 }, { "Description": "Feb-2019 - Project PDF Start - 80 Hours", "Currency": "USD", "Amount": 6400 }, { "Description": "Mar-2019 - Project PDF - 90 Hours", "Currency": "USD", "Amount": 7200 }, { "Description": "Apr-2019 - Project PDF - 100 Hours", "Currency": "USD", "Amount": 8000 }, { "Description": "May-2019 - Project PDF - 80 Hours", "Currency": "USD", "Amount": 6400 }, { "Description": "Jun-2019 - Project PDF - 140 Hours", "Currency": "USD", "Amount": 11200 }, { "Description": "Jul-2019 - Project PDF - 95 Hours", "Currency": "USD", "Amount": 7600 }, { "Description": "Aug-2019 - Project PDF - 85 Hours", "Currency": "USD", "Amount": 6800 }, { "Description": "Sep-2019 - Project PDF - 75 Hours", "Currency": "USD", "Amount": 6000 }, { "Description": "Oct-2019 - Project PDF - 65 Hours", "Currency": "USD", "Amount": 5200 }, { "Description": "Nov-2019 - Project PDF - 100 Hours", "Currency": "USD", "Amount": 8000 }, { "Description": "Dec-2019 - Project PDF - 85 Hours", "Currency": "USD", "Amount": 6800 }, { "Description": "Jan-2020 - Project PDF - 45 Hours", "Currency": "USD", "Amount": 3600 }, { "Description": "Feb-2020 - Project PDF End - 90 Hours", "Currency": "USD", "Amount": 7200 } ] }
\documentclass[a4paper]{article} \usepackage[top=1.5cm, bottom=5cm, left=1.5cm, right=1.5cm]{geometry} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} % Font setup \usepackage[default,scale=0.95]{opensans} \usepackage{graphicx} \usepackage{ragged2e} \usepackage{float} \usepackage{array} \newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} \newcolumntype{P}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}\vspace{2pt}}m{#1}} \newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} \newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}} \newcolumntype{T}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}\vspace{2pt}}m{#1}} \newcolumntype{N}{@{}m{0pt}@{}} \newcolumntype{+}{!{\color{LightGrey}\vrule width 1pt}} \usepackage[none]{hyphenat} %%%%%%%%%%%%%%%%%%%%%% % content definition % %%%%%%%%%%%%%%%%%%%%%% \usepackage[table]{xcolor} \usepackage{longtable} \usepackage{array} \usepackage{multicol} \usepackage{xcolor} \begin{document} \setlength{\tabcolsep}{3pt} \begin{longtable}{L{0.6\linewidth} C{0.15\linewidth} R{0.15\linewidth} N} \hline \bfseries{Description}& \bfseries{Currency} & \bfseries{Amount}&\\[0.5cm] \hline \advGetTableData{invoiceDetails, rowWidth = 0.5cm, decimalplaces = 2, prefix = {,,R}, includeEmptyLastColumn = TRUE, thousandsseparator = space} \hline \end{longtable} \end{document}
AdvGetTableData-PDF-Screenshot