Using fsockopen to display pdf file
Posted: Thu Dec 18, 2003 5:07 am
I'm using fsockopne to open a connection to a port in a java program (must do it this way due to firewall problems) which has read a pdf file a is outputting it as a stream.
I know the java code is ok.
When I display the returned data in php it seems that some of it may be corrupted. Php code below...
while (!feof($fp)) {
$buff = fgets ($fp,128);
$pdffile .= $buff;
}
When I try to get the browser to launch pdf viewer..
header("Content-type: application/pdf");
header("Content-disposition: filename=dmsdoc.pdf");
echo $pdffile;
I get error saying the launchpdf.php (name of script) cannot be downloaded.
All code runs on windows, using apache.
Has anyone else done something similar? Any advice greatly appreciated.

I know the java code is ok.
When I display the returned data in php it seems that some of it may be corrupted. Php code below...
while (!feof($fp)) {
$buff = fgets ($fp,128);
$pdffile .= $buff;
}
When I try to get the browser to launch pdf viewer..
header("Content-type: application/pdf");
header("Content-disposition: filename=dmsdoc.pdf");
echo $pdffile;
I get error saying the launchpdf.php (name of script) cannot be downloaded.
All code runs on windows, using apache.
Has anyone else done something similar? Any advice greatly appreciated.