I have created some forms that have multiple layers in them. They are several pages long. On page 1 there are 3 radio buttons . . . the user selects their appropriate user type and that turns on the correct layer and turns off the other layers. Unfortunately, if they go to page 2 before clicking one of the butttons, they see all of the layers at once, and it's a jumbled mess.
Is there a way to set the default layer visibility so that when you open the PDF, it shows only the layer I want it to? I can't find this in the initial view settings.
Thanks in advance for any help provided!
Yes, you can use a document level script to set the state of the OCG, Optonal Content Group or layer, objects intial states.
var nOCG = 0; // number of OCG to display
// set all OCGs off
var ocgs = this.getOCGs();
ocgs[0].initState.constants.states.off;
// turnon the one OCG for initial view
ocgs[nOCG].initState.constants.states.on;
Hi,
I'm finally getting around to using the script you so generously provided. Client sat on the project for months, and now they want it fixed.
I have 4 layers, or OCGs (sounds like that is what javascript calls them), named "Common", "Staff", "Supervisor", and "Manager" - and I would like the intial view to show the layers "Common" and "Staff" . . . how would I plug that into the script above?
Does javascript refer to the OCGs by name, or do they have numbers associated with them?
Here is my attempt - but really just a guess, and it did not work:
function InitialLayerView()
{
var nOCG = 1; // number of OCG to display
var nOCG2 = 2; // number of OCG to display
// set all OCGs off
var ocgs = this.getOCGs();
ocgs[0].initState.constants.states.off;
// turnon the two OCGs for initial view
ocgs[nOCG].initState.constants.states.on;
ocgs[nOCG2].initState.constants.states.on;
}
Also - once I close the script, save and reopen the file, should I have to do anything to run the script? I'm hoping it just runs on open.
Thanks for any help you can give!
North America
Europe, Middle East and Africa
Asia Pacific