Automating Selected Area Redaction on Multiple Files
Hello all,
I'm an intermediate macro-writer but most of my experience has been in vB in Excel, so JS is a bit unfamiliar to me. Apologies if I'm missing something obvious, and any help is appreciated. The task I'm wanting to complete is:
- Identify Scope (Multiple 1-page, identically arranged PDFs)
- Open First File
- Prompt User to draw a Redact Area around some coordinates
- Apply Redactions
- Loop through the remaining documents, applying redaction to the same area.
So far I've been trying to stitch together a few tutorials/pieces of sample code but I'm getting stuck a lot earlier in the process than I expected, hence my reaching out. The code I'm working with is from the below:
https://acrobatusers.com/tutorials/auto_redaction_with_javascript
https://acrobatusers.com/tutorials/apply_security_with_js
https://acrobatusers.com/tutorials/folder_level_scripts
But I can't even get the first pieces of sample code to run exactly as-is on the sample file provided. For the below:
// Part 1: Quads for the different Redaction areas
var qdFirstName = [[0, 195, 179, 195, 0, 181, 179, 181]];
var qdLastName = [[182, 195, 397, 195, 182, 181, 397, 181]];
var qdAdress = [[-1, 172, 273, 172, -1, 158, 273, 158]];
var qdCityState = [[-1, 172, 273, 172, -1, 158, 273, 158]];
var qdSocSec = [[400, 193, 527, 193, 400, 179, 527, 179]];
var qdAlow = [[471, 132, 529, 132, 471, 109, 529, 109]];
var qdExempt = [[413, 72, 529, 72, 413, 60, 529, 60]];
// Part 2: Function for adding Redact Annotations to a PDF function
AddMyRedacts(quadList) {
for(var pg=1; pg<this.numPages; pg++) {
for(var index=0; index<quadList.length; index++) {
this.addAnnot({
type:"Redact", page:pg,
quads:quadList[index],
overlayText: ":It's gone:",
alignment: 1, // center alignment
repeat:true });
}
}
}
// Part3: Applying the redactions
// Code for two different redaction schemes
// Use only one per document
// #1 Run this code to apply redactions to W4 employee name
// and address
AddMyRedacts([qdFirstName, qdLastName, qdAdress, qdCityState, qdSocSec] );
this.applyRedactions({bKeepMarks: false, bShowConfirmation: true, cProgText: "It's going away" });
// #2 Run this code to apply redactions to W4 exemption
// information
AddMyRedacts( [qdAlow, qdExempt, qdSocSec] );
this.applyRedactions({ bKeepMarks: false, bShowConfirmation: true, cProgText: "It's going away" });
When I try to run the first and second piece, it errors immediately with:
SyntaxError: missing ; before statement
10:Console:Exec
undefined
And, being somewhat unclear on the syntax, this is where I'm stuck. Working on Acrobat Pro DC 10. The name of the PDF file is important, otherwise I would simply combine them and then "Apply Mark Across Pages" to redact in one fell swoop.
