Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the browsers' pdf viewer through program (e.g. HTML, JS, PHP )?

Goal : A browser base pdf viewer that has zoom and drag/ pan function (better if allow hiding the save function) to replace the browser default one

Problem : all browser (exclude old IE) has their own build in pdf viewer, that without dragging/pan function

Currently this code use 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 all browser (Chrome , FireFox , IE8+) using the adobe reader to open pdf file using javascript / jquery / html /php? Or are there any web base pdf viewer has the functions mentioned above?

Note:

For the first approach :

I found the way e.g. content-disposition : attachment

but it only change the behavior from viewing to download the pdf , not changing the preference in opening the pdf file

like image 284
user782104 Avatar asked Aug 21 '13 07:08

user782104


2 Answers

For approach 2: (Which I recommend) Check out:

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

PDF.js is Portable Document Format (PDF) viewer that is built with HTML5.

PDF.js is community-driven and supported by Mozilla Labs. Our goal is to create a general-purpose, web standards-based platform for parsing and rendering PDFs.

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

Approach 1 is inherently dicey due to security reasons

like image 66
Vrashabh Irde Avatar answered Sep 21 '22 01:09

Vrashabh Irde


The only way you can force it client-side is by supplying the alternative...such as pdf.js, zoho, google pdf viewer, scribd, etc (there are many). I'm not sure if Adobe provides an in-browser pdf viewer like you're expecting.

The default pdf viewer is kept in a variable found in about:config that can only be changed by the user.

like image 35
blakev Avatar answered Sep 21 '22 01:09

blakev