Batch remove comments from PDF files
How can I easily remove all comments and annotations (added with Foxit Reader) from all the PDFs in a folder?
I just came across this problem, and none of the answers given here worked for me. What did work was the rewritepdf
tool from the Ubuntu package libcam-pdf-perl
:
rewritepdf -C in.pdf out.pdf
Wrapping this into a little scripting to remove annotations from all pdf files in a directory is now easy:
for i in *.pdf; do rewritepdf -C '$i' '$i'.new; done
As usual, you can install libcam-pdf-perl
via the Software Center or using sudo apt install libcam-pdf-perl
Providing you're on a Unix system:
cd <directory containing PDFs>
find . -type f -name '*.pdf' -exec perl -pi -e 's:/Annots \[[^]]+\]::g' {} +
This is a hack that removes all /Annots
commands from the PDF (the commands that draws the annotations). It leaves the annotation objects there (you can open the PDF with a text editor and search for them), they're just not drawn.