DEV Community

Cover image for Give a PDF ingestion pipeline an explicit route for scanned documents
Tim Zinin
Tim Zinin

Posted on

Give a PDF ingestion pipeline an explicit route for scanned documents

A PDF can look perfectly readable in a viewer while exposing no digital text to an extractor. The page may be an image of printed words. If a pipeline treats an empty extraction as an empty document, it silently drops the content that a person can see.

PDF Text Extractor works with the text layers of authorized digital PDFs. It returns a document envelope with page-level text, metadata and a document hash. It does not perform OCR, reconstruct the original visual layout or interpret charts. Its clean failure routes are as important as its successful text output.

Start with a known digital document

The input below uses the project's synthetic text PDF from the installed schema. It is an example for inspecting the contract, not evidence of a new run performed for this article. Start with one controlled document before importing an uncontrolled folder of mixed PDFs.

{
  "fileUrls": [
    "https://api.apify.com/v2/key-value-stores/b0cgFsJRqVv3XOZyG/records/pdf-text.pdf"
  ],
  "maxPages": 25,
  "maxTextChars": 200000
}
Enter fullscreen mode Exit fullscreen mode

The Actor accepts one through five public direct-download URLs that you own or are authorized to process. Public accessibility alone does not establish permission for every later reuse. Keep your own source authorization with the ingestion job rather than expecting the extractor to decide it.

Keep page provenance in the search index

Each complete document contains page records with physical page numbers, text and character counts. When you split the text into search chunks, carry the document hash, source URL and page number into the chunk metadata. A generated search snippet then has a source location that a reviewer can inspect.

Do not assume extracted reading order reproduces the printed layout. Multi-column pages, positioned text and unusual font encodings can require review. The presence of words in a text layer establishes extractability, not perfect reconstruction of every visual relationship.

Treat whole-document limits as acceptance gates

maxPages can be set from one through twenty-five. The contract rejects a document whose total page count exceeds that selected cap. It does not sell the first twenty-five pages of a longer file as a complete document.

maxTextChars bounds the whole extraction, including its separators, up to two hundred thousand characters. The result unit is the complete document. If the bound prevents completion, preserve the limit notice and keep the source out of the complete-document collection.

Route scans to a separate process

A requires_ocr outcome belongs in an OCR queue. It should not become a successful zero-length document in the text index. A genuinely blank document, a scan and a download failure have different meanings even when none delivers useful text.

If you use a separate OCR tool, retain the original file hash and record that the resulting text was recognized from pixels. That text has a different evidence path from a digital text layer. The downstream index can store both while preserving their extraction method.

Make refresh behavior reversible

Stage a newly extracted document and validate it before replacing the previous accepted version. A failed refresh should create an operational issue while preserving the earlier indexed source. A stable URL is not a stable byte snapshot, so compare document hashes when deciding whether content actually changed.

The practical outcome is a pipeline that can explain why a file entered the search index, needed OCR or was held for a limit. That explanation is more useful than a single generic success flag attached to every downloaded PDF.

Cost and verification scope

The current FREE-tier result price is $0.002 for the documented unit: One complete digital-text PDF, up to 25 pages and 10 MB. The listing also has a $0.003 start event, charged per GB of Actor memory with a minimum of one event. A free diagnostic row does not refund that start event. Discounted platform tiers have their own rates; inspect your applicable tier before estimating a batch. These are listing prices read on 21 October 2026, not a receipt or a claim about customer spending.

The contract for this draft was checked against installed build 0.1.4 (2b7P3iVLriYaYRJWJ). The input above is an illustrative schema example, not a newly executed run. Current source responses and useful output still need inspection when you choose to run it. No new cloud build or run was made to prepare this article.

Open the Actor and inspect its input and pricing.

AI-assisted draft; publication requires independent technical review.

Top comments (0)