How to Extract Text From a PDF

Text-layer PDFs and image-only PDFs need different handling. Here is how to tell them apart.

5 min read

Identify which kind of PDF you have

Open the file and try to select a sentence with your cursor. If the text highlights, the file has a text layer and the characters are already stored in it.

If nothing highlights, or the whole page selects as one block, the page is an image. Recognition is required.

Some files are mixed: a digitally generated report with scanned appendices bound in. Check a page from each section, not just the first.

Extracting from a text-layer PDF

Extract the existing layer directly. The characters are exact, so there is no recognition error at all.

The remaining work is structural: removing repeated headers and footers, rejoining words split by hyphenated line breaks, and fixing reading order in multi-column layouts.

Ligatures such as fi and fl sometimes extract as a single unusual character. A find-and-replace pass handles them.

Extracting from a scanned PDF

Here the page is a picture, so all the usual recognition considerations apply: resolution, contrast, skew and language.

If the scan is low resolution, rescanning the original beats any amount of processing. If the original is gone, expect to correct the output.

Process in batches for very long documents so that a failure part-way does not cost you the whole run.

Checking the result

Compare page counts and spot-check the first paragraph of several pages against the source.

Verify tables and figure captions separately; they are the parts most likely to be relocated in the output.

Frequently asked questions

Tool for this

PDFGPTExtract, convert, merge, split and compress PDFs.

Open the PDFGPT page

More in PDF Tools & Techniques