How to show/hide single layers in browser with JavaScript?
Hello,
I've been beating my head against Adobe's JavaScript API (JavaScript APIs — Acrobat-PDFL SDK: JavaScript Reference) trying to figure out how to do what appears to be a very rudinmentary thing, show and hide specific layers in a PDF in a browser window. I created a map in Illustrator and used layers such that each one shows a single location. When it is opened in a browser window I want my JavaScript to show a specific layer as determined by a onmouseover event. However, I cannot get any layer to show with the file open in Acrobat using the console. I have to say that the API isn't very helpful, most aren't, but I have tried a number of times with no success in getting one specific layer to display on top of the bottom layer. Here is my current code and console output:
var layers = this.getOCGs();
var cnt = layers.length;
cnt
layers[400].name;
layers[400].getIntent;
layers[400].initState;
layers[400].state = true;
undefined
undefined
477
F1
function getIntent() {
[native code]
}
false
true
I was successful in creating a watermark as instructed by one of Thom Parker's tutorials, but havenot been able to display one layer with JavaScript using the API or any of his other tutorials. I assume that the API is intended to work in a browser, which may be wrong. If the API is not intended to allow me to show and hide layers in a browser, then Adobe should be very clear about this, because, well, why have layers? If the API is intended to provide the means to show and hide a PDF's layers in a browser window, then it should provide clearer information about how to use the API to do that as it doesn't.
Jeff
