Run javascript automatically on every PDF file opening
I have a script made in javascript that works well if I execute manually from each document.
But my need is to have this executing on each PDF file open automatically:
if (this.xfa !== undefined) {
app.alert({
cMsg: "Warning: This document contains a XFA form!",
nIcon: 2,
Title: "XFA Document Detected" });
} else {
app.alert({
cMsg: "This is a normal PDF.",
nIcon: 3,
Title: "Normal PDF"
});
}When I have this script on javascript folder (C:\Program Files\Adobe\Acrobat DC\Acrobat\Javascripts), it doesn't work as expected and there are two behaviours happening:
- It always goes no "else" condition, even if the file contain XFA form, I guess that happens because "this.xfa" condition is not met. I tried to find in Adobe Acrobat SDK the reference alternatives but I couldn't find a way of solving/finding the reference.
- If I already have a file opened and try to open a second file, nothing happens. I guess because the script is only valid triggered at Adobe Acrobat startup and I should have a way of listening an event for "file open" action but also I couldn't find any information regarding this.
I'm trying to arrange a solution for a customer that has an issue regarding PDF's that contain LiveCycle XFA forms and while Adobe doesn't provide an option to deal with PDF with XFA forms. I already suggest in Adobe's UserVoice platform.
I would like to hear from some expert if there is anyway of achieving this or if I'm in a dead spot.
Thank you!
