How to view a pdf using iframe from my website?

拥有回忆 提交于 2019-12-24 10:31:47

问题


I have pdf files on my website that I would like to show on a page , I tried :

<iframe src="https://mywebsite.com/files/file.pdf" frameborder="0" width="600" height="550" style="margin:0px; padding:0px;"></iframe>

but the file is downloaded.

I tried using google drive :

<iframe src="https://drive.google.com/viewerng/viewer?embedded=true&url=http://mywebsite.com/files/file.pdf" ></iframe>

But I get the html of my login page , I think it automatically redirects to login page.

and I tried to use iframe to access the folder that contains the file:

<iframe src="https://mywebsite.com/files" ></iframe>

But I get forbidden message that tells me to edit my file permissions .

-Is there is a specific permission that I could use to access the folder or the file?

-Is there is a library , function in any web developing language or anything that could help?


回答1:


You can use something like this to accomplish your task:

https://github.com/mozilla/pdf.js

PDF.js is a Portable Document Format (PDF) viewer that is built with HTML5.



来源:https://stackoverflow.com/questions/48717851/how-to-view-a-pdf-using-iframe-from-my-website

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