Skip to content

Instantly share code, notes, and snippets.

@xiaoouwang
Forked from alexschreyer/extractComments.js
Created August 29, 2020 19:31
Show Gist options
  • Save xiaoouwang/08af79718799845fb42a9801f71e41a1 to your computer and use it in GitHub Desktop.
Save xiaoouwang/08af79718799845fb42a9801f71e41a1 to your computer and use it in GitHub Desktop.
Extract comments from Acrobat PDF
// Get all annotations in current document
var annots = this.getAnnots();
// Assemble them into a Tab-delimited string (remove linebreaks in comments, too)
var cMyC = "Comment\tPage";
for ( var i=0; i<annots.length; i++ )
cMyC += ("\n"+annots[i].contents.replace(/(\r\n|\n|\r)/gm,"")+ "\t" + annots[i].page);
// Export them to MS Excel (opens the data there)
this.createDataObject({cName: "myCommentList.xls", cValue: cMyC});
this.exportDataObject({cName: "myCommentList.xls", nLaunch: 1});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment