From an api I get an JSON with an pdf. The pdf is a base64 encoded string.
I want to respond to the webhook by sending the pdf to the user.
Problem:
I don’t know how to convert it to a binary.
What is the error message (if any)?
Things I tried:
Encoding the base64 string and return a text response with appropiate headers
This gives me an empty pdf (but at least a pdf), but the pdf string form the API works. If I use an online converter to convert base64 to pdf, the pdf is shown correctly.
I tried the Move Binary Data node:
But this node give me an empty output:
In my case the output comes straight from gotenberg
This gives me error The value in "data" is not set
If I remove “Convert to PDF 2”: The browser have a page full of binary characters like the there is no Content-Type. Please help …
@barn4k exactly I don’t need Convert to PDF I just need to pipe back the response from gotemberg that already have the right Content-Type. However this doesn’t work it returns back a page full of binary:
I can’t test it as the site is not accessible for me.
I’ve also noticed one issue with the Convert to HTML node. You should enable the switch Data is base64. Otherwise you will save the base64 string as is in the file instead of saving the html content
I’ve changed Convert to HTML but makes no difference (the pdf is created correctly either way)
Gotemberg offers a demo api (https://demo.gotenberg.dev)
I’ve changed the url you can test yourself! unfortunately I can’t embed the code here it I got a 403 error if I try
Dear @barn4k, please, please, try the workflow you have posted and you’ll see the problems yourself! :
If I use the Convert to html, as you suggest, the pdf comes mixed with the right rendered content and the html source in the body. The same happen if it goes to webhook response see here, so is not a pdf related issue is the Convert node that has a bug
Using the Base64toFile is the only trick to correct create html for guteneberg and create a good pdf but I can’t send the pdf back with “respond to webhook” because it comes as page full of binary characters, but If I click view, or put a node to save to disk, the pdf is correct. gist here
My n8n version is 1.32.2
P.S: every time I embed the code on the bottom I see draft offline and cant post anymore with a 403 error, and say the post is edited in another window (I don’t) what is the trick???
screenshot of Convert to html with the source in the body
Thanks barn,
this solve the issue of bad formatting in the html, and correctly returns the html to the webhook response, but if you attach webhook response to the output of the PDF request I still get a page full of binary, so sending back a pdf from a form is still not working.
Btw then I wonder what “Convert to HTML” is used for?
That one converts the JSON object to an HTML document. But as we have the Generate HTML node, that already converts our JSON object to HTML, we need only to save the response in the text file without any modifications.
If I use a webhook as a trigger, like in your example, and use an external form to POST and works! surprise …
So the bug shows up only with the integrated n8n Form Trigger, can you confirm?