Skip to main content
Lifetime license included with every purchase
n8n workflowsPDF processingdocument automationdata extraction

n8n PDF Processing: Extract, Structure, and Route Documents

Build n8n PDF processing that extracts text, structures it, and routes it anywhere. The Extract from File node, OCR for scans, plus confidence checks.

Nn8n Marketplace Team·October 30, 2026·Updated October 30, 2026·8 min read

A PDF lands in an inbox or a Drive folder. Someone opens it, reads the fields, types them into a sheet, files the PDF, and moves on. Do that a few hundred times a month and it's a part-time job. n8n PDF processing removes it: the document gets read, its fields extracted and structured, and the result routed to wherever it belongs, with the original archived.

The pages ranking for this query have a pattern worth noting. The most-cited tutorial recommends shelling out to pdftotext through an Execute Command node and never mentions the built-in PDF node at all. Another tops out at 1,200 words with no confidence check and no batching. None of them show the parse step that turns extracted text into clean fields, which is the exact step that breaks when builders skip it.

Extracting text is easy. Structuring it reliably, and knowing when the extraction is garbage, is the hard part.

What you can automate with PDF processing

n8n reads PDFs with the Extract from File node (which replaced the Read PDF node from version 1.21.0) and structures the output with an AI step. That covers most document jobs:

  • Pull fields out of inbound invoices, contracts, or reports and log them to a sheet
  • Extract a document's text and push a summary to Slack or Notion
  • Read a batch of PDFs from a Drive folder and turn each into a structured row
  • Route documents by type after reading their content
  • Flag low-confidence extractions to a human review queue
  • Archive the original PDF once its data has been captured

The common thread is extract, structure, route. Get those three right and the document type barely matters.

The PDF processing pipeline

Trigger (Gmail / Drive / Webhook upload)
   → Extract from File (PDF → text)
   → Structure (OpenAI → JSON fields)
   → Parse (Code node)
   → Confidence check (IF)
       high → route to destination
       low  → review queue
   → Archive original

The confidence check is what separates a toy from a tool. Extraction quality varies wildly across documents. Without a gate, a misread field flows straight into your system and you trust it until it bites you. With one, the doubtful cases get human eyes and the clean ones flow through untouched.

1. Get the PDF into the workflow

A Gmail trigger catches emailed documents. The Google Drive node pulls them from a watched folder. A Webhook node (n8n-nodes-base.webhook) handles direct uploads. Whatever the source, the PDF arrives as binary data on the item, and that's what the next node reads.

2. Extract the text

Add the Extract from File node and set it to extract from PDF. It reads the binary and returns the document's text at {{$json.text}}. This is the node the most-cited competitor tutorial skips in favor of pdftotext through Execute Command. The built-in node needs no shell access, no system binary, and works the same on n8n Cloud where you can't run arbitrary commands. Use it.

One caveat that trips people up: this reads the text layer. A scanned document that's really just a photo of a page has no text layer, and the node returns empty.

3. Structure the text into fields

Raw text isn't useful; structured fields are. Send the extracted text to the @n8n/n8n-nodes-langchain.openAi v2.1 node with a prompt that asks for the specific fields you need as JSON. The model returns its output at $json.output[0].content[0].text.

For image-only scans, this same step does double duty: an OCR-capable model like GPT-4o-mini Vision reads the page image directly and returns structured fields, covering the case the built-in node can't.

4. Parse before you route

Here's the step tutorials skip and the one that fails silently. The AI returns text. The next node expects an object. Drop a Code node (n8n-nodes-base.code v2, jsCode) that runs JSON.parse on the model output every single time, even when it feels redundant. The execution log makes a missing parse step obvious after the fact; the workflow itself runs green right up until a downstream node reads undefined.

5. Gate on confidence, then route

Have the AI return a confidence score alongside the fields. An IF node (n8n-nodes-base.if v2) sends high-confidence extractions to their destination (a sheet, a database, a CRM) and low-confidence ones to a review tab. The data validation workflow covers the validation rules you layer on top of the confidence gate.

Implementation patterns

Pattern 1 — Inbox PDF to structured row

Gmail trigger (has attachment)
   → Extract from File (PDF → text)
   → OpenAI (extract fields as JSON + confidence)
   → Code (JSON.parse)
   → IF (confidence > 0.8)
       high → Google Sheets append
       low  → Errors tab

The confidence branch is the difference between a sheet you trust and one you re-check by hand. Set the threshold where your documents actually sit, then watch the Errors tab to tune it.

Pattern 2 — Drive folder batch

Schedule Trigger
   → Google Drive (list new PDFs)
   → SplitInBatches (size 10)
   → Extract from File → OpenAI → Code parse
   → Database write
   → next batch

Batching is non-negotiable at volume. PDFs are heavy binary data, and one DEV Community walkthrough processing 30,000+ documents leans entirely on batching to avoid blowing memory. Load ten, extract, write, release, repeat.

Pattern 3 — Route by document type

Extract from File (text)
   → OpenAI (classify: invoice / contract / report)
   → Code (parse)
   → Switch:
       invoice  → finance sheet
       contract → legal Drive folder + Slack alert
       report   → summary to Notion

Reading the content first, then routing on it, beats routing on filename or sender. Filenames lie; content doesn't. The Switch node fans the structured result out to the right destination per type.

n8n nodes you'll use most

NodePurpose
Extract from FileRead text from PDF binary data (replaced Read PDF in v1.21.0)
@n8n/n8n-nodes-langchain.openAi v2.1Structure text into JSON fields; OCR scans via Vision
n8n-nodes-base.code v2Parse the AI JSON output before any node consumes it
n8n-nodes-base.if v2Gate on confidence so weak extractions go to review
n8n-nodes-base.googleDriveSource PDFs from a folder and archive originals
n8n-nodes-base.googleSheetsWrite structured rows and hold the review queue
Scanned vs text PDFs

This trips up almost everyone the first time. The Extract from File node reads the PDF's text layer. A document scanned or photographed to PDF often has no text layer, just an image of the page, and the node returns empty with no error. If extraction comes back blank on a file that clearly has words, that's why. Route those through an OCR-capable Vision model instead of the built-in node.

Getting started

  1. Confirm your n8n is on 1.21.0 or later so the Extract from File node is available.
  2. Pick a trigger that matches how PDFs arrive: Gmail, Drive, or a webhook upload.
  3. Add Extract from File and verify {{$json.text}} actually returns text for your documents.
  4. Add an OpenAI node that returns the fields you need as JSON, plus a confidence score.
  5. Add a Code node that runs JSON.parse on the output. Always.
  6. Gate with an IF node and route high vs low confidence separately.
  7. Batch with SplitInBatches before you point it at a large folder.

For a document pipeline that's already wired end-to-end, the ReceiptLedger shows the extract-structure-route pattern running in production.

Browse the document templates →
Skip the build

The ReceiptLedger ships the exact extract-structure-route pipeline this post describes, wired and confidence-gated — it monitors Gmail for attachments, sends each document to GPT-4o-mini Vision for structured field extraction, and a confidence check routes high-quality results to your destination sheet while uncertain ones land in a separate Errors tab for review. It's the working reference for any PDF or document workflow, and it's part of The Complete n8n Templates Bundle, a one-time lifetime license to the whole catalog plus future templates if you run more than one document automation.

Get the ReceiptLedger template →

PDF processing earns its keep when it knows the difference between a clean read and a garbage one. Use the built-in Extract from File node, parse the AI output every time, and gate on confidence before anything reaches your real data. For adjacent flows, the Google Sheets ETL workflow shows where structured rows go next, and the data validation workflow covers the rules that catch a bad extraction before it spreads. When you'd rather start from a working pipeline, the Data Entry Automation Hub applies the same validate-and-route discipline to form intake.

See all data processing templates →
FAQ

Common questions

How do I extract text from a PDF in n8n?
Use the Extract from File node, which replaced the older Read PDF node in n8n 1.21.0. Point it at the binary PDF data from a previous node (Gmail, Google Drive, HTTP), set the operation to extract from PDF, and it returns the document text at $json.text for downstream parsing.
Can n8n read scanned PDFs that are just images?
The built-in Extract from File node reads text-layer PDFs, not image-only scans. For scanned documents you need OCR: send the PDF to an OCR-capable model like GPT-4o-mini Vision, or an external OCR step, then feed the recognized text back into the workflow.
How do I turn extracted PDF text into structured fields?
Pass the extracted text to an OpenAI node with a prompt that asks for specific fields as JSON, then parse the response with a Code node before any node that expects structured data. Add a confidence check so low-quality extractions route to a review queue instead of polluting your main output.
How do I process many PDFs in n8n without running out of memory?
Process them in batches with a SplitInBatches node rather than loading every document at once. PDFs are binary and large, so a workflow that fans out 30,000 documents in a single pass can exhaust memory. Batch, extract, write, then move to the next batch.
Stop reading. Start running.

Get the workflow templates this guide is built on

Import-ready n8n JSON, step-by-step setup, and tested end-to-end. One-time payment, own it forever.

Free — $40 value

Get 3 tested n8n templates, free

The full customer package for three real catalog templates — workflow JSON, step-by-step setup guide, credential checklist. Built through the same live-instance release process as everything we sell. Plus new templates and automation guides in your inbox. No spam, unsubscribe anytime.

  • 01Smart To-Do List ManagerPre-built n8n workflow template that automates productivity with OpenAI. Live in about 10 minutes.$14
  • 02Email Follow-Up AutomatorPre-built n8n workflow template that automates crm with OpenAI. Live in about 15 minutes.$12
  • 03Market Trend AnalyzerPre-built n8n workflow template that automates data processing with OpenAI. Live in about 10 minutes.$14