Skip to main content
Participant
May 21, 2024
Question

Interactive pdf for maps

  • May 21, 2024
  • 1 reply
  • 567 views

Hi,

I have a slight issue with making an interactive pdf file. I haven't made any before so i don't have too much knowledge about it. Simply i have a map with multiple layers exported from ArcGis Pro.  I want to make an interactive pdf from this file so the reader is able press a button on the file that will turn a layer off and on. The current feature only allows me to show one layer and will turn the others off. I want the reader to turn multiple layers on and off at the same time. How can i do this?

 

Thanks for your help in advance.

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
May 21, 2024

You can do it using this code:

 

 

 

var layerToShow = "Layer1";
var ocgArray = doc.getOCGs();
for (var i=0; i<ocgArray.length; i++)  {
	if (ocgArray[i].name==layerToShow) {
		ocgArray[i].state=!ocgArray[i].state;
		break;
	}
}

 

 

Edited: Removed incorrect return command.

 

Participant
May 21, 2024

Hi thanks for your quick response. I managed to make it work using the command i found from a video. 

The command is the follwing:

var docOCGs = this.getOCGs();
for (var i=0; i < docOCGs.length; i++)
{
if(docOCGs[i].name == "Text")
{
docOCGs[i].state = !docOCGs[i].state;
}
}