Remove Hidden PDF Text

Strip misread or duplicated invisible OCR text layers

1Choose file2Settings3Process4Save

Choose a PDF and its contents will be analyzed and shown here.

Files are processed only in this browser. Nothing is uploaded to a server.

Strip only the invisible OCR text layer that was misread or stacked behind a scan

Continue in another tool
Task settings
Settings

Finds and removes only text objects (BT…ET) that set render mode 3 (invisible) before drawing glyphs. Visible text and the scanned background image are never affected.

Remove the password from an encrypted PDF first. Processing focuses on page content, so bookmarks, attachments, forms and signatures may not be preserved. Keep the original and check the result.

About Remove Hidden PDF Text

A searchable scanned PDF is usually two layers. What you see is the scan image; on top of it, at the same positions, sits the text an OCR engine recognised, drawn so that it is invisible. The PDF specification expresses that with text rendering mode 3 — neither fill nor stroke.

When the OCR was wrong, or a second text layer was added on top of the first, searches and copy-paste stop matching what the page shows. This tool deletes that invisible text and leaves the scan image byte-for-byte identical, typically as a clean-up step before running OCR again.

What is removed, and is it really gone from the file?

The tool parses each page's content stream — and any Form XObjects the page calls — into text objects (BT … ET), and deletes an object when every one of its text-showing operators runs in rendering mode 3. The rendering mode is part of the graphics state — it carries across BT/ET and is saved and restored by q/Q — so the tool follows it through the whole stream (and across the several streams of one page). Objects that inherit 3 Tr from an earlier one are removed too, and the state operators a removed object set, such as its font and mode, are left in place so whatever follows draws exactly as before. The edited stream is recompressed under the same object number and the whole file is rewritten, so the deleted text does not linger as an earlier revision at the end of the file. Open the result in a text editor and those strings are not there.

Some things do remain. The font objects the OCR layer used are still listed in the page resources, and document info and XMP metadata are not touched. How content streams, objects and revisions fit together is covered in the How PDF Files Work guide.

Hidden text this tool will not catch

Only rendering mode 3 is detected. These cases are left alone:

  • White text on a white background, text set at a tiny size such as 0.1 pt, or text placed outside the page area
  • Ordinary text covered by an image
  • Text inside a Form XObject that sets no mode itself and is invisible only because it inherits 3 Tr from the content that calls the form (forms are checked as if they start in mode 0, so this text is kept)
  • Objects that mix visible and mode-3 text, for example drawing visible text first and only then switching to mode 3 — the whole object is kept so no visible text is lost

Worked examples

A 20-page contract that was OCR'd twice

Input
Every search hit appears twice and copied text comes out doubled, like “contract contract”
Output
All invisible text objects are removed, leaving a plain scanned PDF with no selectable text

Both OCR layers use mode 3, so both go. There is no way to keep one and drop the other, so run OCR once more on the result to get a single, clean text layer.

How to use it

  1. Choose the scanned PDF. Every page is processed, and the preview shows the result as soon as the file loads.
  2. Run it and check the summary for the number of text objects removed and streams changed.
  3. Open the result: it should look the same but have no selectable text. Re-run OCR if you need search back.

Frequently asked questions

It says zero objects were removed.

The text is probably hidden some other way — white text, text behind an image — or the mode is set only by the content that calls a Form XObject. Those files are outside what this tool handles.

Does the scan lose quality?

No. Image objects are never opened, so pixels and compression are exactly as they were.

Can I use this to strip hidden personal data before sharing?

For mode-3 text, yes: it is removed from the file, not just hidden. Text hidden by other means and the document metadata stay, so for public copies also run the metadata sanitiser.

Can I see what will be removed before running it?

Yes. When the file loads, the same removal is run in advance, and any text present in the original but missing from the cleaned copy is shown as red boxes on the page and in a list. The preview and the result come from the same calculation.

Does it work on PDFs made with this site's OCR tool?

Yes. That tool also places recognised text in rendering mode 3, so you can strip it here and re-run OCR with a different language setting.

Sources

Last reviewed:

Privacy and how data is handled