Creating a pdf from a dynamic url, combine them and email them out

We have a field in our CRM called “lead image URL” that directs to a jpg of a lead card image. I want to grab that url, turn that jpg into a pdf, and then email it out to the appropriate agent.

I have a python script that can handle the email, and I can webhook into our CRM to pull the data. My issue is in the middle to create the pdf. I’ve tried apitemplate.io and craftmypdf.com but I can’t seem to get the nodes to work. I get an “invalid JSON” response when using the craftmypdf.com node. I want to just pull the lead image url to create the pdf and then either download it to my computer, or upload it to some sort of lead management/image management system where we can then download them to email out.

The url is dynaimc since it’s different for each unique lead. Is there something I need to do in the parameters of the node?

Thank you!

Hey @Jlindsey hope all is well.

Could you share your workflow or a minimal example, for the issue you are describing?

Specify which node produces the error and what is the input of this node.

https://orcalifebi.app.n8n.cloud/workflow/OboVbs1J6scrPQ5P

I pasted the code of the workflow, I hope that worked.

I’m not sure if craftmypdf.com node wants to link to a template, but I don’t want to use a template, I just want to turn the jpg from the URL into a pdf. If there’s a different way to do that I’m all for it.

The “Craftmypdf.com” node produces the error, the input is from the JSON of the webhook, and I have the “image url” as the input, like in the photo above.

The link you pasted requires authentication.
Please share the workflow itself, not a link or screenshot.

See this to learn how to share the workflow.

Could you also paste the example of the data from the webhook?

[
{
“headers”: {
“host”: “orcalifebi.app.n8n.cloud”,
“user-agent”: “axios/1.7.7”,
“accept”: “application/json, text/plain, /”,
“accept-encoding”: “gzip, br”,
“cdn-loop”: “cloudflare; loops=1; subreqs=1”,
“cf-connecting-ip”: “34.30.80.213”,
“cf-ew-via”: “15”,
“cf-ipcountry”: “US”,
“cf-ray”: “971407b562cdb322-MAN”,
“cf-visitor”: “{“scheme”:“https”}”,
“cf-worker”: “n8n.cloud”,
“id”: “wdFAdNaT0Bxk49SH0C38”,
“x-forwarded-for”: “34.30.80.213, 172.68.205.162”,
“x-forwarded-host”: “orcalifebi.app.n8n.cloud”,
“x-forwarded-port”: “443”,
“x-forwarded-proto”: “https”,
“x-forwarded-server”: “traefik-prod-users-gwc-19-6d7b847dcf-zj8vz”,
“x-is-trusted”: “yes”,
“x-real-ip”: “34.30.80.213”
},
“params”: {},
“query”: {
“Name”: “VICKI GILHAM”,
“Address”: “170 CAMBRIDGE SQ APT C, COLUMBUS IN 47201”,
“Phone”: “(812) 374-2569”,
“Age”: “76”,
“DoB”: “Jan 19th 2000”,
“Spouse”: “null”,
“SpouseAge”: “”,
“ImageURL”: “https://leadimport.blob.core.windows.net/importcontainer-images/ORCA128094173.jpg”,
“Agent”: “Jacob Lindsey”
},
“body”: {},
“webhookUrl”: “https://orcalifebi.app.n8n.cloud/webhook-test/599c12cc-a84f-4d70-8a7b-a3845d04a347”,
“executionMode”: “test”
}
]

Ok, I see that in the Create a PDF node you have data set to the URL.

This field is expecting a JSON object, not a URL.

Here is an example of what could go into this field:

{
   "invoice_number": "INV38379",
   "date": "2021-09-30",
   "currency": "USD",
   "total_amount": 82542.56
}

based on the API ref:

Ok, so should I be using a different node to pull that URL and then create a PDF from it?

There are many services for that. This one looks pretty easy:

https://www.nutrient.io/api/url-to-pdf-api/

A quick test showed all you would need is

and the output will be a binary of a PDF that you can do whatever you need to.

I got the pdf creation to work, and the nutrient.io worked to create a pdf, but now I’m having trouble using the binary data. For example, I want to upload a file into google drive, but there’s no binary data to choose from for the source.

This is not exactly nutrient, but rather PDF.co, which is fine, whatever works for you. What kind of trouble are you having with uploading a file into google drive? Please show the output of your last node before the Google Drive node.

Oh sorry, here is the output of the pdf co node:

And the error of the Google Drive Node:

In this case your pdf.co node returns the link to the file, not a binary, You need to download the file first with HTTP Request node, before uploading it to google drive.

In the node use {{ $json.url }} in the URL field.

Something like this:

Ok, I added the HTTP request, and got this error when I went to upload:

Did you inspect the example I posted in my last post? The field values are wrong.
Input Data Field Name is not a file name, but a name of the binary property.

Are you running the full workflow or the previous node is pinned?

Yes, I put in "{{$binary.data.filename}} like you showed in your example.

It appears now I’m having an issue with Oauth between Google and n8n, so I need to figure that out. It worked earlier and now it’s not.

Clearly, it’s because your Input Data Field Name field is not sync with the ‘orange text’ from the Binary output. You must make the `Input Data Field Name` field sync with the ‘orange text’ from the Binary.

In your case, you must type data inside Input Data Field Name field, instead of using expression

no in my example the

  • input data field name is data (it should be) and the
  • filename is {{ $binary.data.fileName }}

in your example

  • input data field name is {{ $binary.data.fileName }} and the
  • filename is {{ $json.name }}

I sincerely don’t see how they are the same :slight_smile:

you have probably hit the 7 day re-auth for the app in testing mode, just try to go to credentials and re-authenticate.

Oh my gosh, I did have it incorrect. I’m sorry. I misread the field names.
I fixed the fields, but an unable to authenticate.

Even though the email I’m using to sign in is the same as the cloud service I used. I also created the auth today so it hasn’t been 7 days