How to disable Google Chrome "View PDF Chrome files" with Asp.net

due to some unavoidable reasons I need to turn off Google Chrome "PDF Viewer in PDF" and turn on the PDF viewer. I want to do this from C # .net and asp.net code. I know that this is not possible directly, since it is related to setting up the change on the client machine, but I am ready to ask the user if he / she wants to disable the default viewer.

The reason for this work is that all my PDF files created in iTextSharp do not function properly in Google Chrome due to the default reading in Chrome. Not all users can find and disable the plugin manually, so I want this to be done using code. I need to know how we can disable the default PDF viewer. Take this, my problem will be solved automatically. Pls give me any suggestions about code

+6
source share
3 answers

Google chrome plugins doesn't change the way you program, so just let the client know as 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> 

In a hyperlink, write this:

 <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/PDFFiles/AGENCY PROFILE APP.pdf" onclick="return CheckPlugin();">Agency profile app</asp:HyperLink> 

I think this helps more.

+3
source

In addition to your embedding the pdf file in the html file, the following may work for you.

Try changing the embedding type to type="application/vnd.adobe.pdfxml" , I know that this is not what your service is, but when I tried it on regular pdf, the plugin did not suffocate and showed pdf using the Adobes plugin, without the need to disable the standard (Chromes) reader.
I had to test this on the version of the Adobe plugin, which is a bit outdated, like Im on dialup, and could not be bothered downloading a 50 MB file for testing only;). Therefore, you should test it on the latest plugin.
Hope this works for you.

EDIT:
Here is an example page on how to make a pdf file in full screen mode, for example, if you just pointed directly to the file ...
http://pdfobject.com/markup/examples/full-browser-window.html
... its also the page on which I performed my test.

+2
source

I use iTextSharp, and Chrome causes problems when both PDF and Adobe are included. The submit button will send the FDF data back to the server, even if the form is specified to send the data as XFDF. Setting ContentType to "application / vnd.adobe.pdfxml" solved the problem.

Kudos to PAEz.

+1
source

Source: https://habr.com/ru/post/911080/


All Articles