How to change browser viewer through a program (e.g. HTML, JS, PHP)?

Purpose: a database viewer in a browser that has the zoom and drag / pan function (better if you enable hiding the save function) to replace the standard version of the browser

Problem: the entire browser (excluding the old IE) has its own pdf built-in to the viewer, without the drag / pan function

This code currently uses the default PDF viewer:

<object id = 'zoomPage' type='application/pdf' data= '1.pdf'> <p>The PDF can not display </p> </object> 

Is it possible to force the entire browser (Chrome, FireFox, IE8 +) to use Adobe Reader to open a pdf file using javascript / jquery / html / php? Or is there any web-based function for viewing PDF functions that has the functions mentioned above?

Note:

For the first approach:

I found a way, for example. content-disposition: attachment

but this only changes the behavior from viewing to download pdf without changing preferences when opening a PDF file

+6
source share
5 answers

For approach 2: (what I recommend) Departure:

 https://github.com/mozilla/pdf.js/ 

PDF.js is a Portable Document Format (PDF) program that is built using HTML5.

PDF.js is community supported and supported by Mozilla Labs. Our goal is to create a universal, web-based platform for parsing and rendering PDF files.

EDIT: For your speed needs, check out the discussion of other options here: Recommended way to embed PDF in HTML? and see if other options match your requirements.

Approach 1 is essentially security-related.

+7
source

The only way to get it on the client side is to provide an alternative ... e.g. pdf.js, zoho, google pdf viewer, scribd, etc. (a lot of them). I'm not sure if Adobe provides a built-in PDF viewer as you expect.

The PDF viewer is stored by default in a variable found approximately in: config, which can only be changed by the user.

+2
source

Is it possible to force all browsers (Chrome, FireFox, IE8 +) to use Adobe Reader to open a pdf file using javascript / jquery / html / PHP?

You can try this using an iframe pointing to a pdf file. The browser will automatically open the pdf file using the software to read PDF files on the client machine. Like this:

 <iframe src="yourpdffile" style="width:100%;height:500px"></iframe> 
+1
source

you cannot force something on the client for a security problem, but you can check something like this . My previous sentence follows the experience that I have in browsers and encoding, but maybe I can say something wrong.

  • You can control if Adobe Reader uses javascript and code that checks to see if there is a Reader installed with a script like this (I used these lines a few months ago and they work)

  • Try using this plugin, which may be pumping for you (link of the first sentence).

+1
source

You can also use google docs viewer to achieve this functionality.

Just follow this link: https://docs.google.com/viewer

You can get the iframe url and put it on your site.

 <iframe src="http://docs.google.com/viewer?url=http%3A%2F%2Fwww.yoursite.com%2Fpdf%2Ftest.pdf&embedded=true" width="600" height="780" style="border: none;"></iframe> 

note that the value parameter of the url parameter in src is equal to url encoded .

Check out the JS Fiddle example here

0
source

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


All Articles