Compress PDFs using PDF.co in n8n

May 15, 2025·5 Minutes Read

In this guide, you'll set up an automated workflow in n8n to compress PDF files when added to a specific folder in Google Drive. PDF.co will handle the compression.

Google Drive is used for demonstration, but you can use any trigger or file storage of your choice.

Full Workflow Overview

Here’s what the complete workflow looks like in n8n:

Full Workflow Overview

What each step does:

  • Google Drive Trigger – Detects when a new file is added to a folder
  • PDF.co Compress PDF – Compresses the uploaded PDF
  • HTTP Request – Downloads the compressed file in binary format
  • Google Drive Upload – Uploads the compressed file back to Drive

Install PDF.co Node (For Self-hosted Users)

If you're using self-hosted n8n, you can install the official PDF.co node from the Community Nodes registry for easier integration.

  1. Open your n8n editor
  2. Go to Settings → Community Nodes
  3. Search for: n8n-nodes-pdfco
  4. Click Install

For more information, visit the n8n-nodes-pdfco on npm

n8n Community Nodes

Step 1: Trigger on New File in Google Drive

  1. Add Node: Google Drive → Changes Involving a Specific Folder
  2. Set Up:
    • Watch For: File Created
    • Folder: Select the folder to watch for new files
  3. Important: Ensure file sharing is set to "Anyone with the link" so PDF.co can access it.
  4. Click Fetch Test Event to verify the trigger works.
Trigger on New File in Google Drive

Step 2: Compress File with PDF.co

  1. Add Node: PDF.co → Compress PDF
  2. Connect Account:
  3. Input:
    • Drag webContentLink from the Google Drive trigger into the URL field
  4. Test the step to confirm it returns a valid compressed PDF URL.
  5. (Optional) Click Add Option to customize:
    • Output file name

Compression config (see PDF.co API docs).

Compress File with PDF.co

Step 3: Convert URL to Binary (HTTP Request)

Google Drive requires a binary file, so we must download the compressed PDF first.

  1. Add Node: HTTP Request
  2. Settings:
    • Method: GET (default)
    • URL: Drag in the url output from PDF.co
    • Authentication: None (default)
  3. Test to confirm it returns a binary file.
Convert URL to Binary (HTTP Request)

Step 4: Upload to Google Drive

  1. Add Node: Google Drive → Upload File
  2. Set Up:
    • Input Data Field Name: Leave as data (default)
    • Parent Folder: Choose the folder to upload to
  3. Test Step and verify in Google Drive.
Upload to Google Drive

Step 5: Final Check: Verify File Sizes

Once the workflow runs, go to your Google Drive folder and check the file sizes. The compressed PDF should be significantly smaller than the original file.

Verify File Sizes

Troubleshooting Tips

  • PDF.co File Permission Issues → Make sure the file is publicly accessible and not restricted. For binary files, upload them to the cloud using the PDF.co Upload API.
  • Missing/Invalid API Key → Double-check your PDF.co API key in the credentials setup.
  • Not Enough Credits → Verify your PDF.co credits and ensure you’re using the correct account if you have multiple.
  • Input Document is Damaged or of Incorrect Type → First, check the PDF.co File Permission Issue above. If the issue persists, verify that the file is a PDF and not another file type.

Related Tutorials

See Related Tutorials