I use an IFrame to view a Pdf document when a link within that IFrame is clicked. However, on machines without the reader, the link will prompt for download. Is there a way, that the same link can prompt the user to download a reader when it detects no reader instead? I thought I have seen this somewhere. Thanks!
+1
A:
In JavaScript, can you do something like:
var adobePdfObject = new ActiveXObject("theAdobePdfCOMObject");
and then either catch a failure error or the return value of adobePdfObject?
PenFold
2009-08-12 06:53:30
This appear as if it is the most comprehensive approach, however, I am still struggling to make it work. Any spoon feeding would be most appreciated. I am interested in the http://dithered.chadlindstrom.ca/javascript/acrobat_redirect/index.html
Irawan Soetomo
2009-08-18 12:17:12
Could you provide some information on how this works? I feel like just providing a link without explanation is better than nothing, but still leaves something to be desired.
nont
2009-08-18 16:24:29
I've implemented the scripts on a couple of sites with no problems. And I do not see the need to replicate information from the site here when all relevant details are available on the site.
Jim
2009-08-19 08:56:27
+3
A:
This works for me in IE:
<script>
var p;
try {
p = new ActiveXObject('AcroExch.Document');
}
catch (e) {
// active x object could not be created
document.write('doesnt look like the PDF plugin is installed...');
}
if (p) {
document.write('does look like the pdf plugin is installed!');
}
</script>
Found it here. ..but modified to remove the "endif"
nont
2009-08-12 16:10:05
However crude with much activeX flaggings with MsIE, this seemed to be the working one.
Irawan Soetomo
2009-08-18 12:19:22
A:
I know this question had been answered already, but I recently had to build a function that detects PDF plug-in presence across different browsers. This is what I got. Hopefully if helps.
function hasPdfPlugin() {
//detect in mimeTypes array
if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0) {
for (i = 0; i < navigator.mimeTypes.length; i++) {
var mtype = navigator.mimeTypes[i];
if(mtype.type == "application/pdf" && mtype.enabledPlugin)
return true;
}
}
//detect in plugins array
if (navigator.plugins != null && navigator.plugins.length > 0) {
for (i = 0; i < navigator.plugins.length; i++) {
var plugin = navigator.plugins[i];
if (plugin.name.indexOf("Adobe Acrobat") > -1
|| plugin.name.indexOf("Adobe Reader") > -1) {
return true;
}
}
}
// detect IE plugin
if (window.ActiveXObject) {
// check for presence of newer object
try {
var oAcro7 = new ActiveXObject('AcroPDF.PDF.1');
if (oAcro7) {
return true;
}
} catch (e) {
}
// iterate through version and attempt to create object
for (x = 1; x < 10; x++) {
try {
var oAcro = eval("new ActiveXObject('PDF.PdfCtrl." + x + "');");
if (oAcro) {
return true;
}
} catch (e) {
}
}
// check if you can create a generic acrobat document
try {
var p = new ActiveXObject('AcroExch.Document');
if (p) {
return true;
}
} catch (e) {
}
}
// Can't detect in all other cases
return false;
}
xsaero00
2010-10-25 20:35:12