Script to automate the function of buttons
Hello, I have written a script that assigns each button the visibility of 2 levels. The script works fine but when I reopen the PDF the function no longer works.
I have many languages in the pdfs I create and I usually use the set visibility level action in the button properties, but I wanted to automate this. How can I do this?
In the attached code I have only inserted 2 layers
var livBase = "Base";
var livIT = "Italiano";
var livEN = "Inglese";
var pulsanteEN = this.getField("INGLESE");
pulsanteEN.setAction("MouseUp", "livelloInglese()");
var pulsanteIT = this.getField("ITALIANO");
pulsanteIT.setAction("MouseUp", "livelloItaliano()");
function livelloInglese() {
var ocgs = this.getOCGs();
for (var i in ocgs) {
ocgs[i].state = (ocgs[i].name === livEN || ocgs[i].name === livBase);
}
}
function livelloItaliano() {
var ocgs = this.getOCGs();
for (var i in ocgs) {
ocgs[i].state = (ocgs[i].name === livIT || ocgs[i].name === livBase);
}
}
