Skip to main content
johnk74519883
Participating Frequently
December 12, 2018
Answered

constant.states Security Issue

  • December 12, 2018
  • 2 replies
  • 740 views

I'm working in Acrobat X, but users are using a variety of Acrobat and Reader of every version. A client needed a PDF to ship with layers turned off, but be returned with layers turned on. After I added this to the script that displays the PDF results, then saved the PDF with Reader Extended PDF>Enable Additional Features:

if (layers.state == true){

layers.initState = layers.constants.states.on;

}else{

layers.initState = layers.constants.states.off;

}

...the regular PDF worked fine in Acrobat, but the Reader Extended version stops execution with the message:

Acrobat EScript Built-in Functions Version 10.0

Acrobat SOAP 10.0

NotAllowedError: Security settings prevent access to this property or method.

OCG.initState:11:Field Finalizar:Mouse Up

The error message tells us nothing, but when I comment out the lines that switch the constant.states status, the error goes away. But then the layers are not visible when the head office gets the PDF back.

I've looked this up in the Acrobat SDK, but constants.states does not seem to be a high-security command. Does anyone have an idea how to avoid the security problem, or how to change the layer visiblity without having to install a folder-level script on every damn user's computer? Thanks for any help.

This topic has been closed for replies.
Correct answer Bernd Alheit

Read this:

Re: Save layer state on close

2 replies

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
December 15, 2018
johnk74519883
Participating Frequently
December 17, 2018

Thanks to everyone for all the helpful information. In the end, the form already had scripts to show and hide the layers. I just had to re-read the selected dropdown data to reconstitute the form appearance. I wrote a folder-level script for the form administrator that makes the layers visible on her computer.

Inspiring
December 12, 2018

The initState property is read-only in Reader, so it's not able to set it. Reader-enabling document results in other restrictions that would normally work in Acrobat as well, template spawning for example, so it's probably the same type of thing. This is one reason why I'll typically use buttons instead of OCGs since there are fewer restrictions in Reader.

johnk74519883
Participating Frequently
December 15, 2018

Thanks for the information. Is is possible for Reader to run a folder-level script that will overcome this?

try67
Community Expert
Community Expert
December 15, 2018

No.