Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Closing Document if opened with Reader 7 or less

Avatar

Former Community Member
I have created a form in LCD version 8 that does not work properly in Reader versions 7 and less. Therefore, I added the check version script to the docReady event to put up a warning. That works correctly. However, I also want to close the document. I have found a script that works when using Reader version 8 (I changed the check for version less than 9)and it closes the document perfectly. However, when I check for less than version 8 and open the document in Reader version 7, the warning goes up correctly, but the document does not close.



This is the script I am using:



//check version of Acrobat

var appVer = app.viewerVersion;



if (appVer < 8)

{

var viewerMsg = "You are currently using Acrobat Reader version " + appVer + " .\n\n"

+ "This PDF document requires Acrobat Reader version 8.0 or later.\n\n"

+ "---------------------------------------------------------------------------------------\n\n"

+ "Please download and install the lastest version of Acrobat Reader from:\n\n"

+ "http://www.adobe.com/products/acrobat/readstep2.html";



xfa.host.messageBox(viewerMsg);

app.execMenuItem("Close");

}



I have also tried the script

event.target.closeDoc(true);

instead of the

app.execMenuItem("Close");

but that does not work either.



Any suggestions?
5 Replies

Avatar

Level 7
1. Make sure this isn't displayed in a browser, where documents can't

be closed internally.



2. Check out the JavaScript console/debugger.



Aandi Inston

Avatar

Former Community Member
It is not in a browser, just Acrobat Reader 7. Also, the script works in Reader 8 and Pro 8, so there is nothing to debug. The script simply does nothing in Reader 7 - no error message is shown.



Thanks,



Mark

Avatar

Level 7
When the script fails to work, in Reader, that is when you should be

looking at the console. I don't know how to open it in Reader, but I

believe it can be done.



Aandi Inston

Avatar

Former Community Member
Mark,



Amazing--I just went through an almost identical experience, down to testing the script in both 8 and 7, and having it work in 8 and not work in 7. I haven't found a solution yet either.



When you open the doc in Reader 7, do you get the two Adobe messages? I first get one that says "Some features may need a higher version of Reader" or words to that effect, and then a second one that says the user *must* upgrade (neither of those messages are mine--they are generated by Adobe).



Makes me wonder if the script doesn't work in 7 because Reader has decided the document is incompatible and disables it somehow. That's just a guess.



This issue probably isn't important enough on this project for me to pursue it any further--but if I were to pursue it further, I would probably try creating a plain-vanilla PDF document without any 8 features and seeing if the script worked when it was opened in Reader 7.



HTH, and please let us know if you find a solution!



Kathryn

Avatar

Former Community Member
Hi Kathryn,



I did not find a way to close the document so I decided to use a different approach. When the document is opened with version < 7, I used a script that loops through all the fields on each page and made them all read-only. Here's the script I used:



//check version of Acrobat

var appVer = app.viewerVersion;



if (appVer < 8 )

{

//loop through all pages



for (var i = 0; i < xfa.host.numPages; i++)

{

var oFields = xfa.layout.pageContent(i, "field");

var nodesLength = oFields.length;



//set the access type to be protected for all fields

for (var j = 0; j < nodesLength; j++)

{

var oItem = oFields.item(j);

oItem.access = "protected";

}

}



var viewerMsg = "You are currently using Acrobat Reader version " + appVer + " .\n\n"

+ "This PDF document requires Acrobat Reader version 8.0 or later.\n\n"

+ "---------------------------------------------------------------------------------------\n\n"

+ "Please close this form WITHOUT saving then download and install the lastest version of Acrobat Reader from:\n\n"

+ "http://www.adobe.com/products/acrobat/readstep2.html";



xfa.host.messageBox(viewerMsg);

}