How to generate a PDF in pdfmonkey.io via Zapier

I want to premise that the method I am presenting here is currently the only one that I have tested and for which I am sure that it works.
It is likely that there are better methods than mine; I think that through webhook it is possible to do better than this but I have not yet had the opportunity to experience it.
In any case, if you want to know how to generate a PDF from your sheet which is the datasource of your Glide application, this tutorial will probably be useful for you.

So let’s get started …

STEP 1

First, in your APP, you need to be able to assemble a JSON data package formally in the data editor; view and copy the Doc2PDF sample APP to see how to do this.
So copy this APP and the sheet:

STEP 2

In the example APP create a document; this document could be an invoice or an order, or in short any document that is composed of a data header, a foot of data, and a body with a variable quantity of rows.

STEP 3

Just to do a test to see if the JSON data packet is composed correctly, press the {Copy JSON (just to test it)} button and then paste into an online parser; I for example use this: http://json.parser.online.fr/

STEP 4

Create your template in pdfmonkey.io; start from a blank template and use this sections for your experiment with Doc2PDF APP:
Pdfmonkey template sections - Google Docs
(This is a slightly adapted version of the existing “Invoice” Master Template)

If everything is ok, publish it.

Step 5

Create a new ZAP in Zapier:

Trigger New spreadsheet Row in Google Sheets

  • Setup the worksheet Doc2PDF

Generate Document in PDFMonkey

  • Set up action: in the Dynamic Data (JSON Payload) put the column “Dynamic Data” of your sheet

STEP 6

In the Doc2PDF APP push the button “Add a row for the trigger” and after some minutes you will have your PDF document generated in documents section of your pdfmonkey.io

STEP 7

What to do next?
This depends on how you want to use the generated PDF document, for example you could add a subsequent action in Zapier to send it via email to someone, or you could save the generated PDF in your google drive and then capture the link and write back in the original row of your google sheet.

15 Likes

Hi @Roldy Thank you for sharing - I learned alot!

I am working with this solution but using Glide’s Zapier action as the trigger (not a new google sheet row as trigger).
I have set up my template column and if i copy the results manually into the zap (data in for pdfmonkey action), it works perfectly.

The minute i assign my template column to Glide’s Value 1 and nominate that as the data package in my zap, my zap fails with error: “Unexpected token u in JSON at position 0”.

Do you have any suggestions.
Sincerely appreciated!

1 Like

I’m pretty sure there is a problem with the payload definition, I don’t remember how I solved it in the past.
I wrote to technical support, let’s see what they respond.
However it must work!
I ask you for a little patience, we will definitely solve it.

1 Like

Grande! :call_me_hand:t3:

Can I ask you if there is anyway to do the same without use the Monkey (they are better at the zoo :joy: ).
I currently print PDF using googlescript, but maybe this option it save me to do not execute the trigger, that sometime is causing headhacke!
Thx for sharing!
Ciao.

1 Like

I don’t think I ever had that problem, isn’t the first character “{”?

1 Like

Thanks. And yes, now I remember where the problem is.

1 Like

In Glide remove the leading and trailing braces in the column containing the json.
In Zapier add the curly brackets manually like this:
image

1 Like

Ciao @MIKAHEL
I may not have understood correctly. Are you looking for another service instead of pdfmonkey to generate PDF?
Are you creating PDF from apps script code? It’s a bit tiring in my opinion, I chose pdfmonkey because it made it easier for me to define the structure of the document trough html and css.
But there are other services if you want… or just write some code manually as you did with g.a.s.
What problems do you have in g.a.s. that cause you headaches?

actually the problem is only that sometime it stops for whatever mistake and since Ive other to watch out I prefer not to be in trouble with this.
But definitely is not a problem, its more a boring thing
Yes u are right, better to use monkey at the end.

1 Like

:clap:

1 Like

Thank you for this tutorial. Very helpful!

1 Like

Thanks a lot Mr Roldy, for this great contribution.

1 Like

Thank you so much for your comment, been struggling with this for an hour! Any idea why we need to do this? Looking at the Zap error report, the payload seems to have double {{val1…}} making it invalid JSON. Thanks

Do you mean external images? I can confirm that it’s only available on paid accounts.

It looks like thats what it was, I was getting this error message…

But it was the external image that was giving it trouble.

Yeah, so again, we confirm that the external image was the problem? Is it a dynamic or static image? I’m not sure if using it in data-uri format would make it work on a free account.

Yeah, external image was the issue. The one that was giving me the issue was a static image that was in his template, but I have dynamic images that I want to use.

I was able to use chatGPT to make a PDF template that works, I think I’m going to pay for the PDF Monkey plan for the month so I can make PDF’s for this short time period I need them.

1 Like