• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to use Javascript to detect a signed Acrobat document?

Explorer ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Hi,

 

BACKGROUND:

I am using an Action Wizard in Adobe Acrobat Pro DC to automatically label a batch of pdf's. It has various steps: JavaScript (Initial Error Trapping) > Remove Hidden Information >  Reduce File Size > Save to "Prepped" Folder > Add Header & Footer > JaveScript (Adding incremental labels to all documents in "Prepped" Folder so if there are 4 documents, it will label them in sequence as EX01, EX02, EX03, and EX04).

 

REQUEST:

1) I need to bring up an error message for the user when a signed pdf is detected in the batch b/c once we upgraded to Adobe Acrobat Pro DC, such files are skipped and therefore, not processed. I researched this and found it is b/c a signature in the pdf makes it so "Changing the Document" is not allowed.

Note: In my example, Document 3 is the signed pdf and all the processing steps above are skipped and the file is not saved in the "Prepped" folder.

 

I tried the following to alert the user of a signed pdf but it did not work.

 

       if (securityhandler == null) {app.alert(event.target.documentFileName + " is signed and cannot be         labeled. It will be skipped.");}

 

2) As an added bonus, it would be great if you could give me an idea on how I can up the numbering by one once a signed pdf is detected (Can I just add "+1" to the iteration of "global.iteration++"?). Right now, the signed document is skipped and the next document gets assigned its number such that the numbering is off.

Note: In my example, Document 3 is the signed pdf and all the processing steps above are skipped and the file is not saved in the "Prepped" folder. Document 4 instead is labeled as EX03 instead of EX04.

 

Thanks so much!

Sue

TOPICS
Acrobat SDK and JavaScript

Views

7.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 19, 2022 Jul 19, 2022

Try it with this code:

 

var isSigned = false;
for (var i=0; i<this.numFields; i++) {
	var fname = this.getNthFieldName(i);
	var f = this.getField(fname);
	if (f==null) continue;
	if (f.type=="signature" && f.value!="") {isSigned = true; break;}
}
if (isSigned) app.alert("This document is signed.");

 

The securityHandler property is for document encryption, not for signatures.

Votes

Translate

Translate
Community Expert ,
Jul 19, 2022 Jul 19, 2022

Copy link to clipboard

Copied

"I don't know how to deploy this in my action wizard. Can you advise?"

 

1.

Capture_580.png

 

2.

Capture_582.png

 

3.

Capture_583.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines