
Integrate pdfRest with n8n Automation & Dropbox Storage
Low-code Automation with pdfRest and n8n
If you're already familiar with n8n.io, you know how powerful it can be for connecting services and building custom workflows with the simplicity of a low-code interface. This guide will show you how to leverage that power even further by integrating the pdfRest API Toolkit into your workflows to automate all your PDF and document-related tasks.
Using n8n with pdfRest streamlines repetitive tasks without manual intervention, saving time and reducing errors. Its visual workflow builder makes it easy to connect to the pdfRest service, even for users with minimal coding experience. Pull files from public cloud storage tools, such as Dropbox, using n8n's existing platform integrations, and easily process them with pdfRest.
To get started, take a minute to sign up for a free Starter account with pdfRest to generate a dedicated API Key, which will be required for sending calls to the service.
Tutorial: Getting Started with n8n, pdfRest, & Drobox Integration
Objective
In this post we'll cover how to:
- Retrieve a JPEG from a Dropbox URL
- Upload the image to the pdfRest API Toolkit service
- Convert the image to a .pdf document
- Upload the newly converted PDF file back into Dropbox
- Merge that PDF file with another
Step 1: Uploading the Image
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
.
The next step is to create an HTTP Request that uploads the file to pdfRest using the /upload endpoint.
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.
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.
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.
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:
Step 2: Converting the Image to PDF
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
.
Use the same Header Parameter for api-key
as in the Upload call above.
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).
The JSON output of this API call to /pdf will contain:
- The
inputId
of our previously uploaded image file - The
outputId
of the newly converted PDF file - The
outputUrl
to download the converted PDF file
Step 3: Downloading the PDF
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.
Step 4: Merging PDFs with n8n
Next we will use the /merged-pdf
endpoint to merge the converted PDF with another PDF.
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.
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
.
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.
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:
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:
{
"id": [
"132143265-bbac-445d-80f0-43629d94a97e",
"21abec90f-7c2e-4447-8711-85f470362940"
],
"type": [
"id",
"id"
],
"pages": [
1,
1
]
}
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.
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 how we can help!
Conclusion
By following this guide, you've successfully created a powerful automated workflow that handles file retrieval, conversion, and merging using n8n and pdfRest. This is just a glimpse of the many possibilities. The pdfRest API Toolkit includes dozens of other endpoints for document signing, conversion, securing, and more - all of which can be integrated into your existing n8n workflows.
Now that you've mastered the basics, what will you build next? Get started by signing up for a free pdfRest Starter account and explore the full range of what's possible with the pdfRest API.