DEV Community

KomoPDF
KomoPDF

Posted on

A black box on a PDF can leave the text underneath

A black rectangle covers a client name in a PDF. The preview looks ready to send, but selecting the line and pasting it into a text editor reveals the name. The rectangle changed what the page displays; the original text can still be stored underneath.

A PDF can also carry the same name in a comment, form value, document property, attachment, or scan. A safe sharing workflow has to consider the whole exported file, not just the visible page.

Covering is different from removing

Page content and annotations can occupy separate parts of a PDF. Drawing a filled shape over text may leave both objects in the file. Flattening annotations can turn their appearance into page content while leaving the underlying text untouched. Printing to another PDF is also not a reliable redaction procedure: the output depends on the print pipeline and may retain text or other material.

Use a redaction feature that removes the marked content when applied. A mark awaiting application is a review instruction, not proof that the content has been removed. Check the tool's documentation for how it treats text, images, and overlapping objects, then save a separate output file. Keep the original in an appropriately restricted location.

Adobe's sanitization guidance describes hidden information such as metadata, comments, and hidden layers, and provides a separate removal step. The exact options vary between applications. Review what a tool removes instead of assuming that a button with a familiar name covers every object in every PDF.

Search is useful, but it has blind spots

Imagine an invoice with an account number in the body, a scanned signature at the bottom, and a comment containing the same number. Searching the account number can find searchable text, but it may miss characters inside an image, an OCR error, or a differently formatted copy. A search that returns zero matches can also mean the document has no searchable text layer at all.

Use several checks on the saved output:

  1. Search the complete sensitive value and distinctive fragments. Search for a known retained word as a control; if that also fails, the search may not cover the page's content.
  2. Select and copy around each redacted area into a local text editor. Any recovered sensitive text is a failure. A clean copy result alone does not prove that an image or hidden object is clean.
  3. Inspect each affected page visually, including headers, footers, and repeated pages. Zoom in around the edge of each marked area, especially for scans and handwritten material.
  4. Review comments, form fields, attachments, document properties, bookmarks, and hidden layers. Remove sensitive material using the tool's sanitization features, then inspect what remains.

These checks find common mistakes; they do not prove that every possible encoding or hidden object is absent. For a high-consequence release, use the review process and specialist tools required by your organization.

Build a small regression fixture

A document workflow can test for the overlay mistake without using real customer data. Create a fixture containing a unique fake token, such as REDACTION_TEST_4827, in ordinary page text. Add a different fake token in a comment or form field if the workflow handles those objects. Keep a copy of the fixture before editing.

Run the exact workflow that produces a shareable file. In the exported copy, check the page visually, search and extract text with an independent reader, and inspect the comment or field. Include a retained control token elsewhere so the test can distinguish a working text extraction from an empty result. If the sensitive fixture token is still recoverable, fail the release test and investigate the output, not just the preview.

Add a second fixture with text embedded in a scanned image. A text extraction test cannot establish whether those pixels were removed. Inspect the rendered output and use image-aware tests appropriate to the content. If OCR exists, check that its text layer has been treated too; OCR can miss text even when the image remains readable.

Treat the exported file as the artifact

Verify the exact file that will be sent, after applying redactions and removing hidden information. Reopening it catches mistakes such as reviewing one version and attaching another. A file picker or download list can make two similarly named copies easy to confuse, so use a distinct name for the shareable copy and keep the original out of the delivery folder.

For form-heavy documents, redaction and sanitization can remove information the recipient needs, including field values or comments. Check the remaining fields and page content after sanitizing. If the document carries a digital signature, editing can affect signature validation; preserve the signed original and review the recipient's requirements before producing a modified copy. See how PDF changes affect digital signatures.

Top comments (1)

Collapse
 
kamalmosadegh profile image
Kamal Mosadegh •

Good write-up — the control-word check (search a known retained word to prove the search actually covers the page) is the part most redaction guides skip, and the "a mark awaiting application is a review instruction, not proof" line is exactly right.

One check I'd add after you save the redacted output, because search and select-and-copy both have a blind spot your article names: the raw bytes. A sensitive string can survive in the file even when no viewer shows it — in an incremental-update revision, in a hex-encoded string, or inside a Flate-compressed content stream that plain grep never sees.

What I do on the saved output file:

  1. qpdf --qdf out.pdf - | grep -a "CLIENT NAME" — qpdf decompresses the streams first, so grep actually sees the content. A hit here is a failure, full stop.
  2. Grep the hex form too — PDF strings can be stored as <434C49454E54...> rather than (CLIENT...), and a text search will never match that.
  3. Check for an incremental-update tail: if the redaction tool appended a revision instead of rewriting the file, the original objects are still sitting in an earlier revision. qpdf --check will tell you how many revisions the file carries.

If all three come back clean and your select-and-copy test is clean, that's the first point where I'd call the file safe to share. Search alone returning zero matches proves nothing on its own — as your article says, it can also mean there's no searchable text layer at all.