在php页面中显示pdf文件 [英] show pdf files in a php page

查看:1006
本文介绍了在php页面中显示pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些pdf文件,并希望在我的网站上在线显示它们,而不是使用acrobat或firefox附加软件下载或显示,actullay我需要一个pdf查看器.我不确定是否有准备好的库或插件.我想我必须将pdf的每个页面都转换为图像文件,但是我该怎么办呢?

I have some pdf files and want to show them online in my website,not downloading or displaying with acrobat or firefox add-on, actullay I need a pdf viewer. I am not sure if there ia any prepared library or plugin. I guess I have to convert each page of pdf to an image file,but how can I do it?

谢谢.

推荐答案

就像@Lix一样,大多数现代浏览器都内置了此功能,它在chrome和firefox中都可以很好地工作.这就是我要做的...

Like @Lix said most modern browsers have this built in it works well in chrome and firefox. This is what I do...

<object height="950" data="sample-report.pdf" type="application/pdf" width="860">

            <p>It appears you don't have a PDF plugin for this browser.
                No biggie... you can <a href="sample-report.pdf">click here to
                download the PDF file.</a>
            </p>

        </object>

如果浏览器不支持通过下载一个PDF来查看,则它的性能会下降.我在寻找其他解决方案,例如转换为html或图像.但是我不喜欢加载很多大图像,而转换为html会丢失很多格式.

It degrades well if the browser doesn't support viewing PDF by letting one download it. I have looked for other solutions such as converting to html or image. But I don't like to load lots of large images and converting to html loses much of the formatting.

即使您使用此命令运行linux,也可以在服务器上进行转换...

You can convert on your server though if your running linux with this command...

转换abc.pdf abc.jpg

convert abc.pdf abc.jpg

-编辑- Firefox使用 PDF.js 呈现PDF.我之前研究过,但是对于我的任何项目来说,复杂性都不值得.

-EDIT-- Firefox uses PDF.js to render PDFs. I've looked into before, but the complexity wasn't worth it for any of my projects.

希望这会有所帮助.阿罗哈.

Hope this helps. Aloha.

这篇关于在php页面中显示pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆