Automate File Conversions Using n8n.io

Jonas, CTO

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. Manual Trigger

Step 2: Download the DOCX File

Next, we will download a DOCX file using an HTTP request.

  1. Drag and drop the HTTP Request node onto the canvas and rename it to "Download File HTTP Request".
  2. Configure the node with the following settings:
    • URL: https://cdn.convertapi.com/public/files/demo.docx
    • Response Format: File

Download the DOCX File

Step 3: Convert the DOCX File to PDF

Now, we will convert the downloaded DOCX file to PDF using ConvertAPI.

  1. Drag and drop another HTTP Request node onto the canvas and rename it to "File conversion HTTP Request".
  2. 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
    • Response Format: File

You will need to set up the credentials in n8n using your ConvertAPI authentication secret.

Convert the DOCX File to PDF

Step 4: Save the Converted PDF to Disk

Finally, we will save the converted PDF file to disk.

  1. Drag and drop the Read/Write File node onto the canvas and rename it to "Write Result File to Disk".
  2. Configure the node with the following settings:
    • Operation: Write
    • File Name: document.pdf
    • Data Property Name: data

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:

Feel free to experiment and enhance this workflow to fit your specific needs.