embedding pdf file within html with 100% width and height?

北城以北 提交于 2019-12-11 04:20:09

问题


I'm trying to embed a pdf document in html code, and I tried three different approaches, which actually gave me the same result:

<embed src="files/cv_aaragon_en.pdf" width="100%" height="100%">

<object data="files/cv_aaragon_en.pdf" type="application/pdf" width="100%" height="100%">
  <p>It appears you don't have a PDF plugin for this browser.
     No problem, you can still <a href="files/cv_aaragon_en.pdf">download the PDF file.</a></p>
</object>

<iframe src="files/cv_aaragon_en.pdf" width="100%" height="100%">

shown in the figure:

Now I have the following questions:

  1. The frames do not use the entire width of the page (which I believe is normal), because there is a lot of white space to both sides of the gray areas. This doesn't bother me.
  2. If the definition is set to width="100%", why is it not taking the full width? Why are there gray regions? This bothers me because the pdf should be larger so that it becomes readable.
  3. I could change the width, but I don't want to hard code its value so that the page looks good regardless of the device. Is there a way to obtain the actual width and put it in that width definition?
  4. The same with the height, I need it to be much larger, but I don't want to hard-code its value. How is this done?
  5. And finally, given the three approaches above, which one is the best in terms of loading speed?

Thank you.


回答1:


You can try adding a style tag:

<iframe style="position: absolute; height: 100%" src= "files/cv_aaragon_en.pdf" />


来源:https://stackoverflow.com/questions/16326445/embedding-pdf-file-within-html-with-100-width-and-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!