Automating Invoice Image Collection, PDF Conversion, and Archiving in Google Drive with n8n + PDF.co

Sep 22, 2025·5 Minutes Read

What You'll Have When Done

By the end of this tutorial, you’ll have a fully automated workflow that:

  • Monitors your email inbox for new invoice image packages.
  • Downloads invoice image attachments automatically.
  • Uploads the images to PDF.co for secure processing.
  • Merges all images into a single clean PDF document.
  • Archives the final PDF in your chosen Google Drive folder.

This automation eliminates manual invoice handling, saves time, and ensures all invoices are centralized in Google Drive.

Prerequisites

Before you begin, make sure you have:

  • A PDF.co API Key (Get yours here: https://app.pdf.co/)
  • An email inbox with IMAP access (to trigger document collection)
  • A Google Drive account with OAuth2 credentials in n8n
  • A Google Drive folder for saving completed packages
  • An n8n instance (cloud or self-hosted)

Quick Start Options

Option A: I Want It Working Now

  1. Import this workflow template and sample files → Download Workflow File
  2. Connect your IMAP, Google Drive, and PDF.co accounts
  3. Define naming conventions and split rules
  4. Test with sample document collection
  5. Activate and run

Option B: I Want to Build It Step-by-Step Follow the 7-step guide below to create the automation from scratch.

What This Automation Does (Overview)

  1. Monitors your inbox for a new “Invoice Images” email
  2. Downloads image attachments (invoices)
  3. Normalizes and prepares files for processing
  4. Uploads invoice images to PDF.co
  5. Collects returned URLs for processing
  6. Merges all images into a single PDF
  7. Downloads the final PDF
  8. Uploads the completed package to Google Drive

Step 1: Trigger Document Collection Processing

Node: Email Trigger (IMAP)

Settings:

  • Mailbox Name: INBOX
  • Action: Mark as Read
  • Download Attachments: True
  • Custom Email Rules: ["UNSEEN", ["SUBJECT", "Invoice Package"]]

Success Looks Like: The workflow is triggered when a new or unread email with the subject “Invoice Package” arrives, and attachments are pulled into the workflow.

Step 2: Normalize Attachments into Workflow Items

Node: Code (JavaScript)

Settings: Use the provided JavaScript code to process each attachment and extract metadata (filename, type, etc.). This ensures invoices are properly structured for PDF.co. (Download sample JavaScript code here.)

Success Looks Like: Each document is transformed into a structured workflow item, ready for upload.

Step 3: Upload Documents to PDF.co

Node: PDF.co API → Upload File

Settings:

  • Binary File: True
  • Input Binary Field: file

Success Looks Like: All invoice image attachments are uploaded to PDF.co, returning secure file URLs for further processing.

Step 4: Collect Uploaded File URLs

Node: Code (JavaScript)

Settings: Use a collector function after upload to gather all returned URLs into a single files array JSON object that PDF.co’s Merge endpoint expects. (Download sample collector code here.)

Success Looks Like: All invoice image URLs are collected and formatted in the correct array structure for merging.

Step 5: Combine All Documents into One PDF

Node: PDF.co API → Merge PDF

Settings:

Input Links: Map the ordered URLs array

={{ $json.urls[0] }}

={{ $json.urls[1] }}

={{ $json.urls[2] }}

={{ $json.urls[3] }}

Success Looks Like: All uploaded invoice images are merged into a single clean PDF document.

Step 6: Download Final PDF

Node: HTTP Request

Settings:

  • Method: GET
  • URL: {{ $json.url }} (from PDF.co output)
  • Authentication: None

Success Looks Like: The merged PDF is downloaded as binary data, ready to be stored.

Step 7: Save Completed Package to Google Drive

Node: Google Drive → Upload

Settings:

  • Input Data Field Name: data
  • Parent Drive: My Drive
  • Parent Folder: OUTPUT1

Success Looks Like: The final PDF appears neatly in your designated Google Drive folder

Congratulations!

You’ve successfully built an end-to-end automation that:

  • Watches your inbox for invoice images
  • Processes and merges them into PDFs
  • Automatically archives the results in Google Drive

No more manual downloads, merges, or uploads.

Built something cool? Share it with us on Twitter @pdfdotco!

Related Tutorials

See Related Tutorials