Doing PDF Redaction Right: Why a Black Rectangle Is Not Enough
If you have ever received a "redacted" PDF where the sensitive text is behind a black rectangle, and you copied it out anyway, you already know the problem. Drawing a shape over text does not remove the text. The bytes are still in the file. Ctrl+F still finds them. Copy and paste still pastes them. Doing redaction correctly is not hard, but the two common approaches (annotation overlays and text…
Many people have experienced receiving a redacted PDF with sensitive text obscured by a black rectangle. However, this method does not truly remove the text from the file. The bytes remain intact, and methods like Ctrl+F or copying and pasting can still uncover the concealed information. There are three main approaches to redaction, but only one is reliable.
The first approach involves drawing a black rectangle over the sensitive text. Although it appears visually redacted, the text remains in the file and can be extracted easily. This method is essentially decorative and not effective.
The second approach is text substitution, where the sensitive text is replaced with an equal number of X characters or spaces. This method is better than the rectangle approach, as it prevents simple extraction and copy-pasting. However, it still has flaws. Kerning tables can leak the original text, and certain characters or languages may not be substitutable, leading to corrupted or incomplete pages.
The third and most reliable approach is rasterising and flattening. This method involves converting each redacted page into an image, painting the redaction rectangles onto the image, and rebuilding the PDF page with the image-only content. The text objects are gone entirely, making it impossible to extract the sensitive information. The output is larger and may lose accessibility features, but it ensures the text is genuinely removed.
When redacting files, it's crucial to test the output. Open the redacted file in a fresh reader, select all the text, copy it, and paste it into a plain text editor. Search for any of the redacted terms. If any redacted terms still appear, the redaction is merely decorative and not secure. If none appear, the redaction is genuine and the sensitive information has been effectively removed.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.