Demonstration: Web fonts in PDFs
This task illustrates how to use a typeface from Google Fonts, embedding it in a generated PDF which is then emailed to the recipient of your choice.
Try this taskWhen it runs
Occurs when a user manually triggers the task
What you choose
Destination email address
Task code and subscriptions
You can edit the Liquid code after installing this task. View on GitHub or ask a question in the Mechanic Slack community.
Subscriptions
mechanic/user/trigger
How task subscriptions work
Option types and flags
- Destination email address (email, required)
Task code
{% capture html %}
<link href="https://fonts.googleapis.com/css2?family=Liu+Jian+Mao+Cao&display=swap" rel="stylesheet">
<style>
p {
font-family: 'Liu Jian Mao Cao', cursive;
}
</style>
<p>Almost before we knew it, we had left the ground.</p>
{% endcapture %}
{% action "email" %}
{
"to": {{ options.destination_email_address__email_required | json }},
"subject": "PDF test",
"body": "Please see the attached PDF. :)",
"reply_to": {{ shop.customer_email | json }},
"from_display_name": {{ shop.name | json }},
"attachments": {
"font-demo.pdf": {
"pdf": {
"html": {{ html | json }}
}
}
}
}
{% endaction %}
Mechanic Liquid reference