Skip to content

Commit b9a138d

Browse files
Merge pull request #111 from datalogics-tsmith/n8n-sample
PDFCLOUD-5195 Add n8n sample
2 parents 5d9f8a8 + 0f41ce1 commit b9a138d

2 files changed

Lines changed: 119 additions & 0 deletions

File tree

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
![pdfrest-n8n-header-image](https://pdfrest.com/.netlify/images?fm=webp&url=https:%2F%2Fcms.pdfrest.com%2Fcontent%2Fimages%2F2025%2F09%2FSolution-Integrate-pdfRest-with-n8n-Automation.png)
2+
3+
## Tutorial: Getting Started with n8n, pdfRest, & Drobox Integration
4+
5+
### Objective
6+
7+
In this post we'll cover how to:
8+
9+
1. Retrieve a JPEG from a Dropbox URL
10+
2. Upload the image to the pdfRest API Toolkit service
11+
3. Convert the image to a .pdf document
12+
4. Upload the newly converted PDF file back into Dropbox
13+
6. Merge that PDF file with another
14+
15+
---
16+
### Step 1: Uploading the Image
17+
18+
Files intended for the pdfRest API service will first need to be retrieved from somewhere. The file storage service **Dropbox**, used in this tutorial, is one of many options available within n8n. In the example below we download the file `image.jpeg` and stored that in the n8n workflow as `dropbox_jpeg`.
19+
20+
![pdfrest-n8n-solution-1.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-1.png)
21+
22+
The next step is to create an **HTTP Request** that uploads the file to pdfRest using the **/upload** endpoint.
23+
24+
![pdfrest-n8n-solution-2.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-2.png)
25+
26+
For the **HTTP Request**, set up a **POST** to `https://api.pdfrest.com/upload`. Leave **Authentication** set to `None`. Authorization will be done in the Header further down this guide.
27+
28+
![pdfrest-n8n-solution-3.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-3.png)
29+
30+
Create one **Header Parameter** for `api-key` and set your API Key in the value. Your API Key can be found, when logged in, at the very bottom of the [Account page](https://pdfrest.com/account).
31+
32+
![pdfrest-n8n-solution-4.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-4.png)
33+
34+
Lastly create a **Form-Data body type**. The only **Parameter Type** that we need here is a **n8n Binary File** referencing `dropbox_jpeg` from first step.
35+
36+
![pdfrest-n8n-solution-5.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-5.png)
37+
38+
When run, the steps above will output a JSON formatted response from pdfRest with the `name` and `id` of the uploaded file(s), to be used later inside by n8n. This is an example of the output:
39+
40+
![pdfrest-n8n-solution-6.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-6.png)
41+
42+
---
43+
### Step 2: Converting the Image to PDF
44+
45+
Create another **HTTP Request** step, this time to convert the image to a PDF. This will be a **POST** to `https://api.pdfrest.com/pdf`.
46+
47+
![pdfrest-n8n-solution-7.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-7.png)
48+
49+
Use the same Header Parameter for `api-key` as in the Upload call above.
50+
51+
This time we will have a **JSON Body Content Type**. Create a **Body Paramter** for `id`. The value of `id` will come from the JSON response of Upload call above. Note that you can click and drag on the `id` field in the **Schema** tab drop the correct variable directly into the `Value` tab (`{{ $json.files[0].id }}` in the image below).
52+
53+
![pdfrest-n8n-solution-8.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-8.png)
54+
55+
The JSON output of this API call to /pdf will contain:
56+
- The `inputId` of our previously uploaded image file
57+
- The `outputId` of the newly converted PDF file
58+
- The `outputUrl` to download the converted PDF file
59+
60+
![pdfrest-n8n-solution-9.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-9.png)
61+
62+
---
63+
### Step 3: Downloading the PDF
64+
65+
In order to retrieve the newly converted PDF you will create a GET **HTTP Request** using the value of the `outputUrl`. No body or header needed for this step. This will produce a binary file data object (in this case, a technical way of saying a .pdf file) to be sent wherever you wish. In this example, we are downloading the results back into Dropbox.
66+
67+
![pdfrest-n8n-solution-10.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-10.png)
68+
![pdfrest-n8n-solution-11.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-11.png)
69+
70+
---
71+
### Step 4: Merging PDFs with n8n
72+
73+
Next we will use the `/merged-pdf` endpoint to merge the converted PDF with another PDF.
74+
75+
The first step is to download the new PDF from Dropbox just like we did before with the JPEG. Again, the files in your workflow can come from anywhere, we are using Dropbox in this example.
76+
77+
![pdfrest-n8n-solution-12.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-12.png)
78+
79+
Make another **HTTP Request** to `https://api.pdfrest.com/upload` with the same `api-key` Header Parameter as before and the only difference being that we are uploading the PDF from Dropbox this time. The new **Input Data Field Name** will be `dropbox_pdf`.
80+
81+
![pdfrest-n8n-solution-13.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-13.png)
82+
83+
To merge the files we will make an **HTTP Request** to `https://api.pdfrest.com/merged-pdf`. This will use the POST **Method** with the `api-key` Header set as before.
84+
85+
![pdfrest-n8n-solution-14.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-14.png)
86+
87+
For the **Body Parameters**, set the **Content Type** to `JSON` and set **Specify Body** to `Using JSON`. In this merge example, we will be sending two PDF files using their `id` values, merging page 1 of each file into a new 2-page document. The `id` values are pulled from the `outputId` from the Convert to PDF from JPEG step, and the `id` of the Upload PDF to pdfRest step. Again, you can drag and drop the values, indicated by the red arrows in the image below:
88+
89+
![pdfrest-n8n-solution-15.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-15.png)
90+
91+
Since the `id` values are being pulled from existing steps, they will be dynamically generated every time the workflow runs. This is an example of our JSON:
92+
93+
94+
```
95+
{
96+
"id": [
97+
"132143265-bbac-445d-80f0-43629d94a97e",
98+
"21abec90f-7c2e-4447-8711-85f470362940"
99+
],
100+
"type": [
101+
"id",
102+
"id"
103+
],
104+
"pages": [
105+
1,
106+
1
107+
]
108+
}
109+
```
110+
111+
Just as when we called `/pdf` above, this **HTTP Request** will result in a JSON object with `inputId`s, an `outputId`, and an `outputUrl` that can be used to download the final, merged document.
112+
113+
![pdfrest-n8n-solution-16.png](https://cms.pdfrest.com/content/images/2025/09/pdfrest-n8n-solution-16.png)
114+
115+
116+
If you have any trouble getting this set up or would like more information about how pdfRest can solve your PDF processing challenges, please [let us know](https://pdfrest.com/support/) how we can help!
117+
118+
---

n8n/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
In this directory you will find sample code and instructions illustrating advanced integrations with [n8n](https://n8n.io/).

0 commit comments

Comments
 (0)