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

Detect PDF Context

IgnacioLirio
Registered: Oct 10 2011
Posts: 4
Answered

Hi fellows,
 
I am trying to detect which is the context the user is viewing one PDF file. Could be Reader, Acrobat, inside a web browser, in Mac OS van be using the Preview App, etc.
 
The goal is to get to know the capabilities of the environment, to check if that PDF will be played at full capability.
 
I used the app.viewerVersion, app.viewerType, etc. and works fine BUT...
 
When I play a test PDF in the context of a web browser like Google Chrome or Safari in MacOS , I got a message as I am viewing the PDF into Acrobat Pro 9 (my version), at its full extent, like:
 
app.viewerVersion = 9 , app.viewerType="Exchange-Pro" (=Acrobat) , and so on, but I cannot for instance play Video Clips in this context.
 
I also tried doc.media.canPlay ... and no luck. The PDF gives me the SAME message inside Acrobat Pro or Safari, and it is clear that inside a Web Browser I cannot play video clips embedded in a PDF.
 
So it looks that, when the PDF is viewed inside a web browser that allows display PDF instead of download them, the same PDF javascript cannot tell if he is inside a web browser or inside Acrobat Pro X.
 
Any ideas? Thanks!
 
Ignacio

My Product Information:
Acrobat Pro 9.3, Macintosh
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Accepted Answer
Look at the "external" document property to tell whether it's being viewed inside a browser. Also, note that Preview does not support JavaScript in PDFs.
IgnacioLirio
Registered: Oct 10 2011
Posts: 4
Thanks George, this is exactly what I was looking for and your help was 100% useful.

I am aware that I cannot run Javascripts in Preview, so what I did was to present the PDF with a text field with a default value that says "Please open this PDF with Acrobat". If you opened that PDF inside Acrobat o Reader, this.external=TRUE and then a Javascript runs that changes the value of that text field and replaces with "OK" or just Blank, so it works.

Thanks you very much again George.

Ignacio

Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
Ignacio:

you can also create a "dumb page one" that says "Please open this PDF with Acrobat", and execute a Document-JavaScript that goes to page 2 only if Acrobat or if Reader.
There is a sample here, clic the yellow link to download the PDF: http://abracadabrapdf.net/articles.php?lng=fr&pg=589
Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
You can also use a layer, as in this nice demo PDF: http://windjack.com/DownLoads/LicenseDialogExample_Sec.pdf

;-)
Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
I can't place 2 URLs in the same message because lines are concatenated…
Why ?
IgnacioLirio
Registered: Oct 10 2011
Posts: 4
Thanks for your contribution, Merlin. Both ideas are great. I finally chose the one I mentioned above, and I made a new post in my blog to explain it:

http://www.publicarendigital.com/2011/10/script-para-comprobar-si-un-pdf-se.php

It is in spanish, but you can Google-translate it , if you want. It has a link to the PDF sample with the script.

Thanks !
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
The formatter on these forums has been "quirky" for a while, when it detects HTML tags it loses the automatic formatting of line breaks in that paragraph. Don't know if/when it'll be fixed, but editing the post doesn't help.

Merlin wrote:
I can't place 2 URLs in the same message because lines are concatenated…
Why ?
Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
IgnacioLirio wrote:
http://www.publicarendigital.com/2011/10/script-para-comprobar-si-un-pdf-se.php
For videos and SWF files there is another effortless tip: place the alert text as any text in any usual PDF file, then put the video over.
That's all…
;-)

Here is a sample file, clic the yellow link to download this nice multimedia PDF: http://abracadabrapdf.net/articles.php?lng=fr&pg=807
Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
UVSAR wrote:
The formatter on these forums ...
Thanks UVSAR!
IgnacioLirio
Registered: Oct 10 2011
Posts: 4
Thanks Merlin, but yet Google Chrome, when displaying PDF with embedded video files, it shows the poster image so I am not sure if this solution of just placing Video Above would work for that particular case...
Merlin
Acrobat 9ExpertTeam
Registered: Mar 1 2006
Posts: 766
IgnacioLirio wrote:
but yet Google Chrome, when displaying PDF with embedded video files, it shows the poster image…
Thanks, I wasn't aware of that…
;-)