Skip to main content
Participating Frequently
July 4, 2023
Answered

Help with Javascript for Adobe Acrobat

  • July 4, 2023
  • 1 reply
  • 937 views

Hi

I have no JS knowledge but tried this out by reading examples online + using chatgpt

i have a very crude JS. It is doing what i was trying to achieve, that is, to redact header and footer of all PDF i have selected.

 

In acrobat, i created an Action, select all the files i want to redact. But when i run this script, it keeps showing this JS script and i have to keep clicking ok to run it + it keeps prompting me to "Save as" the file as PDFname_redacted.pdf. Can i seek some pointer how can i tune the script such that when i run it, i just redact the PDF i have selected without the need to keep clicking anything ? Thank you

/* My Script */

var qd = [[39, 813, 557, 813, 39, 757, 557, 757]]; // Quad coordinates
var qd1 = [[38,88,559,88,38,42,559,42]]; // Quad coordinates


var numPages = this.numPages; // Total number of pages in the PDF

for (var pgNum = 0; pgNum < numPages; pgNum++) {
this.addAnnot({
type: "Redact",
page: pgNum,
quads: qd,
overlayText: "Deleted",
alignment: 1, // Center alignment
repeat: true
});
this.addAnnot({
type: "Redact",
page: pgNum,
quads: qd1,
overlayText: "Deleted",
alignment: 1, // Center alignment
repeat: true
});
}

this.applyRedactions({ bKeepMarks: false, bShowConfirmation: false, cProgText: "Deleted" });

 

This topic has been closed for replies.
Correct answer Thom Parker

I think you can disable it via Edit - Preferences - Security (Enhanced).


I think this might be a protected mode issue.  Make sure it's turned off. 

 

 

1 reply

try67
Community Expert
Community Expert
July 4, 2023

Click the Execute JavaScript command in the Edit Action window and tick off the Prompt User check-box.

Also, make sure to add a Save command to your Action, but keep in mind that Redactions can't be reversed, so maybe save the files under a new name, just in case something goes wrong...

Participating Frequently
July 4, 2023

Thank you so much for your help. Yes, I managed to follow your advice and

1) turned off the prompt

2) auto save as filename_Redacted.PDF

 

though there is still a "Security Warning"  saying it requires write access to the file system, it is only 1 click of a button which is ok for me.

 

try67
Community Expert
Community Expert
July 4, 2023

Can you post a screenshot of that message?