Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zoom to fit: PDF Embedded in HTML

Tags:

html

object

pdf

I am embedding a local pdf file into a simple webpage and I am looking to set the initial zoom to fit to the object size. Here is what I tried but it is not affecting the zoom.

 <embed src="filename.pdf?zoom=50" width="575" height="500"> 

does anyone know how to modify the code so its initial zoom is set to fit the object size.

like image 460
user3024833 Avatar asked Dec 13 '13 08:12

user3024833


People also ask

How do I zoom a PDF in HTML?

#zoom=50 or #page=2&zoom=300 work perfectly both in chrome and IE. IE only seems to be responding to #view=Fit. More IE params here: partners.adobe.com/public/developer/en/acrobat/… I had a multiple page PDF and #zoom=100 worked for me.

Can you embed PDF in HTML?

HTML's object tag is the first way to embed PDF files. In the below example, the pdf file will be displayed on a web page, which is an object. In addition to embedding a pdf file into a webpage, the object tag can embed ActiveX, Flash, video, audio, and Java applets.

How do I view a PDF in HTML?

To embed the PDF in the HTML window, point the page to a document and then specify the height and width of the PDF so the HTML window is the correct size using the code: <embed src="filename. pdf" width="500" height="375">. Note that an embedded PDF may look very different on different browsers and operating systems.

How do I embed a PDF in a Web page?

One popular option is that you upload the PDF file to an online storage service, something like Google Drive or Microsoft's OneDrive, make the file public and then copy-paste the IFRAME code provided by these services to quickly embed the document in any website.


2 Answers

Bit of a late response but I noticed that this information can be hard to find and haven't found the answer on SO, so here it is.

Try a differnt parameter #view=FitH to force it to fit in the horzontal space and also you need to start the querystring off with a # rather than an & making it:

filename.pdf#view=FitH 

What I've noticed it is that this will work if adobe reader is embedded in the browser but chrome will use it's own version of the reader and won't respond in the same way. In my own case, the chrome browser zoomed to fit width by default, so no problem , but Internet Explorer needed the above parameters to ensure the link always opened the pdf page with the correct view setting.

For a full list of available parameters see this doc

EDIT: (lazy mode on)

enter image description here enter image description here enter image description here enter image description here enter image description here

like image 187
Rich Avatar answered Sep 18 '22 08:09

Rich


For me this worked(I wanted to zoom in since the container of my pdf was small):

    <embed src="filename.pdf#page=1&zoom=300" width="575" height="500"> 
like image 21
nazbouy Avatar answered Sep 21 '22 08:09

nazbouy