Templates
The plugin uses the Postmark template system for emails. For attachments the plugin relies on the pdfkit library.
In your JSON templates you can use several types (and variables):
image
for (local) imagestext
for simple words, (long) sentences, paragraphs and linksmoveDown
for moving the cursor down one linehr
for a horizontal linetableRow
for a table(-like) rowitemLoop
for looping over items in an orderitemLoopEnd
for ending the item loop
Example:
[
{
"type": "image",
"image": "image.png",
"x": 100,
"y": 100,
"fit": [200, 50]
},
{
"type": "text",
"text": "This is a text",
"size": 20
},
{
"type": "moveDown",
"lines": 2
},
{
"type": "hr"
},
{
"type": "moveDown",
"lines": 2
},
{
"type": "text",
"text": "Another text"
}
]
image
Images are stored in /src/images/
and can be used in the template like this:
{
"type": "image",
"image": "image.png",
"x": 100,
"y": 100,
"fit": [200, 50]
}
fit
has multiple options, see here for more info.
Optional:
align
horizontally align the image, the possible values areleft
,center
, orright
valign
vertically align the image, the possible values aretop
,center
, orbottom
text
Text can be used for words, sentences, paragraphs and links.
{
"type": "text",
"text": "This is a text"
}
If you use moveDown
correct you won't need to use x
and y
for the text.
Optional:
These options can be used to style the text or to position it.
x
the x position of the texty
the y position of the textfont
the font of the textsize
the font size of the textcolor
the color of the text (Hex codes#ff0000
)width
the width of the textalign
the alignment of the text, the possible values areleft
,center
,right
, orjustify
.
For more styling options, see here for more info.
moveDown
This is used to move the cursor down one or more line(s).
{
"type": "moveDown",
"lines": 1
}
hr
This is used to draw a horizontal line.
{
"type": "hr"
}
Optional:
color
the color of the line (Hex codes#ff0000
)width
the width of the line if you don't want it to be the full width of the pageheight
the height of the line element, including paddingy
the y position of the line if you can not rely on the cursor (affected bymoveDown
)
tableRow
This is used to draw a table row.
{
"type": "tableRow",
"columns": [
{
"text": "Column 1",
"width": 200
},
{
"text": "Column 2",
"width": 150
}
]
}
Optional:
You can use the same options as for text
to style the text in the table row. If you want a special column styled, you can add the options to the column object.
itemLoop
This is used to start the loop of items in an order.
To access item variables, use the item
object, for example {{ item.title }}
.
{
"type": "itemLoop"
}
itemLoopEnd
This is used to end the loop of items in an order.
{
"type": "itemLoopEnd"
}