Reading pdf files.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mparker1113
Forum Commoner
Posts: 28
Joined: Wed Apr 05, 2006 9:39 am

Reading pdf files.

Post by mparker1113 »

I see plenty of links on the web for creating pdf files with php, but I just want to read some!

The following page attempts to do it with fopen() with not so great of results:

http://216.180.244.51/download.php?Filename=test1.pdf

This is the code that I am using, but the characters that are printed are coming out all cryptic:

Code: Select all

$fp = fopen("documents/$Filename","r"); 
$buff = fread($fp,5000000); 
if(strchr($Filename, ".pdf") != "" OR strchr($Filename, ".PDF") != "")	
Header("Content-Type:application/pdf"); 
else if(strchr($Filename, ".doc") != "" OR strchr($Filename, ".DOC") != "")	
Header("Content-Type:application/pdf"); 
else
Header("Content-Type:application/unknown"); 
Header( "Content-Disposition:attachment;filename=$Filename"); 
echo $buff; 
$fp = fclose("$Filename");
I just saw some new info, but any input/discussion on this would be quite welcomed.


[/url]
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Have you tried PHPClasses.org for possible classes that can do this?
mparker1113
Forum Commoner
Posts: 28
Joined: Wed Apr 05, 2006 9:39 am

Post by mparker1113 »

- I am looking for coding hints, not to buy something.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

most, if not all, code on phpclasses.org is free or under fairly loose licenses. I'm not aware of any on there that require payment to use.

The PDF format specification is available for download from Adobe.

If you're wanting to create PDFs, there are many libraries available, one oft recommended is fpdf.
mparker1113
Forum Commoner
Posts: 28
Joined: Wed Apr 05, 2006 9:39 am

Post by mparker1113 »

no, i do not want to create a pdf, just to display one on the screen seamlessly. I will look at the phpclasses.org site again.

tq,

Mike
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

mparker1113 wrote:- I am looking for coding hints, not to buy something.
Can I make the recommendation that you look at what is suggested before dismissing it as something that you think it is? PHPClasses.org is a member of the PHP Developers Network. It has a huge library of user contributed code bases that are free to use and licensed very loosely. There are classes and code snippets that cover almost anything you'd want to do with PHP. At the very least, the code samples and classes could point you in the right direction on how you would want to develop your own code (like a hint on coding).

Please give consideration to the suggestions offered by the members of this board that are trying to help you. If our suggestions don't work, then by all means tell us. But without trying, it seems like the time we put into helping means nothing.

Please note, this is not meant to be a personal attack on your. It just seemed awful fast that you would come back with that particular response.
mparker1113
Forum Commoner
Posts: 28
Joined: Wed Apr 05, 2006 9:39 am

Post by mparker1113 »

No, I went to the site, and what I found was a program that I could purchase.

I still am not finding anything for reading existing pdf files, only for creating/editing them.

I don't mind the site, but I really did not find anything there that looks like it can help, except for one program that was a solicitation.

Didn't mean to offend just am frustrated that I can't get this to work, and that my boss seems to need me to.

Thanks,

Mike
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Try this link...
http://www.phparch.com/sample.php?mid=5

Not sure if it will do what you want, but I searched google for 'PHP PDF Viewer' and it was on the second page of the results.
Post Reply