1 Reply Latest reply on Sep 1, 2015 12:48 PM by JoelGeraci_Datalogics

    Toggling Layers in Adobe Acrobat




      I have created a PDF which has 5 layers.


      I want create a button that will make certain layers visible and hide others. I.e a button that will hide layer 1 and Layer 2,  and display Layer 3 and Layer 4, and vice versa. I believe there is a way to do this using java script, i'm just not sure how.


      I have had a look through the forums but can only find how to toggle between all the layers, rather than certain layers which  I need.


      Is there a way to do this?

        • 1. Re: Toggling Layers in Adobe Acrobat
          JoelGeraci_Datalogics Level 3

          A visible layer has a stat of true, hidden is false. The function below will let you call the layer by name and then set it's state.


          function getLayerByName(name){

              var ocgArray = this.getOCGs();

              layer = null;

              for (var i=0; i < ocgArray.length; i++) {

                  if (ocgArray[i].name == name) {

                      layer = ocgArray[i];




              return layer;




          getLayerByName('MyLayerName').state = false;