Page 1 of 1

Transfering PDF's without PDFLib

Posted: Wed Apr 02, 2003 4:49 pm
by musashi
Does anyone know if this is possible?

I have a simple rountine setup, but the issue is that since the file extension to the php program is .php IE seems to be confused as to what to do. So it's solution is to just download the contents of the file and display it in a text editor. When, my hope is to have it realize this is a pdf file and use Acrobat.

Any ideas?

Here is the code:

Code: Select all

<?php
header("Content-Type:  application/pdf");
$fp = fopen("tutorial.pdf","r");

fpassthru($fp);

fclose($fp);
?>
Greatly appreciate the help!

Posted: Wed Apr 02, 2003 8:34 pm
by gyardleydn
If you are using apache, you could create a directory with an .htaccess file with the following entry

AddType application/x-httpd-php .pdf

Then you could use php with a file that has a pdf extension to provide security, or whatever reason you don't want to provide direct access, but still provide a pdf extension for browsers that ignore type headers.

Posted: Tue Mar 02, 2004 7:23 am
by hyper_st8
header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=foo.pdf");
readfile("tutorial.pdf", 'r');

Would work. I think...