Skip to main content
Inspiring
August 17, 2016
Question

Make layers name in the layers palette invisible

  • August 17, 2016
  • 1 reply
  • 610 views

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

This topic has been closed for replies.

1 reply

try67
Community Expert
August 17, 2016

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.

yosimoAuthor
Inspiring
August 17, 2016

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?

Inspiring
August 17, 2016

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.


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.