Is there a way to remove all PDF annotations (including highlights, comments, notes, arrows) in bulk (e.g., via command line)?
Asked
Active
Viewed 1,779 times
2 Answers
8
The following series of commands solved my problem:
pdftk original.pdf output uncompressed.pdf uncompress
LANG=C sed -n '/^\/Annots/!p' uncompressed.pdf > stripped.pdf
pdftk stripped.pdf output final.pdf compress
Rafael Beirigo
- 1,136
- 9
- 10
-
1Thanks! This worked for me, with the following modifications for `macos`: the `sed` command should be `LANG=C LC_ALL=C sed ...` (see [this answer](https://stackoverflow.com/a/23584470/4970632)), and `pdftk` should be downloaded via the `.pkg` file linked in [this answer](https://stackoverflow.com/a/39814799/4970632). – Luke Davis Aug 29 '18 at 06:43
-
2A faster (in-memory) way is to use a shell pipeline: ```sh pdftk in.pdf output - uncompress | sed '/^\/Annots/d' | pdftk - output out.pdf compress ``` – Farid Cheraghi Sep 27 '20 at 21:09
-
@FaridCheraghi it works on macOS M1. Very good – GoingMyWay Oct 01 '21 at 12:45
1
pdfcpu has a subcommand to remove annotations:
pdfcpu annotations remove my.pdf
Frederick Nord
- 1,166
- 1
- 12
- 30