Copy link to clipboard
Copied
Hi all,
on
https://acrobatusers.com/tutorials/creating-and-using-layers-ocgs-with-acrobat-javascript
Thom Parker describes, how to make hidden layers visible in the layers palette with the JS-Code:
this.getOCGs();
But how can I make the layer name in the layers palette invisible again? What is the JavaScript-Code so that I can do it vice versa or that I can undo it?
I can't find anything about this in the literature.
Thanks for a helpful tip,
Yosimo
Copy link to clipboard
Copied
That code doesn't do anything on its own. It just retrieves the array of OCGs (layers) in the file.
To make a specific layer visible (or invisible) you need to access it via that array and then change its state property to true or false, resp.
I believe it's all explained in that tutorial you found.
Copy link to clipboard
Copied
I don't want to make a specific layer invisible. I want to make the layer name in the layers palette invisible.
If I place a watermark with the watermark function of Acrobat, then I can make the layer name in the layers palette visible with the JS-code
this.setOCGOrder(this.getOCGs()); // (and not: this.getOCGs(); sorry, I was wrong)
But what is the code to make the layer name in the layers palette invisible again?
Copy link to clipboard
Copied
That code doesn't have anything to do with showing the layers palette or making a layer's name in it hidden or visible. It just sets the order of the layers (to the current order, which is useless).
As far as I know, it's not possible to do any of those things using a script.
Copy link to clipboard
Copied
Too bad, I was hoping I could do it with JS.
Thank you very much.
Copy link to clipboard
Copied
The point is you can have an OCG that doesn't show up in the list, such as when you add a watermark. The code:
this.setOCGOrder(this.getOCGs())
has the effect of making the OCG names that aren't visible in the Layers pane visible, which then allows a user to manipulate it via the user interface.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now