13

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>
Patrick
  • 328
  • 1
  • 2
  • 9

4 Answers4

11

Does Adobe's document 'Parameters for opening PDF files' help you?

According to that document, something like

<object data="/path/to/file.pdf" type="application/pdf">
    <param name="view" value="Fit" />
</object>

could work, or even

<object

   data="/path/to/file.pdf#toolbar=1&amp;navpanes=0&amp;scrollbar=1&amp;page=3&amp;view=FitV"
   type="application/pdf">

   <p>It appears you don't have a PDF plugin for this browser. 
      No problem though... 
      You can <a href="/path/to/file.pdf">click here to download the PDF</a>.
   </p>

</object>
Kurt Pfeifle
  • 86,724
  • 23
  • 248
  • 345
  • 1
    Excellent thought, but alas, neither method works. I did make sure to specify the "page" parameter first, as noted in the documentation. – Patrick Aug 13 '12 at 17:15
  • So it doesn't work with neither browser?!? And it doesn't even display the sentence in `

    ...

    ` markup?
    – Kurt Pfeifle Aug 13 '12 at 17:25
  • The PDF displays fine, and in IE9 the text displays as it should (because IE is generally terrible and won't display a PDF on a page like this without some extra wizardry), but the document is not being "zoomed" or "fit" as directed by the parameters passed. Basically both methods of passing the parameters are failing. – Patrick Aug 13 '12 at 18:52
  • 1
    @Patrick: But this is the most authoritative answer you can ever get on this topic. If IE9 doesn't implement this, then... well. – Kurt Pfeifle Sep 10 '12 at 12:02
5

See demo here http://jsfiddle.net/6TNrw/68/

The above works if the pdf viewer object is adobe.

Google chrome has its own pdf viewer so changing its zoom parameter wont work for that.

<object data="http://www.nclabor.com/wh/faqs.pdf?#view=fitH" 
 type="application/pdf" 
 width="100%" height="100%">

    <param name="view" value="fitH" />

</object>  
h2ooooooo
  • 39,111
  • 8
  • 68
  • 102
  • What do you mean `if the pdf viewer object is adobe`? How does browser know which is which? Also adding `param` doesn't seem to make a difference for me. – Dan Sep 18 '14 at 15:48
  • @Dan, he is talking about the browser plugin. If you are using Adobe Reader plugin, it works but if you are using Chrome, which has it's own pdf viewer, it does not work. – PersyJack Oct 02 '14 at 15:18
4

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.

Community
  • 1
  • 1
Johannes
  • 41
  • 3
1

Another late answer (looks like we're on a 2-year cycle...)

I found that setting the parameter #zoom=Fit finally did the trick. This is only in FF so far. Chrome is laughing at every parameter I feed it.

Note that the documentation states that view gets the Fit values, but zoom is the one that seems to do anything with them.

I hope this helps someone down the line.

targetcreature
  • 107
  • 1
  • 7