How to strip comments and annotations from a lot of PDF documents

The fastest way to solve it is to use pdftk, which is also available on macOS M1. Pdftk is free and easy to use.

Open the terminal and type

$ LC_CTYPE=C && LANG=C
$ pdftk in.pdf output - uncompress | sed '/^\/Annots/d' | pdftk - output out.pdf compress

You can find the out.pdf without any comments and annotations.

Next, you can list all the files and process them with shell scripts.

To use the commands above, you can replace the in.pdf and out.pdf with your PDF files.

Cheers!

References

  • https://stackoverflow.com/q/20804441/5046896
  • https://stackoverflow.com/a/49614525/5046896