Hey I'm using buttons to show/hide multiple layers in Acrobat with javascript. How do I save a new PDF with my selection of layers showing? Every time I save a PDF the layers are back to hidden by default. Here's the javascript I use for my button action
var docOCGs = this.getOCGs();
for (var i=0; i < docOCGs.length; i++)
{
if (docOCGs[i].name == "Badge Tab")
{
docOCGs[i].state = !docOCGs[i].state;
}
}
Appreciate the help.
Set the "initState" property. However, this only work in Acrobat Pro.
var docOCGs = this.getOCGs();
for (var i=0; i < docOCGs.length; i++)
{
if (docOCGs[i].name == "Badge Tab")
{
docOCGs[i].state = !docOCGs[i].state;
docOCGs[i].initState = docOCGs[i].state;
}
}
For a strategy that work for Reader you'll need to store the state on the form. For example, in a hidden text field. Then a document level script can be used to setup the OCG states when the PDF is opened.