JavaScript done in Adobe Pro DC not executed in Adobe Reader DC
Hello all, I am posting this request on the forum, as I need help!
I am building a form that will be shared with customer to request an access to a web portal. I want this form to be a PDF with field, and once the fields are populated by the customers, by the click of a button, the fields are lock (to prevent modification), a watermark is applied and the form is send using the default web application.
I'm using Adobe Pro DC (version 2021.007.20099). With Adobe Pro DC, I created a simple form that contains a JavaScript that is executed when the end user click on a button. The script is provided below for convenience. (I am not a JavaScript or an Adobe expert, I just copied/pasted and re-arranged pieces of code I found here and there on the Internet...). When I execute the form using Adobe Pro DC, everything works as it should be and I am very happy with this!
However, when I open the form with Adobe Reader DC (version 2021.007.20099), the script doesn't full execute. The dialog box opens, but the watermark is not applied, and the email is not sent. However, the fields within the form are correctly "locked". So, I see that as only some items in this script are executed, but not all of them.
In Adobe Reader DC, I checked thatt I have JavaScript enabled (Edit/Preferences/JavaScript).
If anyone can help me, or point me in the right direction, that would be great! Thank you!
Julien
var nRslt = app.alert ("Do you want to continue, lock and send this form to the pre-registered email address?\n -Yes, to open the default email application and generate the email.\n -No, to return to the form.", 2, 2);
if(nRslt == 4) {
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f==null) continue;
f.readonly = true;
}
var cMyText = "Generated on " + util.printd("yyyy/mm/dd", new Date);
this.addWatermarkFromText({
cText: cMyText,
cFont: "Helvetica-Bold",
nFontSize:10,
aColor: color.red,
nHorizAlign:app.constants.align.left,
nHorizValue: 457, // from left
nVertAlign:app.constants.align.bottom,
nVertValue: 737, // above bottom
});
this.addWatermarkFromText({
cText: "Access Request",
nTextAlign:app.constants.align.center,
cFont: "Helvetica-Bold",
nFontSize:50,
aColor: color.blue,
nStart: this.pageNum,
nRotation: 45,
nOpacity: 0.1,
bOnScreen: true
});
var cToAddr = "john.doe@somewhere.com"
var cCCAddr = this.getField("Email").value;
var cSubLine = "Access Request"
var cBody = "Thank you for submitting your form.\n" +
"Save the filled form attachment for your own records.\n" +
"We will contact you soon.\n" +
this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCCAddr, cSubject: cSubLine, cMsg: cBody});
}else{
app.alert ("exit",2)
}
