Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I had to print a couple of PDFs recently to send to someone, but I wanted to redact (black out) a couple small bits of text.

A quick google search didn't turn up any tools for this specific purpose, so I fell back to imagemagick & gimp:

  • convert document.pdf document.png
  • gimp document-0.png
  • (use paintbrush to black out text)
  • print redacted page from gimp
  • print remaining pages from xpdf

The problem with this strategy is that the conversion process (from PDF to PNG or whatever other format) loses quality. I tried editing the PDF in gimp but it didn't work right away.

Is there a specific tool that permits redaction in this way? (It doesn't even need to be "real" redaction -- I'm not sending a softcopy so "fake" redaction will work because the hardcopy can't be hacked to reveal the underlying text.)

Or, is there a trick to being able to edit PDFs in gimp?

share|improve this question
1  
PDF is scalable, PNG is raster graphics, which is probably why there is quality loss in the conversion process. Convert to a scalable format instead, such as SVG. –  Anonymous Oct 27 '11 at 19:28
    
@Anonymous: Nice idea, but not usable. The resulting SVG file is massive; I had to -KILL the viewer after 30 minutes and a GiB or so of memory consumption. –  bstpierre Oct 27 '11 at 20:35
add comment

9 Answers

up vote 7 down vote accepted

(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 ...
share|improve this answer
1  
+1 and accepted! Thanks for suggesting inkscape, it did a reasonable job (not perfect -- it lost a couple of (unimportant to me) graphic objects) -- but very reasonable). And the tip on convert was good too: the incantation I used was convert -density 300x300 and there's no loss of quality. –  bstpierre Oct 27 '11 at 23:37
    
+1 for mentioning GIMP can handle pdfs quite well –  don.joey Dec 20 '12 at 12:09
3  
Warning to the general populace: the redaction methods here that involve retaining text suggested here (e.g. all the ones that avoid rasterisation) are not secure. Text can still be selected from under blackouts, or read from the source of the file. See for example freerepublic.com/focus/f-news/2706743/posts and hackaday.com/2008/08/01/exposing-poorly-redacted-pdfs –  naught101 Jun 12 '13 at 2:43
    
Although the original question asked about sending hardcopy only, for which nonrasterizing methods are acceptable, downvoting since this answer does not clearly enough warn about the security risk when distributing the result electronically. –  Jesse Glick Feb 3 at 16:45
1  
@JesseGlick: instead of "punishing" me for not addressing a use case not even mentioned in the original question, you could've just edited the answer. That would be more beneficial for the future visitors. –  Sergey Feb 3 at 20:29
show 1 more comment

The best way I have found to do this is to use http://www.pdfescape.com. You can annotate, add text and images, draw a "whiteout" rectangle around stuff you want to redact, and you can quickly download and save it. It also works really well with multi-page documents, which is something that lots of other solutions don't work well with. For example, if you open a multi-page document in Gimp or Inkscape, you will only be able to open one page at a time. The process is much faster in PDFescape. The whole process for me to redact a 2-page document takes less than a minute.

share|improve this answer
add comment

Basically what you are trying to do is highlighting/annotating 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 PDFs?

One of the highest rates 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

Xournal interface Resulting exported PDF

share|improve this answer
    
Xournal is good but you have to know that it can only export raster PDFs meaning that all text and vector information is lost in the process. If you can deal with that then Xournal is the application of your choice. –  Glutanimate Apr 20 '13 at 3:45
1  
Thanks for the feedback, @MHC. Xournal does not rasterise, see revised answer for more information. –  Tomas Apr 21 '13 at 3:02
1  
I just tried it for myself and you're absolutely right. Sorry for the confusion. It had been a while since I had used Xournal and somehow I was left with the impression that the exported documents weren't true PDFs. Thanks for setting that straight! –  Glutanimate Apr 21 '13 at 16:13
add comment

PDF Studio is a non-opensource and is software that requires purchasing.

In terms of this question, from version 8 onwards it has a manual redaction feature. Users can select a text object and redact it. The content is removed from the PDF and replaced with a black rectangle.

In version 9 coming third quarter 2013, redaction annotations and burning will be also available for images and shapes.

share|improve this answer
3  
Per the faq, you should disclose your affiliation with the product you are promoting. –  bstpierre Apr 20 '13 at 2:14
    
Even though this is likely more of a promotional ad than an answer I have to say that PDFstudio really is a great piece of software. It might be a tad bit overpriced but it's certainly the best PDF editing suite for Linux out there. Make sure to at least try their trial version out. –  Glutanimate Apr 20 '13 at 3:57
add comment

I remember one time me and a colleague had to find a way to edit a couple of pdf, We ended up using Gimp. I will comment you the details ... we open the pdf directly with gimp (in a terminal)

gimp the_file.pdf

Once you are finished editing, we did not save the changes, instead of that we print in to pdf file ... That seemed to work ok.

share|improve this answer
    
For whatever reason, gimp refuses to allow me to make any edits to the file. I had to convert with imagemagick's convert first, then edit the converted file. (See accepted answer.) –  bstpierre Oct 27 '11 at 23:38
    
ok, the solution of inkscape is valid. But I repeat to you The Gimp can edit pdf files directly. =D –  maniat1k Oct 28 '11 at 11:55
    
Gimp seems to work with most PDF files, but the file I was using last night didn't work correctly. Inkscape handled that file properly. –  bstpierre Oct 28 '11 at 13:18
add comment

You could also try this tool: https://launchpad.net/updf

Here it is (but anyway, the text is selectable):

enter image description here

share|improve this answer
1  
uPDF is great in that it preserves the original PDF and its text and svg content. However, it appears to have some problems with compression levels. Edited PDFs are about 3-4x larger in size than the original. Thank you for posting this, though. I wasn't aware of uPDF. –  Glutanimate Apr 20 '13 at 4:39
    
Yes I know it has some problems, it's a bit rough. Hopefully newer releases will correct these issues... :) –  franzlorenzon Apr 21 '13 at 16:37
add comment

Use LibreOffice Draw for that quick editing that you are looking for. After you are done you can save it as LibreOffice Draw format or export it again to PDF format (File>Export as PDF)

enter image description here

To be able to import PDF files in to LibreOffice Draw you must first install the package libreoffice-pdfimport.

Install it via the Ubuntu Software Center (libreoffice-pdfimport Install libreoffice-pdfimport) or via a terminal with sudo apt-get install libreoffice-pdfimport.

share|improve this answer
add comment

There are multiple editors for editing PDF documents directly, such as pdfedit, or converter it to other vector formats that might be better supported, such as pstoedit. However I wouldn't recommend the use of any of them as the risk of doing something stupid, like just painting over the text with black while leaving the vectors in place is to easy, thus making the redaction trivial to undo.

Going the vector to bitmap route is the safest way, preferably the 1bit bitmap route, to avoid any potential issues with alpha channels or color differences that could leave the text readable.

If possible you should always redact the original document and just flat out remove the info, not the paint on the PDF, as even the kerning and spacing of text around the redacted text can give it away.

share|improve this answer
    
I understand the issues with redacting properly, but thank you for taking the care to point them out for anyone who comes along after. In my case, the PDF itself is disposable -- all I'm looking for is a hardcopy. (The PDF will be deleted as soon as I'm have hardcopy.) FWIW, pdfedit did not work: when I drew a black rectangle over the text in question, it nuked the rest of the page, leaving me with a document consisting of a single black rectangle. –  bstpierre Oct 27 '11 at 23:24
add comment

Open the PDF with the free tool PDF-Xchange PDF Viewer. Black out the text to be redacted using black rectangles. Print. That will get you easy, high-quality "fake" redaction.

share|improve this answer
    
That appears to be a win32 tool. Let me know if I missed the link for the linux port... –  bstpierre Oct 27 '11 at 20:47
3  
The free portable PDF-Xchange viewer will work with wine. –  Sabacon Oct 27 '11 at 23:27
    
Thanks, this worked perfectly for me with wine. The inkscape and gimp solutions are only really useful for single page redactions. –  Gearoid Murphy Nov 10 '12 at 15:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.