Español

Lee este artículo en español.

How to Extract Text from a PDF (Even When You Can't Copy It)

Updated

Short answer: if the PDF has real text, open it in any viewer, press Ctrl+A and then Ctrl+C (Cmd on a Mac) and paste it wherever you need. If nothing gets selected, the PDF is a scanned image: upload it to Google Drive and choose Open with → Google Docs, or open it from Word; both recognize the text. To extract the text from many PDFs at once, do it automatically with an API.

You've got several PDFs (invoices, reports, contracts) and what you actually need isn't the file itself, it's the text inside it: to search for a word, analyze it, drop it into a spreadsheet, or hand it off to another tool. Copying and pasting page by page doesn't scale past a couple of files.

It comes up a lot in cases like:

By hand: copy it, or recognize it

To do it automatically for many PDFs, Extract text from a PDF does the work: you send it the PDF, it sends back the text. For scanned PDFs, Cofferdock also has PDF OCR, which recognizes the text of scanned pages.

How it works

You send the raw PDF (application/pdf) or a JSON body with { file, pages }. The response is always JSON (never a PDF, since what you're asking for is text, not a file) with { text, num_pages, info, pages? }: the full text, the page count, and some info about the document.

If you need the text page by page

By default (pages: false) you only get the full text, all joined together in text. Set pages: true and you also get a pages array with each page's text kept separate. Useful when it's not enough to know a phrase is somewhere in the document; you need to know exactly which page.

When the text comes back empty, that's not an error

This is the case that trips people up the most: if the PDF is a scan (an image sitting inside a PDF, with no real text layer behind it), the response comes back with text: "" (empty) but success: true, and it still uses 1 credit. Nothing failed: that PDF genuinely has no text to extract, just a picture of a page. Getting text out of it would require OCR, which this tool doesn't do.

If you run into this, the quickest check is whether you can select text with your mouse when you open the PDF in a browser. If you can't, it's a scan, and the empty result is correct, not a bug.

FAQ

Why can't I select the text in my PDF? Because it's a scan: the pages are images, not text. Use text recognition (OCR), for example by opening it with Google Docs from Google Drive.

Why does the copied text come out as strange symbols? The PDF uses fonts that don't include proper text information. Copying can't fix that; use text recognition instead.

Why does it return empty text when the PDF opens perfectly fine? Because "opens fine" and "has real text" are two different things. A PDF can be nothing more than a scanned image sitting inside a PDF file: it looks perfect, but there isn't a single character of real text in it, so there's nothing to extract without OCR.

Can I find out which page a specific phrase is on? Yes, by requesting pages: true. Alongside the full text in text, you get a pages array with each page's content kept separate.

How much does each extraction cost? 1 credit per call, regardless of how much text the PDF actually has (even if it comes back empty because it's a scan).

Related guides

Try these tools

You'll find the full instructions for Extract text from a PDF, covering both output modes. And if you don't have an account yet, you can create one for free.