Flatten PDF annotations

5

There is a similar question, but the answers fail to solve the problem of "flattening" annotations, i.e. turning them from annotations into actual content.

One way is to print them to PDF, but that can result in a loss of quality, especially of scanned images in the PDF. Is there a way to achieve this, preferably using a Linux command line tool like pdftk that can preserve everything in the PDF as-is and only adds the annotations as content?

Thomas W.

Posted 2016-03-01T17:26:56.893

Reputation: 308

Answers

1

The accepted answer on the same question, How can I totally flatten a PDF in Mac OS on the command line? seems to work for me to "bake in" or "flatten" PDF annotations as PDF content:

gs -sDEVICE=pdfwrite -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out.pdf input_with_annots.pdf

... and it even seems to preserve the annotation text (so it is copypastable, along with the original text content).

Tested this on Ubuntu 14.04, Ghostscript gs --version 9.10.

sdaau

Posted 2016-03-01T17:26:56.893

Reputation: 3 758

This solution preserves image quality for uncompressed images, but JPEGs get re-encoded, which I'd want to avoid. – Thomas W. – 2017-11-29T13:14:22.940

This does not work with stamps. – Bruni – 2019-08-08T08:11:38.653