Most PDFs you get are a mix: some pages contain real text, others are scans. Running OCR on every page is slow and costs more than it needs to.
Here's one request that handles both. Pages that already contain text are read directly; only scanned pages and images go through OCR.
curl -X POST \
"https://api.apify.com/v2/acts/mvisiondigital~pdf-image-ocr/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"fileUrls": ["https://example.com/contract.pdf"]}'
You get one row per page:
{"page": 2, "method": "ocr", "text": "This Agreement is made on ...", "confidence": 0.96, "fileTextUrl": "https://..."}
method tells you whether the page was read directly (text-layer) or OCR'd. fileTextUrl links to the whole document as one text file, which is handy for feeding a RAG pipeline.
In Python:
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("mvisiondigital/pdf-image-ocr").call(run_input={"fileUrls": ["https://example.com/contract.pdf"]})
for page in client.dataset(run["defaultDatasetId"]).iterate_items():
print(page["page"], page["method"], page["text"][:80])
Pricing is $4 per 1,000 scanned pages and $0.50 per 1,000 digital pages, with no subscription. If you already use RapidAPI, the same OCR is there too, with a free plan: https://rapidapi.com/MohitSawhney-YfHq0dWUO/api/audio-noise-remover-ocr-and-video-frames
Disclosure: I built it.
Top comments (0)