Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initial Zoom Parameter for PDF Object in HTML5

Tags:

html

pdf

I am building a page that will display a PDF file on the page. When viewing this page in Chrome, the zoom level is set by default so that the document is wider and taller than the allotted space. Safari seems to have a preferable default of fitting the page to the available space, just FYI.

I would like to know if there are any parameters that can be set in <object> to force the initial zoom level of the document. It might be name=initZoom with values like "fitToPage" or "fitToWidth" or "70" (for 70% zoom). It might look something like this:

<object data="/path/to/file.pdf" type="application/pdf">
    <param name="initZoom" value="fitToPage" />
</object>
like image 603
Patrick Avatar asked Aug 13 '12 16:08

Patrick


People also ask

How do you embed a PDF in HTML?

Using an iframe tag is the second way to embed a pdf file in an HTML web page. In web development, web developers use the iframe tag to embed files in various formats and even other websites within a web page. Due to its wide compatibility, the iframe tag is widely used for embedding pdf.

How do I make an embedded PDF responsive?

I'll keep this quick. All you need to do is add #view=fitH to the end of the source attribute. That's it!

How do I display the contents of a PDF in HTML?

The easiest way to put PDF in an HTML document is using the <a> tag with its href attribute. You need to add the URL or the reference link of your PDF file to the element.


1 Answers

Adding a late answer since none of the existing ones worked for me, and someone might need it.

Instead of adding '#view=fitH' or '#view=fitV' to the pdf url, which didn't work for me, i got it working by adding '#zoom=scale', like this:

<object data="/path/to/file.pdf#zoom=scale" type="application/pdf">
</object>

Hope this helps someone, and sorry for any inconvenience.

EDIT: Found more parameters here. Found the link in this thread, which is basically the same question as this.

like image 82
Johannes Avatar answered Sep 28 '22 16:09

Johannes