Skip to content

Instantly share code, notes, and snippets.

@chatchavan
Created November 14, 2022 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chatchavan/7b23b0c84cbda16eab92335faaa23465 to your computer and use it in GitHub Desktop.
Save chatchavan/7b23b0c84cbda16eab92335faaa23465 to your computer and use it in GitHub Desktop.
This script will adjust all PDF comment annotations by replacing the name of the creator in the comment metadata and content with a new name.

Anonymize PDF comments

This script will adjust all PDF comment annotations by replacing the name of the creator in the comment metadata and content with a new name.

Requirement

  • Adobe Acrobat Pro DC

Setup Adobe Acrobat Preferences

Under the JavaScript section, check the following:

  • Enable Acrobat JavaScript
  • Enable menu items JavaScript execution privileges
  • Enable interactive console
  • Show console on errors and messages

Usage

  • Press Cmd + J to open JavaScript Debugger
  • In the Console, paste the script
  • Adjust the variables oldAuthorName and newAuthorName
  • Select all script and press Cmd + Enter to execute
var oldAuthorName = "Max Mustermann";
var newAuthorName = "R1";
var annots = this.getAnnots();
if (annots!=null) {
for (i in annots) {
annots[i].author = newAuthorName;
var contentBefore = annots[i].contents;
var contentAfter = contentBefore.replace(oldAuthorName, newAuthorName);
annots[i].contents = contentAfter;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment