Centering embed PDF content

前端 未结 1 1817
我寻月下人不归
我寻月下人不归 2021-01-16 19:22

I have a PDF file embed inside my web page. My HTML is:


My CSS is:

emb         


        
相关标签:
1条回答
  • 2021-01-16 19:41

    You can control the height and width via CSS like such:

    <style>
        embed {
            width: 100%;
            height: 500px;
        }
    </style>
    

    You also control it via attributes in the embed tag like such:

    <embed src="http://znaci.net/zb/4_1_19.pdf" width="640" height="480">
    

    As for the zoom, you can achieve this by doing the following (note the #zoom=75):

    <embed src="http://znaci.net/zb/4_1_19.pdf#zoom=75">
    

    This syntax worked in IE11 and FF32, but not in Chrome 38.


    Edit: Answer to the centering part of the question:

    Centering the PDF only fails in Chrome. A work around for this can be to replace the embed tag with an iFrame like such (though I don't think this is the best practice).

    <iframe src="http://znaci.net/zb/4_1_19.pdf"></iframe>
    

    Alternatively, you can look at some thing like pdf.js.

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