Ubuntu – How to flatten comments using okular

okularpdf

Recently Okular has become a great tool to annotate pdfs.

I have added some annotations (stamps) using okular to a pdf. I would like these annotations to become flat. By flat I mean that they are no longer selectable and deletable so that they are not distinguishable from the original pdf.

A Bug report has been filed on the KDE bugtracking system.

Best Answer

Poppler PDF library can do this - Okular and Xournal++ use it internally. The poppler-utils package comes with a pdftocairo utility. So the following is just another way to do it in the terminal instead of using a GUI application. Run the following command

pdftocairo -pdf "input.pdf" "output-with-flatten-annotations.pdf"

and your annotations will be flatten/"baked" into the PDF.

But as this more or less a PDF to PDF conversation, some differences may apply, e.g. Poppler considers your fontconfig resulting in font replacements and the internal structure of the PDF may be altered. Please be aware that using poppler-cairo in this context may result in larger PDF output files.


You might also want to try qpdf (another utility and package that is not poppler-related) as that utility does not do an entire PDF conversation.

$ qpdf --flatten-annotations=all input.pdf output.pdf

Please mind that there is also print and screen as argument value for --flatten-annotations= instead of all that includes both print and screen. Check qpdf --help for more information. As the output for help is pretty long, you might want to use a pager like less, e.g.

qpdf --help | less