How to view a pdf using iframe from my website?

2019-08-06 04:58发布

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条回答
啃猪蹄的小仙女
2楼-- · 2019-08-06 05:33

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.

查看更多
登录 后发表回答