OCR and route email PDF attachments with pdfRest verified n8n node

Process each PDF attachment, add OCR when page text is sparse, and file invoices, contracts, or review items in Drive.
Share this page

Gmail + pdfRest + n8n + Google Drive

Turn email attachments into organized documents

Process each PDF attachment, add OCR when page text is sparse, and file invoices, contracts, or review items in Drive.

Requires configured service credentials and a pdfRest plan that supports the operations. Evaluation plans may add watermarks or text redactions.

What is n8n?

n8n connects applications, files, and APIs in visual workflows. These templates use the verified pdfRest node for PDF processing, with small configuration and routing steps where needed.

From inbox to the right folder

  1. Receive

    Download PDF attachments from new matching Gmail messages and split them into individual files.

  2. Inspect

    Read text page by page. A sparse page triggers OCR using the configured language.

  3. Classify

    Apply editable invoice and contract keyword rules. Unmatched, conflicting, or sparse results go to review.

  4. Route

    Save the PDF to its configured Drive folder. Keep the original email untouched.

Import and connect your workflow

START HERE

Import the template

Create a workflow in your n8n instance. Open the editor’s three-dot menu, choose Import from File, and select the downloaded JSON. Configure the template before activating it.

Install the verified node by searching pdfRest in the nodes panel. Self-hosted instance owners can also install @pdfrest/n8n-nodes-pdfrest through Settings → Community Nodes.

01

Connect your accounts

Select Gmail credentials on the trigger, Google Drive credentials on the upload, and pdfRest credentials on Add searchable text.

02

Choose your folders

Replace all three folder IDs in Classify and choose folder. Keep these folders private to the intended team.

03

Set your routing rules

Refine the Gmail search, OCR languages, and classification rules using representative documents. The default language is English.

Test, review, then activate

Run a few representative documents through the workflow before switching on automatic processing.

Open the five-document test checklist
  • A text-based invoice with invoice and amount-due language routes to invoices without OCR when every page has enough text.
  • A scanned PDF invokes OCR, then routes using the extracted result.
  • A mixed PDF with a text page and a blank-text scanned page invokes OCR.
  • A document matching both categories, neither category, or still containing sparse text routes to review.
  • An email containing multiple PDFs and a JPG uploads one file per PDF and ignores the JPG.

Know what to review

When OCR needs a closer look

OCR detection is a page-text heuristic. It may process a blank page unnecessarily or miss image text beside existing text.

How classification works

Classification uses starter keyword rules, not Claude or another AI model. It is separate from the already-published Claude workflow.

Handling failed runs and duplicates

Locked or malformed PDFs stop the execution for inspection. Replays can upload duplicates; monitor failures and review before retrying.

Sources remain intact. Files travel through n8n, the selected pdfRest deployment, and any connected services shown above. Review your execution-data retention settings before production use.

Build your workflow

Download, connect your accounts, and test with a sample PDF.

Generate a self-service API Key now!
Create your FREE API Key to start processing PDFs in seconds, only possible with pdfRest.