Home › Blog › Anonymize a scanned PDF

Anonymize a scanned PDF or a photo of a document

A scanned PDF or a photo of a document is an image, with no text to redact directly. To anonymize it, mask the sensitive areas visually, or run text recognition (OCR) before treating it as a text document.

Published · Updated · 9 min read

Why a scan differs from a text PDF

A regular PDF contains text: each word is a sequence of characters that you can select, copy, or hide with a redaction tool. A scanned PDF or a photo of a document is an image: a grid of pixels, with no underlying text, unless software has added a text-recognition layer.

This difference changes everything for anonymization. The documents most often scanned or photographed — ID card, passport, bank account details, pay slip, proof of address — contain highly sensitive data, and tools designed to redact text do not apply directly to an image. You have to either mask the pixels of the area to hide, or first recognize the text and then treat it as a text document.

Mask areas on an image or a scan

On an image file (JPEG, PNG), drawing an opaque box and then saving the result in that same image format really masks the information: the box is burned into the pixels. On a Mac, Preview makes this simple:

  1. Open the image (JPEG, PNG) in Preview.
  2. Click the Markup icon, then choose the Rectangle shape.
  3. Draw a rectangle over the area to mask, set its fill to opaque black and its border to black.
  4. Export the result to a new JPEG or PNG file (File, Export): never overwrite the original, always keep a source copy.
  5. Reopen the exported file and check that the rectangle can no longer be selected or moved.

This method only works for an image file saved as an image. On a PDF, even a scanned one, a rectangle added as an annotation does not change the image underneath: the annotation can be deleted and everything seen again, not to mention a possible OCR text layer (see the next section). For a scanned PDF, export the page as an image, mask it, then rebuild the PDF from the image, or use a redaction tool that handles image areas, such as Adobe Acrobat Pro or LibreOffice (Tools › Redact). Preview's Tools › Redact acts on selectable text: on a scan without text, go through the image. Then check the final file: Cmd+A or Ctrl+A, copy and paste into a text editor, and try to select or move the rectangles.

When a scan hides a text layer (OCR)

Many scanners and scanning apps silently add a layer of OCR-recognized text on top of the image, to make the document searchable. In that case, a box drawn on the visible image is not enough: the invisible text remains present and can be selected, copied or extracted, exactly as with a black box placed on a text PDF.

To find out whether your file contains such a layer, try selecting text with the mouse directly on the displayed page. If words highlight and can be copied, an OCR layer exists and the document must be handled with the same precautions as a text PDF, not just with visual masking.

Anonymize an ID card or an official document

On an ID card or passport, masking the visible fields (last name, first name, date of birth, document number) is not enough. The bottom of these documents carries a machine-readable strip, the MRZ, which encodes the same information in plain text in a compact form. A document where only the top fields are masked remains re-identifiable through this strip if it is not masked too. It is a point to check on every ID document in a notarial file.

On bank account details or a pay slip, such as the bank details and pay slips in client files of an accounting firm, the sensitive areas to cover are generally the full name, address, IBAN, social security number and net salary, depending on how the document will be used. Before masking, ask yourself who the document is for and what it must prove: a proof of address sent to open an account does not need to show the rent amount, and bank details provided for a refund do not need to show the transaction history if only a partial screenshot was requested.

Free tools to anonymize a scan

Several free solutions let you mask an image without uploading the file:

These manual methods suit an isolated file. They become slow as soon as you have to process several scans from the same file, or spot every sensitive area yourself across dozens of pages. To be clear about AnonymFiles: the app reads scanned PDFs and images (.jpg, .png, .tif) with local OCR. The pixels of the detected areas are erased in the image, and an invisible text layer carries the labels; nothing is exported without a side-by-side review. A stamp, a signature or a handwritten note that the OCR cannot decipher is masked in one click. For an isolated scan, without the app, the methods described above remain valid (masking the pixels, exporting as an image, checking the OCR layer).

For the rest of a file — briefs, letters, contracts in text format — AnonymFiles works offline once installed, with no account, no online license check, no telemetry and no cloud chat: it goes through the entire folder and shows you each original next to its redacted copy before any export. It is coming soon for Apple silicon Macs and Windows. For those documents, follow our method for text PDFs. A human review is still necessary.

Check that a scan's anonymization works

Once the file is processed, check three points before sharing it. First, zoom in on each masked area to check that no edge of text sticks out from the cover. Next, try to select text across the whole document: if an OCR layer was regenerated or left untouched, the masked text can remain readable by copy and paste, as documented for PDF redaction in general. Finally, check the file's metadata (author, date, software used), which can also reveal information.

No automatic tool is 100% reliable: a human review of the final document is still necessary before sending it.

Frequently asked questions

Can you redact a scan like a text PDF?

Not directly: a scan is an image, so there is no selectable text to delete. You have to mask the pixels of the area concerned, or run text recognition (OCR) before treating the document as a text PDF.

Is a black box drawn on a photo of a document reliable?

Yes, if the photo is an image file (JPEG, PNG) and you save the result in that same image format: the box is then burned into the pixels. On the other hand, a box added as an annotation on a PDF, even a scanned one, does not change the image underneath: the annotation can be deleted and everything seen again, not to mention a possible OCR text layer. For a scanned PDF, export the page as an image, mask it, then rebuild the PDF from the image, or use a real redaction tool.

Should you mask the MRZ strip of an ID card or passport?

Yes. The machine-readable zone at the bottom of the document encodes the same information as the visible fields (name, date of birth, number): masking only the text above is not enough.

Which free tools can anonymize a scan?

Preview on a Mac and GIMP let you draw opaque areas on an image and save the result as JPEG or PNG, which burns the masking into the pixels. For a scanned PDF, use a redaction tool that handles image areas (Adobe Acrobat Pro, LibreOffice › Tools › Redact) or convert the page to an image before masking it. Keep online tools for non-sensitive documents, since the file is sent to a server.

Once the scan is anonymized, is there anything else to check?

Yes: the file's metadata (author, date, software) and the absence of any leftover OCR text layer. No automatic tool is 100% reliable, so a review is still necessary.