Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
544 views
in Technique[技术] by (71.8m points)

show pdf files in a php page

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?

thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

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.

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

convert abc.pdf abc.jpg

-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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...