Best way to get OCR data in n8n

I need an OCR machine that can extract all text from a PDF file. We often receive files in PDF format that are essentially just images without text, which is why our own “PDF reader” in n8n doesn’t always work. I need it to do that.

It’s about receiving large annual reports with lots of columns in PDF format, and we need data from some of those columns.

For example, like in the image, where we need to use these columns as JSON.

I am pretty new, so explain in it to me, like I’m a child :sweat_smile:

Since it’s an image you need an OCR node as you said. n8n Does not have an official node but there is a community one: n8n-nodes-tesseractjs

After extracting the text from image you can use different methods to filter them. I always use a ‘Code’ node to do so but you can use an AI node too if you don’t mind spending extra tokens.

In my opinion Mistral AI’s OCR tool is the best out there right now. Ideally you would use their API in a HTTP Request node to do your ocr transformation. If the data is sensitive, you can get a special license from them to use a private on prem instance for better privacy

If you need an example then I can build a demo

If you just need to turn those image‑based PDFs into actual text/structured data (like JSON), try Mathpix: https://mathpix.com/pdf-conversion. It does OCR on scanned PDFs and can extract tables/columns cleanly, then you can grab the data as JSON for n8n. Way less painful than trying to hack it with a basic PDF reader.

我們可以使用 OpenAI/Ollama 的視覺模型來分析影像,這樣會提取所有內容。然後我們可以保留所需的資料。

對於年度報告 PDF 中的密集表格,視覺模型(GPT-4o 或 Gemini Flash)運作良好,但關鍵在於提示詞。使用類似以下內容的提示詞傳遞影像:"從此表格中提取所有資料,並返回一個 JSON 陣列,其中每一列都是一個物件,以欄位標題作為鍵。" - 這能可靠地取得結構化輸出,無需後續處理。對於多頁 PDF,首先使用「提取文件內容」節點或「程式碼」節點將檔案分割成個別頁面影像,然後將每一頁傳遞給視覺模型,最後在結尾合併結果。

Mistral OCR API 有一個免費層級(透過他們位於 console.mistral.ai 的 API 控制台)。如果你想要完全免費且可自行託管的選項,n8n-nodes-tesseractjs 社群節點對於影像型 PDF 運作良好 - 你可以將其與 Convert to File 節點配對來傳遞二進位檔案。如果你想要具有慷慨免費層級的雲端 API,Google Document AI 也是一個選項,但設定比起 Mistral 的單一 HTTP 呼叫方式要複雜得多。