Skip to content

Instantly share code, notes, and snippets.

@timothyclemansinsea
Last active January 13, 2016 20:33
Show Gist options
  • Save timothyclemansinsea/40f83565a87e1ee2212d to your computer and use it in GitHub Desktop.
Save timothyclemansinsea/40f83565a87e1ee2212d to your computer and use it in GitHub Desktop.
// This script is free open source code copyright by Timothy A. Clemans 2016 licensed under AGPL
app.addToolButton({cName: "RedactStuffMarkedForRedaction", cLabel: "Redact Stuff Marked for Redaction", cEnable: "event.rc = (app.doc != null);", cExec: "redact(this);" });
var redact = app.trustedFunction( function(doc){
app.beginPriv();
var isRedact = false;
for(var page=0;page<doc.numPages;page++){
for (var i=0;i<doc.getPageNumWords(page);i++){
if (doc.getPageNthWord(page,i)=='startredact'){
isRedact = true;
} else if (doc.getPageNthWord(page,i)=='stopredact') {
isRedact = false;
} else if (isRedact) {
doc.addAnnot({type:"Redact",page: page,quads: doc.getPageNthWordQuads(page,i),overlayText: "",alignment: 1,repeat:false});
}
}
}
//If you want the script to apply redactions itself then uncomment next line
//doc.applyRedactions({bKeepMarks: false,bShowConfirmation: false,cProgText: ""});
app.endPriv();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment