These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Programmatically set a Layer's Visibility to "Visble When On"

dotnetwiz
Registered: Jun 8 2010
Posts: 57
Answered

Anyone know how to programmatically set a PDF layer's initial state visibility to "Visible When On"?

I'm using the following code to add the layers:

this.addWatermarkFromFile(
{
cDIPath : "/C/Users/Wiz/Temp/Begin.pdf",
bOnTop : true,
bOnScreen : true,
bOnPrint : false,
});

Setting bOnScreen to true results in "Always Visible" and setting it to false results in "Never Visible". Questoin is, ow do I set it to "Visible When On" using script?

My Product Information:
Acrobat Pro Extended 9.3.1, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Can't be done through scripting. It has to be manually or through a plug-in. Although if you wrote a plug-in for this you could automate it through JavaScript

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

dotnetwiz
Registered: Jun 8 2010
Posts: 57
Thanks Thom, I was hoping there was a parameter for the "Visible When On" option, but it helps to know that there isn't one.

I may have to figure out how to go about writing plug-ins--I'm a relative newbie to PDF scripting. I'm not even sure if one writes a plug-in in Javascript or if there's a separate API for plug-in development.

In any case, I've benefitted greatly from all your training resources. You're definitely one of a handful of gurus in this area. :)

Cheers!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Acrobat Plug-ins are written in C++. You'll need Visual Studio 2005 or better, good programming skills, and lots of time to learn about the PDF format and the Acrobat SDK. You can read more about it in the Acrobat SDK documentation at www.adobe.com/devnet/acrobat.

Like many other aspects of Acrobat scripting, its a bit dissapointing that they went to the trouble to add in all the OCG features that they did and left this vital part out. The difficulty in usability and ease of implimentation between a JavaScript solution vs a plug-in solution is huge. It's infuriating that they would leave such big holes like this in the JavaScript SDK, and there are quite a few of them.

However, I have written a plug-in for manipulating OCG Layers in ways that are not provided by the Acrobat user interface. I did not write it to be automated though. I'll have to think about doing this. It's a members download at [url=http://www.pdfscripting.com/public/programs/downloadsearch.cfm?StartRow=16&searchtype=simple&searchmode=cat&keywords=All%20Files%20in%20Automation%20Tools%20Category&cat=Automation%20Tools&sortby=name]pdfscritping.com[/url]Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

dotnetwiz
Registered: Jun 8 2010
Posts: 57
Thanks Thom. While I've done a fair amount of coding in C++, my current PDF "project" is not significant enough to warrant developing a plug-in for.

The reason why I've needed this functionality was because I'm implementing a UI within Acrobat using layers and fields, turning them on and off as needed. If the OCG/layer is set to "Always visible" things get screwed up when the user hits F4 (inadvertently or otherwise) and invokes the Navigation Pane. I believe this is a bug in Acrobat.

In any case, I'm going to look into creating a UI using Flash, so these issue will become irrelevant in the longer run.

Thank you again for your thoughts and your mentorship.

Cheers!