I am creating a new field for each word in my pdf and giving action for each button using Acrobat Pro, My problem is I am unable to get the value of the button that has been clicked. Here is my code
var numWords = this.getPageNumWords(0);
for ( var j = 0; j < numWords ; j++) {
var nThWord;
var cScript;
nThWord= this.getPageNthWord(0, j);
var wrdRect = this.getPageNthWordQuads(0, j);
if (nThWord != '') {
cScript = "app.alert(nThWord);";
console.println(nThWord);
var fldRect = [];
fldRect[0] = wrdRect[0][4];
fldRect[1] = wrdRect[0][5];
fldRect[2] = wrdRect[0][4] + 3;
fldRect[3] = wrdRect[0][5] + 3;
var oFld = this.addField(nThWord, "button", 0, fldRect);
if (oFld != null) {
oFld.buttonSetCaption("");
oFld.borderStyle = border.s;
oFld.fillColor = color.gray;
oFld.textColor = color.white;
oFld.lineWidth = 1;
oFld.setAction("MouseUp", cScript);
}
}
}
PS: The JS API says setAction() function does not work in Adobe reader but I tested in Adobe reader 11. I was able to execute setAction() function.