在没有 Adobe Reader 的情况下将 pdf 文件显示到浏览器中
我需要在没有 Adobe Reader 的情况下在浏览器中打开 pdf 文件。是否有 PHP 的 API 可以在浏览器中打开 PDF 文件。
问候
I need to open pdf file into browser without Adobe Reader. Is there any API with php which open PDF files into browser.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不会
。PHP 在服务器上运行。它可以访问的唯一“浏览器 API”是 HTTP。
如果你想在客户端渲染PDF,那么客户端需要一个PDF渲染器。有 JavaScript PDF 阅读器,但我无法评论他们的交叉 -浏览器支持或成熟度。
No.
PHP runs on the server. The only "browser API" it has access to is HTTP.
If you want to render a PDF on the client, then the client needs a PDF renderer. There are JavaScript PDF readers, but I can't comment on their cross-browser support or maturity.
您可以使用 SWFTools 将 PDF 转换为 Flash。但是SWFTools的默认皮肤看起来一点也不好看,所以你可以作为查看器查看Flexpaper。
如果您要制作自己的皮肤,那么阅读以下内容可能会有所帮助:SWFTools (pdf2swf)使用 Flex
另一个解决方案是 pdf.js (正如 Quentin 指出的那样),但是 AFAIR 这个脚本对于具有复杂结构(例如复杂渐变)的 PDF 不可用(当时,当我寻找时)。
如果您需要将文档发布为“私人”,您应该将服务视为 Issuu,否则您将不得不保护文件免遭下载。
You can use SWFTools to convert PDFs to Flash. But SWFTools default skins are not looking good at all, so you can check Flexpaper as a viewer.
In case you are going to make your own skin, then could be useful to read: SWFTools (pdf2swf) to properly work with Flex
Another solution is pdf.js (as Quentin point out), but AFAIR this script was not usable(back then, when I looked for) for PDFs with complex structures (complex gradients for example).
If you need to publish documents as "private" you should look at services as Issuu or you will have to protect files from downloading.
如果您的 pdf 文件放在网上且不受限制,您可以尝试使用 Google Doc Viewer。将查看器放入
中是一种非常好的方法,这样它就可以与您的网页结合起来。
If you pdf files are put online and not restricted, you can try using Google Doc Viewer. It's a very nice way to put the Viewer in
<iframe />
so that it can be combined with your web page.如果没有 Adobe Reader 等查看器,则无法查看 PDF 文件。如果您只是不想使用 Adobe Reader,您可以尝试使用其他公司的 Web 浏览器 PDF 查看器插件。
但是,如果您根本不想使用查看器并希望编写/构建自己的查看器,那么更好的选择是将 PDF 转换为可缩放图像,然后使用图像标签在网页上显示它们。您还可以使用 JavaScript 创建这样的查看器。
您甚至可以找到许多已经可用的基于 JavaScript 的查看器,可以显示这些图像。
It is not feasible to view the PDF files without a viewer like Adobe Reader. If you just don't want to use Adobe Reader, you may try a PDF viewer plug in for web browser from some other company.
However, if you do not want to use a viewer at all and want to write/build your own viewer then a better option is to convert the PDF to scalable images and then show them on the web page using image tags. You can also create such a viewer using JavaScript.
Even you can find many already available JavaScript based viewers which can show those images.