Generate a simple product catalog PDF, with Mechanic.

Mechanic is a development platform for Shopify. :)

Generate a simple product catalog PDF

by Isaac Bowen (team@usemechanic.com)

This task is a simple demonstration of pulling product titles and images into a PDF, resulting in a simple catalog of the products available in your store. Use it as a starting point for building something more complex.

Runs when a user triggers the task.

15-day free trial – unlimited tasks

Documentation

This task is a simple demonstration of pulling product titles and images into a PDF, resulting in a simple catalog of the products available in your store. Use it as a starting point for building something more complex.

Run this task manually to generate the PDF.

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.

Events
when a user triggers the task (mechanic/user/trigger)
Script
{% capture html %}
  <h1>Product catalog</h1>
  <ul>
  {% for product in shop.products %}
    {% assign image = product | img_url: "300x300", crop: "center" %}
    <li>
      <b>{{ product.title }}</b>
      <br>
      {% if image %}
        <img src="{{ image }}"/>
      {% else %}
        (no image)
      {% endif %}
    </li>
  {% endfor %}
{% endcapture %}

{% action "files" %}
  {
    "catalog.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.