Initial Zoom Parameter for PDF Object in HTML5

前端 未结 4 844
执念已碎
执念已碎 2020-12-30 08:59

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 th

相关标签:
4条回答
  • 2020-12-30 09:11

    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.

    0 讨论(0)
  • 2020-12-30 09:14

    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>  
    
    0 讨论(0)
  • 2020-12-30 09:21

    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>
    
    0 讨论(0)
  • 2020-12-30 09:21

    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.

    0 讨论(0)
提交回复
热议问题