如何在我的网站上使用iframe查看pdf? [英] How to view a pdf using iframe from my website?
问题描述
我的网站上有要显示在页面上的pdf文件,我尝试过:
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>
但文件已下载.
我尝试使用Google驱动器:
I tried using google drive :
<iframe src="https://drive.google.com/viewerng/viewer?embedded=true&url=http://mywebsite.com/files/file.pdf" ></iframe>
但是我得到了登录页面的html,我认为它会自动重定向到登录页面.
But I get the html of my login page , I think it automatically redirects to login page.
我尝试使用iframe访问包含该文件的文件夹:
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?
-是否有一个库,使用任何Web开发语言的功能或任何可能有用的功能?
-Is there is a library , function in any web developing language or anything that could help?
推荐答案
您可以使用类似的方法完成任务:
You can use something like this to accomplish your task:
https://github.com/mozilla/pdf.js
PDF.js是使用以下内容构建的可移植文档格式(PDF)查看器: HTML5.
PDF.js is a Portable Document Format (PDF) viewer that is built with HTML5.
这篇关于如何在我的网站上使用iframe查看pdf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!