In this tutorial, we'll demonstrate how to automate file conversion using n8n.io and ConvertAPI. We'll walk through an example workflow that downloads a file, converts it from DOCX to PDF, and then saves the converted file to disk.
Prerequisites
Before we begin, ensure you have the following:
Step-by-Step Workflow
Workflow can be imported from the public template.
1. Manual Trigger
First, we'll add a manual trigger node to start our workflow. This node will allow us to test the workflow manually.
Step 2: Download the DOCX File
Next, we will download a DOCX file using an HTTP request.
- Drag and drop the HTTP Request node onto the canvas and rename it to "Download File HTTP Request".
- Configure the node with the following settings:
- URL:
https://cdn.convertapi.com/public/files/demo.docx
- Response Format: File
- URL:
Step 3: Convert the DOCX File to PDF
Now, we will convert the downloaded DOCX file to PDF using ConvertAPI.
- Drag and drop another HTTP Request node onto the canvas and rename it to "File conversion HTTP Request".
- Configure the node with the following settings:
- Method: POST
- URL:
https://v2.convertapi.com/convert/docx/to/pdf
- Authentication:
Generic Credential Type
- Generic Auth Type:
HTTP Query Auth
- Headers:
Accept: application/octet-stream
- Body Parameters:
- Type:
multipart-form-data
- Name:
file
- Input Data Field Name:
data
- Type:
- Response Format:
File
You will need to set up the credentials in n8n using your ConvertAPI authentication secret
.
Step 4: Save the Converted PDF to Disk
Finally, we will save the converted PDF file to disk.
- Drag and drop the Read/Write File node onto the canvas and rename it to "Write Result File to Disk".
- Configure the node with the following settings:
- Operation:
Write
- File Name:
document.pdf
- Data Property Name:
data
- Operation:
Conclusion
With this n8n workflow, you can automate the process of converting DOCX files to PDF using ConvertAPI. This setup can be extended to handle different file formats and more complex automation tasks. More workflow templates can be found here:
- Convert DOCX to PDF using ConvertAPI
- Convert DOCX (from URL) to PDF using ConvertAPI
- Merge PDF files using ConvertAPI
Feel free to experiment and enhance this workflow to fit your specific needs.