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

Save Layer visibility for next open

bobmcjob
Registered: Jan 5 2011
Posts: 3

I have an amendable/Editable PDF form that i'm working on and the top has 3 sections. Only one section can be filled out. All are hidden by default and triggered by 3 buttons. When one is clicked 2 are hidden and the selected one is shown.
 
Each section has a few form fields. These two are hidden/shown depending on the checkbox shown.
 
My issue is when you fill out 1/3 sections and save it, the PDF won't save the selected layer. It saves the from fields and shows them upon reopening, however the layer underneath is not shown. If you select the checkbox corresponding to the filled in fields it shows, but I need it to show be default if the fields in that section are filled out.
 
From my research so far the only way of doing this is to put a javascript function that runs on Document open to see if any fields have values, then show the correct layer accordingly.
 
However there must be a better way in Acrobat to setup the layers so their default state is updated and visible on open, if it was saved as visible.
 
Example of form:
 
[VISIBILE]
1)
- Field 1
- Field 2
- Field 3
 
[HIDDEN]
2)
- Field 1
- Field 2
- Field 3
 
[HIDDEN]
3)
- Field 1
- Field 2
- Field 3

My Product Information:
Acrobat Pro 9.2, Windows
bobmcjob
Registered: Jan 5 2011
Posts: 3
Figured it out.

Used Javascript to hide/show the 3 sections and field groups associated with those sections.

Then on document Open ran an if statement which finds which section had it's radio button checked when it was last save, if any, and then displays the correct fields and layer for that section.


riles9
Registered: May 23 2011
Posts: 1
Over the past few days I learned how to make forms using Adobe Acrobat for a project I'm working on and have ran into this same problem. I googled it, and your post is the only place I have found that references this particular issue. I do not currently know JavaScript, though now that I will be creating more forms it is something that I will be learning. However, for the time being I was really hoping that you wouldn't mind posting the JavaScript that you used to remedy this situation!

If you can do that, it would be very much appreciated.

Thanks for your time!

-nate
bobmcjob
Registered: Jan 5 2011
Posts: 3
Hey Nate,

Here is what i've been able to dig out. Been a while since i've done one now.

Each checkbox has the following JS, on Mouse Up:

var aOCGs = this.getOCGs();
aOCGs[2].state = true;
aOCGs[3].state = false;
aOCGs[4].state = false;

this.getField("a").display = display.visible;
this.getField("b").display = display.hidden;
this.getField("c").display = display.hidden;

The visible & true items change depending on what checkbox you click on.Then on Page Open I run this JS (sectionA etc. are the names of my layers):

if (cb1 == "sectionA") {
aOCGs[2].state = true;
} else if (cb1 == "sectionB") {
aOCGs[3].state = true;
} else if (cb1 == "sectionC") {
aOCGs[4].state = true;
}