Is there a better way to redact a PDF?
(originally I recommened Okular but it didn't work as I expected)
1. Edit the document in a vector editor
I was able to open a PDF file in Inkscape, draw a rectangle over a piece of text and print it out. Inkscape is a vector editor so no rasterization involved. Some fonts looked wrong though - probably because the document was created on Windows machine with fonts which are absent on mine.
Note that any method that does not involve rasterization is only acceptable if you're going to print the redacted document on paper and not distribute it electronically, as the text still can be retrieved from under blackouts.
2. Increase the rasterization resolution when opening in a bitmap editor
Regarding "quality loss" when opening the page in Gimp: you can directly open a PDF file in Gimp. It will be rasterized in the process. The amount of quality loss in the process is a matter of resolution you choose when importing - 300 dpi should give you a very decent quality (the default is 100).
You can also get good results with ImageMagick's convert
command if you tell it to increase resolution:
convert -density 300x300 ...
You can use Okular.
sudo apt-get install okular
- Open the pdf with Okular.
- Press F6.
- Press 8.
- Highlight the text you wish to redact.
- Right click the text, select properties, select the "Type" as "Highlight", press Ok.
- Print the file to a pdf.
Basically what you are trying to do is highlight/annotate a PDF, but with some flexibility towards marker opacity and colour (you mentioned you don't need to censor/remove something, merely redact). Have you taken a look at answers here: How can I highlight or annotate PDFs?
One of the highest rated answers recommends Xournal, which has not been mentioned here and would be my weapon of choice. It is a tool that allows you to make handwritten notes but has extra features allowing you to annotate a PDF. By default it'll save your annotations as a separate file but also allows you to export the annotated PDF as a new PDF. This should maintain the layout, fonts, etc.
With Xournal you'd choose "Annotate PDF", then use a solid black marker to mask the parts you want to redact, and "Export to PDF".
There are some stories on the internet suggesting that Xournal rasterises the text in the exported PDF (thanks for pointing this out, MHC). This does not seem to be true: with simple annotations, the text remains selectable and searchable and the file size does not increase by much (it increased from 205 kb to 220 kb in the example below).
To install, run in a terminal: sudo apt-get install xournal
or just select it from the Software Centre