Print Page | Close Window

Layer Control in Adobe Reader

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=191
Printed Date: 24 Apr 2019 at 11:04am
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: Layer Control in Adobe Reader
Posted By: drsebast
Subject: Layer Control in Adobe Reader
Date Posted: 30 Jan 2012 at 4:00pm
Is it possible to control the visibility of a layer in a pdf from a pushbutton control in that pdf?

I have a mapping pdf with 8 layers, each showing a different type of symbol.  The legend on the page shows all of the layers and symbols.  I would like to have a button (check box type would be great) next to each legend item to allow that layer to be turned off or on after clicking.

I am not familiar with javascript and was refered here by the Debenu Customer Service people so some code samples would be a great assistance.

Thanks in advance.
Don



Replies:
Posted By: drsebast
Date Posted: 30 Jan 2012 at 7:22pm
Thanks for the chance to post this question.  I overlooked the old forum and archive links above.  I did find a similar question and it had a script that I could modify.  Works fine.

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


I found it in the old forum in "JavaScripting in PDF's" by bk80.









Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net