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

Can I use "app.viewerversion" then close the PDF if needed?

Timmyb
Registered: Nov 19 2007
Posts: 25
Answered

Hi

I am designing forms using LiveCycle that require the user to have version 8 or above of Acrobat Reader in order for them to work correctly.

Can i assess the version they are using (app.viewerversion) then close the PDF if they are using a version older than 8?

If it is not possible to close the PDF, could I at least hide the sub-form if they are using an older version (so present user with a blank page + message)?

Any other ideas appreciated.

Thanks
Tim

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, you can detect the version and close the LiveCycle form with a script in exactly the same way its done with an AcroForm.

Use an event that is only called once when the PDF is opened, Like DocReady.

if(app.viewerVersion < 8)
event.target.closeDoc(true);


That's it

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

Timmyb
Registered: Nov 19 2007
Posts: 25
Thom

Thanks for this. I have implimented this but have read elsewhere that it does not work if the PDF is opened within a browser or another window.

Have you any smart ideas how this could be overcome?

Thanks
Tim
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
That's probably true. PDFs displayed in a browser have special restrictions on them. Give it a try, and if it doen't work you might want to go with your other strategy of hiding subforms. You can detect that the PDF is in a browser or other window with the "doc.external" property. Maybe something like this:

if(event.target.external)
{
<...Hide Stuff...>
app.alert("This PDF cannot be displayed in a browser window");
}
else if(app.viewerVersion < 8)
event.target.closeDoc(true);

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

Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
As we said here : reverse the issue to the other side.

Your script and Thomp's script will run ONLY in a JavaScript enabled software : Apple Preview and some Reader for Windows don't handle JavaScript, so nothing will happen…

Then you have to create something that display an alert in any case, except if displayed in version 9 (Reader or Acrobat).

See that sample : the 1st page (and the preview icon) is an alert (in french langage) for inviting end user to use Reader 9 or later version.
A document JavaScript detect if the software is Reader (or Acrobat) 9 or later, and ONLY in this case, go to the 2nd page where the "real" content is placed.

So, Reader 9 users will never see the first page (the alert), and all other users will see it an any case.

;-)

The sample file : http://abracadabrapdf.net/articles.php?lng=en&pg=594
(clic the yellow link to download)