Reputation: 969
due to some unavoidable reasons I need to disable Google Chrome's "Chrome PDF Viewer" and enable the adob PDF viewer. I want to do this from C#.net and asp.net Code. I know it is not possible directly as it is related to change setting's on a client machine but I am ready to ask permission from user if s/he wants to disable the default viewer.
The reason behind this work is that all my PDFs created in iTextSharp are not functioning properly in Google Chrome due to Chrome's default reader. Not all user's can find and disable the plugin manually, hence I want it to be done by code. I need to know that how we can disable the default PDF viewer. AFter this my problem will be solved automatically. pls give me any suggestion about code
Upvotes: 5
Views: 5375
Reputation: 11
I use iTextSharp, and Chrome was causing issues when both the Chrome PDF and Adobe were enabled. The submit button would send FDF data back to the server even though the form specified sending the data as XFDF. Setting ContentType to "application/vnd.adobe.pdfxml" solved the problem.
Kudos to PAEz.
Upvotes: 1
Reputation:
Google chrome plugins doesnot change the programming way so just inform to the client like a pop up message
<script type="text/javascript">
function CheckPlugin()
{
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
function findPlugin(ext) {
var thisExt, findExt;
for (var n = 0; n < navigator.plugins.length; n++) {
//alert("n value"+ navigator.plugins.length);
for (var m = 0; m < navigator.plugins[n].length; m++) {
//alert("m length:"+navigator.plugins[n].length);
thisExt = navigator.plugins[n][m].description.toLowerCase();
// alert("this exten"+thisExt);
findExt = thisExt.substring(0, thisExt.indexOf(" "));
//alert("findexes"+findExt);
if (findExt == ext)
return (true);
}
}
return (false);
}
if (is_chrome ==true) {
//alert("chrome browser");
if (findPlugin("acrobat")) {
//alert("Adobe Acrobat pdf viewer");
return true;
}
else {
alert("please disable the chrome pdf viewer and enable the Adobe Acrobat PDF viewer \n Please follow the steps:\n 1.Open the new tab 'chrome://plugins/' type the Address. \n 2. Click the Enable link in 'Adobe Acrobat' field. \n 3. click the Disable link in 'Chrome PDF Viewer'. \n 4. Close the tab and you can open the PDf files in chrome browser.");
return false;
}
}
else {
//alert("not chrome");
}
}
</script>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/PDFFiles/AGENCY PROFILE APP.pdf" onclick="return CheckPlugin();">Agency profile app</asp:HyperLink>
I think it is more help full.
Upvotes: 1
Reputation: 8542
Aslong as your embedding the pdf in a html file the following might work for you....
Try changing the type
of the embed to type="application/vnd.adobe.pdfxml"
, I know this isnt what your serving but when I tried it on a normal pdf the plugin didnt choke and showed the pdf using Adobes plugin without having to disable the default (Chromes) reader.
I had to test this on a version of the Adobe plugin that is a bit old as Im on dialup and couldnt be bothered downloading a 50 something meg file just for testing ;). So you should test it on the newest plugin.
Hope it works out for you.
EDIT:
Heres an example page of how to make the pdf take up the full screen like if you just pointed straight to the file...
http://pdfobject.com/markup/examples/full-browser-window.html
...its also the page I did my test on.
Upvotes: 2