Document generation options in Zapier
Last updated
Last updated
This article is dedicated to advanced features or our Zapier integration. If you wish to learn how to generate your first Document using Zapier, we have a dedicated guide you can read:
Be careful!
With great power comes… great trouble sometimes. Only switch to advanced JSON if you know what you’re doing and know how to escape your data properly.
See Fixing frequent Zapier errors for more information.
By default, our integration provides a very simple mapping field to define what will be sent to PDFMonkey.
In most cases the simple mapping will be good enough. But there might be cases where you want to structure your data in a different way. That's where the Use a custom JSON structure option can be useful.
It will switch from the simple mapping to a text area where you can insert your own JSON and use nested properties:
You can specify a custom name for the generated PDF. This might be useful if you plan on storing this file in a private space like Drive or Dropbox.
You can use dynamic parts to build this filename but be careful of a few things:
The filename should not contain any slash /
or backslash \
Non-latin characters should be avoided as they can be messed-up when saving the file
We usually recommend to use short name based on dates or IDs.
When you generate a Document, you can attach meta-data to it. Meta-data are not available in the Template and cannot be used ton influence the content of the Document. They’re simply attached to it.
A common use-case is receiving the Document via a webhook and using one of its meta-data to handle it differently.
If you're editing an invoice or a quote, you will likely need to deal with line items. Zapier offers a great way to access those items if the trigger you use supports them.
Let's take the example of a Stripe invoice. Items in the invoice will be available through a Line Items collection.
To send those items in a way that can be understood by PDFMonkey, you need to set Add Line Items to Yes.
It will open a new section where you can specify what a single item should look like.
For the sake of this article, we created a Stripe invoice with the following items:
While the TOTAL
itself should be sent as basic data for the Document, the name, unit price, quantity and total amount for each item should be sent as line items from Zapier:
Mapping or JSON
Note that the field to define the data for a line item will use the same form as the main data. If you use advanced JSON for the main data, the line item payload will also be defined using advanced JSON.
When Zapier sends the line items to PDFMonkey, they will be accessible through a special lineItems
variable. In our case, the payload would look like this:
Only strings attached
If you pay close attention to the payload above, only string are sent in the payload. Zapier doesn’t make any difference between text and numbers.
Luckily enough, Liquid (the template we use) is smart enough to convert those values to numbers when you do math with them. But just keep this fact in mind if you run into trouble with numbers.
You can loop over the lineItems
array to display content for each item individually:
This would result in the following HTML:
Usually you will probably want to build a table row for each item but this should give you a good idea of how to achieve that.