# Output binary data from node

**URL:** <https://community.n8n.io/t/output-binary-data-from-node/44592>\
**Category:** Questions\
**Created:** [April 18, 2024, 2:43pm UTC](https://community.n8n.io/t/output-binary-data-from-node/44592 "2024-04-18T14:43:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![atwork1](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/atwork1/32/30810_2.png) [@atwork1](https://community.n8n.io/u/atwork1)\
**Post date:** [April 18, 2024, 2:43pm UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/1 "2024-04-18T14:43:24Z")

</div>

## Describe the problem/error/question

How do I output the response from this http request within a code node as binary data.

## Please share your workflow

## Share the output returned by the last node

## ![grafik](https://europe1.discourse-cdn.com/n8n/original/3X/2/1/2189de205feab350504b7ad9e9ecc1dacaf166e3.png)

 ![grafik](https://europe1.discourse-cdn.com/n8n/original/3X/5/f/5f179139d0db66a25c29c1bd2557a72011298a5b.png)

## Information on your n8n setup

- **n8n version:** latest
- **Database (default: SQLite):** default
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):** default
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** docker
- **Operating system:** Ubuntu

---

<div class="post-metadata">

**Author:** ![Shirobachi](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/shirobachi/32/37882_2.png) [@Shirobachi](https://community.n8n.io/u/Shirobachi)\
**Post date:** [April 18, 2024, 8:03pm UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/2 "2024-04-18T20:03:29Z")

</div>

Hey @atwork1,

There are few nodes what can make (image) or convert (Convert to File) binary files or you could use APIs like [renderform.io](http://renderform.io) or APITemplate  
if you need PDF, I think that’s no easy, but maybe you can make image and convert it somehow? Or use pdf template api, check [this](https://rapidapi.com/search/template%20pdf)  
Also maybe you could find [some community node](https://www.npmjs.com/search?q=keywords%3An8n-community-node-package%20pdf), but I don’t know any what address this problem  
If you need like JSON file to be binary I’ve made wf what download data from mongo as JSONL file (I need that for fine tuning)

check also those topics:

- [Create PDF](http://community.n8n.io/t/create-pdf/3512)
- [How can I generate a PDF file with n8n?](http://community.n8n.io/t/how-can-i-generate-a-pdf-file-with-n8n/7528)

---

<div class="post-metadata">

**Author:** ![atwork1](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/atwork1/32/30810_2.png) [@atwork1](https://community.n8n.io/u/atwork1)\
**Post date:** [April 19, 2024, 7:45am UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/3 "2024-04-19T07:45:18Z")

</div>

Thank you for your reply.  
I’ve tried to encode the response to base64 and construct the binary file like you did, but the file i get isn’t a valid pdf file.

 ![grafik](https://europe1.discourse-cdn.com/n8n/original/3X/9/c/9c1a8c1d05b27845fc9c4105a4a986d0f4715f0d.png)

I’ve created a workflow using the gotenberg demo api and a sample pdf file that is loaded from [https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf](https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf) with a http request, so you see the results I’m getting.

I don’t know why the http-request node is dispayed as unknown in the preview … maybe a new version.? (Edit: yes its ther version, changing the node version to 4.1 will fix the preview, here in the thread)

 ![grafik](https://europe1.discourse-cdn.com/n8n/original/3X/2/8/28fa207da823f60c4d076e6ac14e41b1f7afacce.png)

PS: I need to use a code node, because I’m merging a variable number of PDF documents and the HTTP request node can’t handle that.  
Edit: fixed some stuff

---

<div class="post-metadata">

**Author:** ![Shirobachi](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/shirobachi/32/37882_2.png) [@Shirobachi](https://community.n8n.io/u/Shirobachi)\
**Post date:** [April 20, 2024, 8:20pm UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/4 "2024-04-20T20:20:31Z")

</div>

Yes, that makes sense. I was creating a JSONL file—which isn’t technically text, but it’s relatively straightforward compared to PDFs.

Just a quick question: how many PDFs do you need per month, and can you send this data to a third-party API? If so, I’d recommend using something like APITemplate.

Alternatively, I’ve set up a workflow that converts HTML to PDFs using Gotenberg, a tool specifically for PDF operations. You’ll need to install it, but it’s straightforward using the following Docker command:

```bash
docker run --rm -p 3333:3000 gotenberg/gotenberg:8

```

(Note: I changed the port to `3333` because `3000` was already in use on my system.)

References:

- [Gotenberg docs](https://gotenberg.dev/docs/getting-started/introduction)
- [Gotenberg github](https://github.com/gotenberg/gotenberg)
- [Tutorial what I used](https://invidious.lunar.icu/watch?v=bo15xdjXf1Y)
- [Post where I found 👆 tutorial](http://community.n8n.io/t/convert-html-to-pdf/34815/3)

Hope this help;)  
Simon

---

<div class="post-metadata">

**Author:** ![atwork1](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/atwork1/32/30810_2.png) [@atwork1](https://community.n8n.io/u/atwork1)\
**Post date:** [April 22, 2024, 10:01am UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/5 "2024-04-22T10:01:10Z")

</div>

thanks,  
I have a similar one for generating a HTML file filled with images and printing it with gotenberg.  
Borderless, assuming all images have the same dimensions.

But it’s feels wrong and probaly breaks at the slightest variations of inputs…

Edit: posting the workflow it gives a 403 error for some reason. maybe because of the html  
Edit2: posting without the html node

 ![grafik](https://europe1.discourse-cdn.com/n8n/original/3X/e/7/e7ebbac2b2f9e01315bd8f8ef68f2acb45af5d8f.png)

---

<div class="post-metadata">

**Author:** ![Shirobachi](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/shirobachi/32/37882_2.png) [@Shirobachi](https://community.n8n.io/u/Shirobachi)\
**Post date:** [April 23, 2024, 2:57pm UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/6 "2024-04-23T14:57:58Z")

</div>

Hey,

So 403 means there is auth error, you use their instance or your local one? 🤔

---

<div class="post-metadata">

**Author:** ![atwork1](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/atwork1/32/30810_2.png) [@atwork1](https://community.n8n.io/u/atwork1)\
**Post date:** [April 23, 2024, 3:10pm UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/7 "2024-04-23T15:10:29Z")

</div>

here in the Forum^^

when I add the html node I can’t post the reply.

The html is probably messing with the POST and being interpreted as actual html ‘code’.

---

<div class="post-metadata">

**Author:** ![Shirobachi](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/shirobachi/32/37882_2.png) [@Shirobachi](https://community.n8n.io/u/Shirobachi)\
**Post date:** [April 23, 2024, 9:01pm UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/8 "2024-04-23T21:01:13Z")

</div>

Aaaaa sorry about that… I’m not sure why this is happening. Could you possibly share a link to a gist or something similar? Is everything working for you, or does your workflow still need some attention from us? 😅

@bartv can you assist with 403 issue?

---

<div class="post-metadata">

**Author:** ![atwork1](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/atwork1/32/30810_2.png) [@atwork1](https://community.n8n.io/u/atwork1)\
**Post date:** [April 26, 2024, 6:31am UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/9 "2024-04-26T06:31:09Z")

</div>

I’m still not able to get a valid pdf file.

how does the https node handle binary files? Can I use that “principle” in the code node?

---

<div class="post-metadata">

**Author:** ![atwork1](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/atwork1/32/30810_2.png) [@atwork1](https://community.n8n.io/u/atwork1)\
**Post date:** [May 6, 2024, 2:42pm UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/10 "2024-05-06T14:42:58Z")

</div>

> [@atwork1](#):
>
> fixed the issue, see below

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [May 13, 2024, 2:43pm UTC](https://community.n8n.io/t/output-binary-data-from-node/44592/11 "2024-05-13T14:43:38Z")

</div>

Closed on May 13, 2024, 2:43pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
