PDF full text search requires a pipeline that validates each file, extracts native text where it exists, runs OCR where it doesn’t, normalizes and stores that text at the page level, indexes it, and returns results with a document ID, page number, snippet, and highlight coordinates. Most teams build this with Apache Tika or PDFBox for extraction, Tesseract for OCR, and Elasticsearch for indexing, swapping in Foxit or a similar SDK when you need tighter control over result coordinates.


TL;DR:

  • Score each page and send only pages with little extractable text to OCR, using document specific thresholds and reviewing low confidence results.
  • Page per document indexing costs more index overhead than whole file indexing, but supports page numbers, tighter snippets, and better relevance on long PDFs.
  • Elasticsearch attachment extraction is limited to roughly 10 MB per file through self managed connectors, with a hard 100 MB limit; extract larger PDFs separately.
  • Return document and page IDs, snippets, character ranges, and highlight rectangles; store page dimensions and rotation so highlights align after rendering.
  • Run extraction and OCR separately from live search nodes, and route malformed, oversized, or password locked files to manual review.

Yonderly
Keep Shared Content Up to Date
Yonderly automatically updates files and makes them searchable, helping teams find and share current materials across online and offline work.

Explore Yonderly

Table of Contents

How PDF Text and Searchability Actually Work

A PDF is not a text document with formatting on top. It’s a set of drawing instructions: place this glyph at this coordinate, draw this line, fill this shape. The order those instructions appear in the file often has nothing to do with the order a person would read them in. A two-column layout might store the right column’s text before the left column’s, and your extraction tool has no idea which arrangement is correct unless you tell it how to reconstruct reading order.

This is also why accessibility and search share the same root problem. A tagged PDF includes a logical structure tree that marks headings, paragraphs, and reading order explicitly, which screen readers rely on and which search tools can use to recover sensible text order. An untagged PDF has none of that: the text might extract correctly by luck, or it might come out scrambled.

Some PDFs contain no text layer at all. These are image-only PDFs: usually scanned pages saved as pictures, with nothing a search engine can match against. The W3C’s PDF7 technique addresses this directly, noting that a scanned PDF is not searchable or accessible until optical character recognition (OCR) creates an actual text layer, and that OCR output needs verification for recognition errors and reading order before you trust it.

A few things determine how clean that OCR layer turns out:

  • Scan resolution: low-dpi scans produce more misreads, which is why most pipelines render pages at 300 dpi before running OCR.
  • Reading order: OCR engines try to reconstruct it, but complex layouts (multi-column pages, sidebars, tables) can confuse the result.
  • OCR-suspect flags: many OCR engines mark low-confidence characters or words, which you should capture and surface for review rather than silently indexing.
  • Font and language coverage: unusual fonts, handwriting, or mixed-language pages increase error rates and deserve a manual QA pass.

Getting this layer right is the difference between a search feature that works and one that quietly returns nothing for half your document library.

Extraction Pipeline: Validating Files, Extracting Text, and Deciding When to OCR

Before you extract anything, you need to know whether you can. Run a validity and encryption check first: confirm the file opens, isn’t corrupted, and isn’t password-protected in a way that blocks programmatic access. Record basic metadata (page count, creation tool, PDF version) at this step too, since it helps you debug extraction failures later without reopening the file.

Here’s a practical sequence we recommend for ingestion:

  1. Validate the file. Check that it parses, isn’t encrypted (or capture the password if you have one), and log page count and metadata.
  2. Attempt native text extraction. Run Tika or PDFBox against every page and capture the extracted text along with a per-page character count.
  3. Score each page. Compare character count and the ratio of unmapped Unicode characters (a common sign of broken font encoding) against a threshold. Pages below it are treated as text-poor.
  4. Trigger OCR selectively. Send text-poor pages through OCR rather than reprocessing the whole document, which saves compute on files that are mostly native text with a few scanned inserts.
  5. Flag OCR-suspect pages. Record low-confidence OCR output for manual review instead of indexing it silently.
  6. Persist page-level text and metadata. Store extracted text, extraction method (native or OCR), confidence flags, and page dimensions, all keyed to page number.

Apache Tika’s PDFParser supports an AUTO OCR strategy built for exactly this decision: it inspects each page, and when native extraction looks insufficient, it renders the page (commonly at 300 dpi) and runs OCR automatically, rather than forcing you to choose OCR-for-everything or OCR-for-nothing up front.

Pro Tip: Set your text-poor threshold per document type rather than globally: a scanned contract and a native-PDF spreadsheet export need very different character-count cutoffs to avoid false triggers.

The reason this matters for search quality specifically: a page that silently fails extraction doesn’t throw an error, it just returns an empty or garbled string that gets indexed as-is. Your search feature doesn’t break loudly, it just becomes unreliable in ways that are hard to notice until a user complains that an obviously relevant document doesn’t show up.

Tooling and Configuration: Tika, PDFBox, and Tesseract Settings Worth Tuning

The default settings on most PDF parsers are tuned for general document conversion, not search accuracy, so a few configuration knobs are worth adjusting deliberately:

  • sortByPosition: reorders extracted tokens by their coordinates on the page rather than their order in the file’s content stream. This helps with simple layouts but can interleave text across columns on complex pages, so test it against your actual document types.
  • enableAutoSpace: inserts spaces between glyphs that are positioned apart but not explicitly space-separated in the content stream, which prevents words from running together.
  • suppressDuplicateOverlappingText: filters out text that’s rendered twice at the same position, common in PDFs generated by certain publishing tools.
  • imageStrategy and ocr.strategy: control whether Tika extracts embedded images, runs OCR, or does both, with AUTO being the practical default for mixed document collections.
  • maxMainMemoryBytes and maxPages: cap how much memory and how many pages a single extraction job can consume, which protects your extraction service from a single malformed or enormous file.

For OCR rendering specifically, dpi, imageFormat, and imageType settings determine the trade-off between recognition accuracy and processing time. Rendering at 300 dpi in grayscale is a common starting point: high enough for solid character recognition, low enough to avoid turning a 50-page scanned report into a multi-gigabyte processing job.

Scanned pages aren’t searchable until OCR builds a text layer, and that output needs verification against reading order and recognition errors before it’s trusted for search, per W3C’s PDF7 guidance.

Scanned page converted and checked before indexing

Forms, bookmarks, annotations, and embedded documents each need explicit handling in your parser configuration rather than being left to defaults. Form field values, for instance, often contain searchable content that lives outside the main text stream, and annotations (comments, highlights) may or may not be something you want indexed depending on your use case. Encrypted PDFs need a password supplied through parser metadata, or they need to be routed to a manual-handling queue instead of failing the whole batch job.

Indexing: Pre-Indexing, Page-Level Mappings, and Elasticsearch Limits

Two indexing models dominate PDF search implementations, and the choice affects both ranking quality and how your UI can navigate results.

Full-document indexing treats each PDF as one search record. It’s simpler to build and works fine for short documents, but it makes page-level navigation impossible: a match in a 200-page manual returns the whole manual, with no way to jump to the relevant page without re-scanning the text client-side.

Page-per-document indexing treats each page as its own searchable record, linked back to a parent document ID. This costs more index overhead but gives you page numbers and tighter snippets for free, and it scales ranking quality better on long documents where relevance should be judged per page, not per file.

Fields worth indexing and returning per match:

  • Document ID and page number, so the client knows exactly where a match lives.
  • Snippet text, the surrounding context around the match for display in results.
  • Character range, which anchors the match precisely within the page’s extracted text.
  • Highlight rectangles, the PDF coordinates needed to draw a box around the matched text in a viewer.
  • Relevance score, for ranking multiple matches across a document or collection.

If you’re using Elasticsearch, the ingest-attachment processor uses Apache Tika internally to extract file content at index time, which is convenient for small collections but comes with real limits: self-managed connectors cap extraction at roughly 10 MB per file, and Elasticsearch enforces a hard 100 MB per-file limit regardless of connector. For anything beyond small PDFs, extract text in a separate pipeline step and index the resulting text rather than feeding raw PDFs through the attachment processor directly.

For large collections, pre-indexing (extracting and indexing in a batch process ahead of time) outperforms on-the-fly extraction at query time almost universally. The exception worth watching is wildcard and fuzzy queries, which can get expensive against large page-level indexes and usually benefit from field-level tuning (edge n-grams, controlled fuzziness) rather than brute-force matching.

Search Result Model and Viewer Integration

A search result is only useful if a user can click it and land exactly on the matched text. That requires your API to return more than a snippet.

A minimal result payload includes:

  1. Document ID, identifying the parent file.
  2. Page number, so the viewer knows which page to render.
  3. Snippet, the text shown in the results list.
  4. Character range, locating the match within the page’s text.
  5. Highlight rectangle array (optional but recommended), the PDF-space coordinates for drawing a highlight box.

SDKs like Foxit’s return exactly this shape: page index, character ranges, the containing sentence, and rectangles in PDF coordinates, which a viewer can transform into pixel coordinates without re-parsing the document client-side.

That transformation matters more than it sounds. PDF coordinates originate from the bottom-left of the page and are independent of zoom level, while viewer pixels originate from the top-left and scale with zoom. You also need to preserve page rotation metadata: a page rotated 90 degrees at render time needs its highlight rectangles rotated to match, or the highlight box lands in the wrong place entirely.

Pro Tip: Store page width, height, and rotation alongside extracted text at ingestion time, not just at render time, so your highlight math has everything it needs without a second trip to the file.

Two UI patterns serve different needs. Sequential Find (next match, previous match, inside an open document) suits interactive reading, similar to what Adobe Acrobat’s search offers for basic and advanced phrase matching. Batch search APIs, which return every match across a document or collection in one call, suit automation workflows like redaction or bulk compliance review, where nobody is sitting at a keyboard clicking “next.”

Operational Concerns: Performance, Size Limits, and Failure Modes

Extraction and OCR are CPU and memory-heavy operations, and running them on the same infrastructure as your search index is a reliable way to degrade query performance for everyone. Elastic’s own guidance is explicit about this: extraction work should be isolated from the nodes handling live search traffic, since a burst of large-file uploads can otherwise starve search queries of resources.

A few patterns worth building in from the start:

  • Isolate extraction workloads on separate compute from your search cluster, scaling them independently.
  • Set explicit size caps per file for your main pipeline, routing anything larger to a dedicated edge extraction service or a manual review queue.
  • Build an on-failure path for malformed or oversized files instead of letting one bad upload block a batch job.
  • Supply passwords for encrypted PDFs through parser metadata where you have them, or route those files to a manual handling workflow when you don’t.
  • Log extraction metadata (method used, processing time, OCR-suspect counts) per file, which turns “search seems broken” into a traceable, specific problem.

That last point pays off more than it seems like it should. A rising OCR-suspect count across recent uploads is often the first sign that a new document source or scanner is producing lower-quality input, and catching that trend in logs beats catching it in a support ticket. If your organization also manages content distribution alongside search, the operational practices in enterprise document distribution overlap here, particularly around tracking which files are current versus stale across many endpoints.

Before calling a PDF search feature production-ready, work through a short, concrete checklist rather than trusting that it works because it compiled.

  1. Ingest a representative sample set, including native-text PDFs, scanned documents, and mixed files with both.
  2. Verify per-page extraction method is logged correctly (native versus OCR) for every page in the sample.
  3. Test multi-column layouts explicitly, since reading-order bugs concentrate here.
  4. Test rotated pages, confirming highlight rectangles rotate correctly with the page.
  5. Test tables, accepting that cell structure usually won’t survive extraction and checking that the text still reads sensibly, not that formatting is preserved.
  6. Test low-quality scans, reviewing OCR-suspect flags against actual recognition errors to calibrate your threshold.
  7. Run end-to-end highlight verification: search a known phrase, confirm the returned page and rectangle actually highlight that phrase in the viewer.
  8. Automate OCR-suspect sampling, pulling a percentage of flagged pages into a review queue on a schedule rather than only at launch.
  9. Add integration tests that assert snippet text matches the source page and that highlight coordinates land within page bounds.

Skipping the rotated-page and multi-column test cases is the most common shortcut we see, and it’s also where most production search bugs turn up first.

How Yonderly Fits Into a PDF Search Strategy

Full-text search is only as good as the index behind it, and an index is only as good as the files feeding it. A common failure mode has nothing to do with extraction quality: the PDF getting searched is simply out of date, because someone updated the source file but the copy sitting in a shared drive, device, or kiosk wasn’t replaced.

Our platform addresses that gap directly. We built automatic file updates into the core of how content gets distributed, so once a new version of a file is pushed, every connected device picks it up without someone manually re-uploading or re-indexing anything downstream.

For teams managing interactive presentations rather than static PDFs, we let you share and manage that content across online and offline devices from one place, which matters when your search layer needs to reflect what’s actually on a device in the field, not just what’s in a central repository. We also built in advanced search capabilities and real-time engagement tracking, and we designed setup to take minutes rather than requiring extensive training or a long-term contract, which matters for teams in life sciences and similar regulated settings where content accuracy carries real weight.

Searching Beyond PDFs: Interactive Presentations and Mixed Content

PDF search solves one piece of a larger problem. Most teams don’t manage a library of PDFs in isolation: they manage a mix of PDFs, PowerPoint decks, HTML pages, and interactive presentations, often covering the same underlying content in different formats for different audiences.

A search feature that only covers PDFs leaves gaps the moment a sales deck or an HTML microsite enters the picture. The extraction and indexing principles carry over reasonably well (text layers, page or slide-level granularity, snippet and highlight models), but the file formats need their own extraction paths: PowerPoint files store text in slide XML rather than PDF content streams, and HTML content needs DOM parsing rather than OCR or PDF text extraction.

If your team distributes PowerPoint presentations alongside PDFs, or maintains an updatable pitch deck that changes more often than a static file would allow, it’s worth designing your search layer around content type from the start rather than retrofitting PDF-specific logic onto formats it was never built for.

What I’d Optimize for If I Were Building This Today

Page-level indexing wins almost every time, even though it costs more index overhead than full-document indexing. The ability to return a specific page number, not just a file name, is what makes search feel accurate instead of approximate, and it’s the detail users notice first when it’s missing.

I’d also spend more engineering time on extraction observability than on indexing features. A fuzzy-search tweak might improve recall by a small margin; a dashboard that surfaces rising OCR-suspect rates catches a broken scanner or a bad upload source before it quietly poisons weeks of search results.

My defaults: 300 dpi OCR rendering, AUTO strategy for mixed collections, page-per-document indexing, and a hard rule that no extraction confidence score goes unlogged.

— Paul

Keep Your Searchable Files Current With Yonderly

A search index is only trustworthy when the files behind it are the right ones, and that’s the piece most PDF search guides skip entirely. Our platform is designed to close that gap by pushing new versions to connected devices automatically, helping ensure the content your team searches and shares remains current.

Yonderly

A few specifics worth knowing if reliable distribution is part of your search strategy:

  • Automatic file updates push new versions to every connected device without a manual re-upload step.
  • Offline access keeps content available and current even when a device isn’t connected.
  • Cross-platform delivery supports multiple operating systems from a single upload.
  • Flexible setup, designed to be quick without requiring extensive training or long-term commitments.

Plans start with the Standard plan costing several tens of dollars per month per Admin, with higher-tier plans priced in the low hundreds and mid hundreds of dollars per month for growing teams, each with its own per-device fee for scaling beyond the included allowance, detailed on our pricing page. If you manage interactive presentations or a document library that needs to stay current across many devices, our 7-day pilot is a practical way to see the update speed firsthand before committing to a plan.

FAQ

What’s the difference between a searchable PDF and an image-only PDF?

A searchable PDF has an underlying text layer that a search engine can read and match against, usually because it was generated digitally or because OCR was run on it. An image-only PDF, typically a straight scan, has no text layer at all, so search tools find nothing until OCR creates one.

Do I need OCR if my PDFs are generated digitally, not scanned?

Usually not for the whole file, but mixed documents are common: a digitally created report with a few scanned signature pages or appendices still needs OCR for those specific pages. Scoring each page’s extracted character count lets you trigger OCR selectively rather than running it across an entire document unnecessarily.

How large a PDF can Elasticsearch’s attachment processor handle?

Self-managed connectors using Elasticsearch’s ingest-attachment processor limit extraction to roughly 10 MB per file, and Elasticsearch enforces a hard cap of 100 MB per file regardless of connector. Larger files should be extracted in a separate pipeline step before indexing the resulting text.

What should a PDF search result actually return to the client?

A usable result includes the document ID, page number, a text snippet, the character range of the match, and ideally highlight rectangles in PDF coordinates, which SDKs like Foxit’s search API provide natively. That combination lets a viewer jump directly to the match and draw an accurate highlight box without re-parsing the file.

Can full-text search stay accurate if the underlying PDF file changes?

Only if the index gets updated whenever the file does, which is a distribution problem as much as a search problem. Platforms that push file updates to every device or location automatically, rather than relying on manual re-uploads, reduce the chance that search returns results from an outdated version of a document.

Sources