Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Ruling out non-adobe viewers
  FAQ FAQ  Forum Search   Register Register  Login Login

Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Ruling out non-adobe viewers

 Post Reply Post Reply Page  12>
Author
zhirik View Drop Down
New Member
New Member


Joined: 04 Jun 2013
Points: 32
Post Options Post Options   Quote zhirik Quote  Post ReplyReply Direct Link To This Post Topic: Ruling out non-adobe viewers
    Posted: 17 Jun 2013 at 5:29pm
Hi guys,
 
I'd like to add a doc-level script (thru another script) that will check the viewer type, and if it neither Acrobat nor Reader, the document will close.
 
So I wrote:
 
...
this.addScript("CheckViewer", "var viewer = app.viewerType;\
     if(viewer !== \"Exchange-Pro\") && (viewer !==\"Reader\")\
     {app.alert(\"This Document Requires Adobe Reader or Acrobat Version 10 or Later.\");\
    this.closeDoc(true);}");
 
The script is correctly placed in the document, but the console notifies on syntax error on the line that comes after the script! But this line does not exist!
 
I also tried:
this.addScript("CheckViewer", "if(app.viewerType !== \"Exchange-Pro\") && (app.viewerType !==\"Reader\")\
     {app.alert(\"This Document Requires Adobe Reader or Acrobat Version 10 or Later.\");\
    this.closeDoc(true);}");
 
I guess, there is something wrong with  if(viewer !== \"Exchange-Pro\") && (viewer !==\"Reader\") part, but I can't figure out what the problem is.
 
I would appreciate your advice! Confused
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4113
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 17 Jun 2013 at 6:24pm

You also need to check for viewer "Exchange" and the viewer version.

if(viewer !== \"Exchange-Pro\") && (viewer !==\"Reader\")
 
 if(viewer !== \"Exchange-Pro\") && (viewer !==\"Reader\")
 
Should have both logical statements within parenthesis.
 
 if ( (viewer != \"Exchange-Pro\") && (viewer !=\"Reader\")  )
 
I would also use the "!=", not equal, and not the "!==", strict not equal, comparison.
 
Back to Top
zhirik View Drop Down
New Member
New Member


Joined: 04 Jun 2013
Points: 32
Post Options Post Options   Quote zhirik Quote  Post ReplyReply Direct Link To This Post Posted: 17 Jun 2013 at 9:19pm
Hi gkaiseril,

Thank you for your response and for the suggestions!

Could you please explain why it is better to use the "!=", not equal, and not the "!==", strict not equal?

Thank you in advance!

Originally posted by gkaiseril gkaiseril wrote:

You also need to check for viewer "Exchange" and the viewer version.

if(viewer !== \"Exchange-Pro\") && (viewer !==\"Reader\")
 
 if(viewer !== \"Exchange-Pro\") && (viewer !==\"Reader\")
 
Should have both logical statements within parenthesis.
 
 if ( (viewer != \"Exchange-Pro\") && (viewer !=\"Reader\")  )
 
I would also use the "!=", not equal, and not the "!==", strict not equal, comparison.
 
Back to Top
aandi View Drop Down
Senior Member
Senior Member


Joined: 07 Jul 2011
Points: 18358
Post Options Post Options   Quote aandi Quote  Post ReplyReply Direct Link To This Post Posted: 17 Jun 2013 at 11:34pm
Remember that non-Adobe viewers might have no JavaScript, or might return Exchange-Pro or Reader themselves; and that Adobe readers might have JavaScript off.
Back to Top
zhirik View Drop Down
New Member
New Member


Joined: 04 Jun 2013
Points: 32
Post Options Post Options   Quote zhirik Quote  Post ReplyReply Direct Link To This Post Posted: 18 Jun 2013 at 9:57am
Hi aandi,
 
You are right. Foxit, for example, completely ignores this script, even with Javascript enabled. And even of I set the app.viewerVersion to <10 (with Foxit 6 installed), the file is opened without any problem. Too bad..
 
Originally posted by aandi aandi wrote:

Remember that non-Adobe viewers might have no JavaScript, or might return Exchange-Pro or Reader themselves; and that Adobe readers might have JavaScript off.
Back to Top
zhirik View Drop Down
New Member
New Member


Joined: 04 Jun 2013
Points: 32
Post Options Post Options   Quote zhirik Quote  Post ReplyReply Direct Link To This Post Posted: 18 Jun 2013 at 10:05am
A small update: Foxit disguises itself as "Reader". The question is if it's possible to detect it as "Foxit" in any other way?
 
Thank you for your response in advance!
 
Originally posted by zhirik zhirik wrote:

Hi aandi,
 
You are right. Foxit, for example, completely ignores this script, even with Javascript enabled. And even of I set the app.viewerVersion to <10 (with Foxit 6 installed), the file is opened without any problem. Too bad..
 
Originally posted by aandi aandi wrote:

Remember that non-Adobe viewers might have no JavaScript, or might return Exchange-Pro or Reader themselves; and that Adobe readers might have JavaScript off.
Back to Top
aandi View Drop Down
Senior Member
Senior Member


Joined: 07 Jul 2011
Points: 18358
Post Options Post Options   Quote aandi Quote  Post ReplyReply Direct Link To This Post Posted: 18 Jun 2013 at 11:08am
By experiment, you could find something it doesn't do (and preferably isn't likely to do); try it; and deal with the exception. 
Back to Top
zhirik View Drop Down
New Member
New Member


Joined: 04 Jun 2013
Points: 32
Post Options Post Options   Quote zhirik Quote  Post ReplyReply Direct Link To This Post Posted: 18 Jun 2013 at 12:50pm
Hi aandi,
 
You are right - it seems to be the only way to do it. But it seems that Foxit can do everything that Reader does and even do it better. ;-)
 
Have a nice day!!!
 
Originally posted by aandi aandi wrote:

By experiment, you could find something it doesn't do (and preferably isn't likely to do); try it; and deal with the exception. 


Edited by zhirik - 18 Jun 2013 at 12:50pm
Back to Top
Rowan View Drop Down
Moderator Group
Moderator Group


Joined: 29 Jun 2011
Points: 82
Post Options Post Options   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Posted: 19 Jun 2013 at 12:50am
I daresay that Foxit pretends to be Adobe Reader in order to get around PDF files (produced by Adobe products) that contain JavaScript which prevents them from opening in anything but the latest version of Adobe Reader.

By the way, I'll say the same thing to you as I've said to Adobe, this is a bad idea and it breaks the Portable Document Format.
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4113
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 19 Jun 2013 at 5:08pm

ISO committee could add a metadata field like "ViewerVendor" property to the app object so one could tell whose product is being used, but this would only work for those programs/apps that add this item and not apply to older versions of programs/apps. It would take years for this to become a usable standard. And it could still be omitted and not be in non-conformity with the standard.

It might more helpful to know if the viewer is being used on a mobile device. But this is limited since not all mobile devices have or simulate JavaScript. 


Edited by gkaiseril - 19 Jun 2013 at 5:10pm
Back to Top
aandi View Drop Down
Senior Member
Senior Member


Joined: 07 Jul 2011
Points: 18358
Post Options Post Options   Quote aandi Quote  Post ReplyReply Direct Link To This Post Posted: 20 Jun 2013 at 12:19am
And, crucially, vendors could still lie about being some other piece of software if it suited them for any reason. It's very likely some would.
Back to Top
 Post Reply Post Reply Page  12>
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.063 seconds.