4 Replies - 18764 Views - Last Post: 29 June 2011 - 06:03 AM Rate Topic: -----

#1 sourjatilak  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-June 11

how to display pdf file in php?

Posted 28 June 2011 - 10:09 AM

How to display a pdf file from server into html page?


I want to make an online library of pdf files which can only be readable but not downloadable.
I want to display pdf files page wise.

I am programming in php.so I want to know how to do it or is there any open source project available
or some softwares like ipaper viewer,etc.
Is This A Good Question/Topic? 0
  • +

Replies To: how to display pdf file in php?

#2 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 948
  • View blog
  • Posts: 2,357
  • Joined: 15-February 11

Re: how to display pdf file in php?

Posted 28 June 2011 - 11:29 AM

Try changing the Content-Type to application/pdf. Should work if I'm not wrong. If a plugin is installed on the client's browser it should cause it to open the PDF file.

Example - Not Tested
header('Content-type:application/pdf');
readfile('mypdffile.pdf');

Was This Post Helpful? 2
  • +
  • -

#3 RPGonzo  Icon User is offline

  • // Note to self: hmphh .... I forgot
  • member icon

Reputation: 151
  • View blog
  • Posts: 954
  • Joined: 16-March 09

Re: how to display pdf file in php?

Posted 28 June 2011 - 02:01 PM

That would be the ideal way to handle the document however, if by download you mean save the document the ideal way is not what you are looking for.

You would have to use a 3rd party library to be able to read the PDF into text, but the downside is 9 times out of 10 you lose formatting ... so the document doesn't stay 'pretty' if you have a lot of that going on.

Codeprada's code is functional though, and again would be the ideal way to handle things.
Was This Post Helpful? 0
  • +
  • -

#4 KingCuddles  Icon User is offline

  • D.I.C Regular

Reputation: 176
  • View blog
  • Posts: 496
  • Joined: 20-December 08

Re: how to display pdf file in php?

Posted 29 June 2011 - 04:33 AM

Anyone using Chrome can save a PDF, and I am sure other browsers feature similar abilities.

You could use something like Yudu or ISSUU which converts it to Flash?
Was This Post Helpful? 1
  • +
  • -

#5 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 948
  • View blog
  • Posts: 2,357
  • Joined: 15-February 11

Re: how to display pdf file in php?

Posted 29 June 2011 - 06:03 AM

That's true, as long as Adobe Reader or the native PDF reader opens the file in the browser there's going to more times than not be a save button. You'd have to introduce third party systems to your site to prevent downloading. If not the sites KingCuddles suggested try Google Books.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1