Skip to content

Instantly share code, notes, and snippets.

@antonkratz
Last active June 21, 2025 10:25
Show Gist options
  • Save antonkratz/0ff4d9f9cce5ec457654937108e31d07 to your computer and use it in GitHub Desktop.
Save antonkratz/0ff4d9f9cce5ec457654937108e31d07 to your computer and use it in GitHub Desktop.
readact, flatten, PDF, Ubuntu

There is a sensitive document. Credit card statements. Reimbursement.

I want to redact (hide) parts of the document.

  1. Create a pitch black highlighter pen in Okular. Highlight the relevant text in black.
  2. The text is still there and can easily be seen, for example by highlighting (in the sense of Ctrl-A) the entire document.
  3. To flatten = actually remove the text beneath the black highlights:

pdf2ps in.pdf - | ps2pdf - out.pdf

Other suggestions (convert, ghostview...) do not work. Broken images, missing pages, weird fonts...

@alejandromunoz-es
Copy link

I've tried to highlight with black and then flatten the pdf, but the text is still there.

This turns it into a bitmap pdf, which is the only thing which works. Thank you for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment