Display Adobe pdf inside a div

前端 未结 9 728
南旧
南旧 2020-12-01 04:59

I have a pdf file that the user has to see and click on the \"I agree\" button. How do you display a pdf inside a div?

相关标签:
9条回答
  • 2020-12-01 05:32

    Yes you can.

    See the code from the following thread from 2007: PDF within a DIV

    <div>
        <object data="test.pdf" type="application/pdf" width="300" height="200">
            alt : <a href="test.pdf">test.pdf</a>
        </object>
    </div>
    

    It uses <object>, which can be styled with CSS, and so you can float them, give them borders, etc.

    (In the end, I edited my pdf files to remove large borders and converted them to jpg images.)

    0 讨论(0)
  • 2020-12-01 05:32

    Here is another way to display PDF inside Div by using Iframe like below.

    <div>
      <iframe src="/pdf/test.pdf" style="width:100%;height:700px;"></iframe>
    </div>
    <div>
      <!-- I agree button -->
    </div>

    0 讨论(0)
  • 2020-12-01 05:34

    You can use the Javascript library PDF.JS to display a PDF inside a div. The size of the PDF can be adjusted according to the size of the div. You can also setup event handlers for moving to next / previous pages of the PDF.

    You can checkout PDF.JS Tutorial - How to display a PDF with Javascript to see how PDF.JS can be integrated in your HTML code.

    0 讨论(0)
  • 2020-12-01 05:35

    You could create an image thumbnail, and link it to the actual pdf as an inline popup using something like http://orangoo.com/labs/GreyBox/

    0 讨论(0)
  • 2020-12-01 05:36

    I think its not working, because you z-index property not applied on pdf(any outside object). So when you add any control in PDF view boundary,its appear behind of pdf view.

    0 讨论(0)
  • 2020-12-01 05:37

    I don't think you can. You may need to use an Iframe instead.

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