Demonstration: Web fonts in PDFs, with Mechanic.

Mechanic is a development and ecommerce automation 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 Occurs when a user manually 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, Shopifolks, 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.

(By the way, have you seen our documentation? Have you joined the Slack community?)

Open source
View on GitHub to contribute to this task
Subscriptions
mechanic/user/trigger
Tasks use subscriptions to sign up for specific kinds of events. Learn more
Options
destination email address (email, required)
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 %}
Task code is written in Mechanic Liquid, an extension of open-source Liquid enhanced for automation. Learn more