Blog

How do I OCR PDFs through an API without a subscription?

11 November 2026

You can OCR PDFs through an API without a subscription by using a pay-per-use hosted service, a metered cloud OCR endpoint, or an open-source OCR engine that you host yourself. Pay-per-use suits irregular volumes, while self-hosting makes sense only when your volume is steady and high. Whichever you choose, send only scanned pages for OCR and keep the rest as they are.

What are my options for OCR through an API without a subscription?

You have three realistic routes, and each trades money, time and control differently.

  • Self-host an open-source OCR engine. You run it on your own server and wrap it in a small web endpoint. There is no licence fee, but you pay for hosting, maintenance and tuning.
  • Use a pay-per-use hosted API. You send a file, you are billed for what you process, and nothing recurs when you stop. This suits irregular or spiky workloads.
  • Use a cloud vendor's metered OCR service. These usually bill per page with no monthly plan, though you may need an account, billing setup and some configuration.

Before choosing, estimate your volume. A few hundred pages a month rarely justifies running your own servers, while a steady, very large flow may make self-hosting cheaper over time.

Also consider the surrounding work. OCR rarely stands alone: you often need to split a large scan into separate documents, merge supporting files, or rotate and clean pages first. An option that handles those steps in the same call chain saves you stitching several tools together.

Check the pricing page carefully for minimum spends, free-tier limits and per-page rules, because these change and differ between providers.

How does a typical OCR API request work?

Most PDF OCR APIs follow the same pattern, so the code you write is easy to move between providers.

  1. Authenticate with an API token, normally sent in a header.
  2. Submit the PDF, either as a multipart upload or as a URL the service can fetch.
  3. Set options, such as language, page range and whether to output plain text or a searchable PDF.
  4. Wait for the result. Small files often return synchronously. Larger ones run as a job: you receive an ID, then poll for status or receive a webhook when it finishes.
  5. Download the output and store it somewhere durable.

Keep your token in an environment variable rather than in source control. Add a timeout and a retry with backoff, since network calls fail occasionally.

For longer documents, process in batches and track each job ID so you can resume after a failure without redoing everything. Log the page count and duration of each job; this makes cost and performance easy to review later.

Finally, validate the output. Check that the returned text is not empty and that the page count matches the input. A quick sanity test catches most silent failures before they reach your users or your database.

Should I run OCR on every PDF?

No. Many PDFs already contain a text layer, and running OCR on them wastes money and can make the text worse.

A simple check: try extracting text with a PDF library first. If you get sensible text on each page, skip OCR. If a page returns nothing, or only stray characters, it is probably a scanned image and needs OCR.

Mixed documents are common, so decide per page rather than per file. Send only the image-only pages to OCR and keep the existing text for the rest.

Other ways to cut cost and improve accuracy:

  • Scan at a sensible resolution. Around 300 DPI is a common starting point for text documents.
  • Straighten and crop skewed pages before upload.
  • Use greyscale or black and white for plain text, to keep file sizes down.
  • Set the correct language. Wrong language hints are a frequent cause of poor results.
  • Remove irrelevant pages, such as blanks or cover sheets, before processing.

Treat accuracy as something to measure, not assume. Take a small sample of your real documents, compare the output with the originals, and note where errors cluster, for example handwriting, stamps or low-contrast print. That tells you whether preprocessing is worth the effort.

How do I split and merge PDFs in the same workflow?

Splitting and merging are cheap operations compared with OCR, so do them in the order that reduces the work.

A common pipeline looks like this:

  1. Split first if a single scan holds many documents, such as a batch of invoices. Cut by page ranges or by detecting blank separator pages.
  2. OCR each part separately. Smaller files are easier to retry and give you per-document results.
  3. Merge afterwards if you need one combined file, such as a case bundle or monthly archive.

Page ranges are usually written as strings like 1-3,7,10-12. Check whether the API counts pages from one or zero, and what it does with out-of-range numbers: some ignore them, others return an error.

When merging, supply files in an explicit order and keep a manifest recording the source of each page range. This helps if someone later asks where a page came from.

Be careful with metadata. Merging may drop bookmarks, form fields or document properties, so test with a representative file. Also confirm that a merged searchable PDF keeps its text layer, by selecting text in a viewer or extracting it programmatically.

What should I check before relying on it in production?

Treat the integration like any other dependency that handles customer data.

  • Data handling. Find out where files are processed, how long they are kept and whether they are deleted automatically. If documents contain personal data, UK GDPR obligations apply, so check the provider's terms and consider a data processing agreement.
  • Limits. Look at maximum file size, page count, request rate and timeout. Design around them with splitting and queues.
  • Error handling. Decide what happens with encrypted, corrupt or password-protected files. Return a clear message rather than failing silently.
  • Cost controls. Set spending limits or alerts if the provider offers them, and cap how many pages a single job can process.
  • Idempotency. Make sure retrying a job does not create duplicate records in your system.
  • Monitoring. Track failure rates, average processing time and pages processed per day.

Keep your own copy of the original file until you have verified the output. If you ever switch provider, having originals means you can reprocess without asking anyone to rescan.

Finally, wrap the API calls in one small module of your own. Then changing provider means editing a single file.

Frequently asked questions

Can I OCR PDFs for free through an API?

Some providers offer limited free tiers, and open-source engines cost nothing to licence. Free tiers usually have page or rate limits, and self-hosting still costs you server time and upkeep.

What is a searchable PDF?

It is a PDF that keeps the original page image but adds a hidden text layer from OCR. You can then select, copy and search the text while the page looks unchanged.

Does OCR work on handwriting?

Results are usually much weaker than for printed text and vary widely with the writing. Test with your own samples before depending on it.

Related on B.A.I.S.

PDF Toolkit API on Apify gives you pay-per-use PDF OCR, split and merge as an API, so you pay for what you process with no subscription.


Need this done for you? PDF Toolkit API on Apify