Demonstration: Web fonts in PDFs, with Mechanic.

Mechanic is a development platform for Shopify. :)

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.

Runs when a user triggers the task. Configuration includes destination email address.

15-day free trial – unlimited tasks

Developer details

Mechanic is designed to benefit everybody: merchants, customers, developers, agencies, Gurus, everybody.

That’s why we make it easy to configure automation without code, why we make it easy to tweak the underlying code once tasks are installed, and why we publish it all here for everyone to learn from.

Open source
View on GitHub to contribute to this task
Events
when a user triggers the task (mechanic/user/trigger)
Options
destination email address (email, required)
Script
{% 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 tasks are written in Liquid, which makes them easy to write and easy to modify. Learn more about our platform.