I am viewing PDF into iframe. It works fine. But some of the client don't able to see it in IE. They get it as download option.
How can I identify if browser has pdf viewer or not and prompt user that he hasn't pdf viewer?
Note: I am using asp.net mvc 5 (c#).
I tried this, but don't help me. The problem with me some of the client has Adobe PDF, so no issue for below answer. But those who have nitropdf or chrome pdf viewer, below answer don't help me. I want to idenitify all pdf viewer. otherwise if client has some kind of pdf viewer then also alert will be display that no pdf viewer is installed. And that's wrong thing.
I applied this code by getting help from عبد النور التومي's answer and it worked for chrome and mozilla. Here is the js I modified.
But IE still not respond to it. I don't know how to check in IE that it has pdf viewer or not. For IE, I'm getting following error though there is pdf viewer is there:
PDF format is a licensed adobe format, from my understanding it's probably not always going to be reliable detection if you need to account for all non-licensed PDF readers also.
However, there is this resource: http://www.pinlady.net/PluginDetect/PDFReader/
The basic idea is:
"application/pdf"
in the browser'snavigator.mimeTypes
arraynavigator.mimeTypes
array test fails, a second test is run in the background (i.e. nothing shown to the user on the frontend) which sends the browser a lightweight "empty" pdf file to see if it can be interpretedOf course the idea of running a test pdf in the background might be a costly solution (i.e. mobile users on 3G etc.) but it's probably going to be a pretty reliable method, and the good part is you only have to test your user once when they reach your domain and then set a
cookie
orlocalStorage
item with their pdf config saved so you don't have to keep testing their pdf capability.I tried following solution by taken help from عبد النور التومي, which helps for any pdf viewer in chrome and mozilla
And I got following error for IE, Though I have pdf viewer installed in my browser.:
Then I solved it by this link.
Then I add new condition for IE 11
trident
and now it works fine. Also I added option to check forfoxit reader
. you can add another pdf reader name also in or condition.As an alternative, you can use a library like viewer.js to display your pdf in a container.
see http://viewerjs.org/
There is a JS solution :
Known that API getAcrobatInfo is :