fdopen(1, ...) in lib goes where?
| From: | Uwe Steinmann | Date: | Fri, 28 May 1999 06:08:28 +0000 |
| Subject: | fdopen(1, ...) in lib goes where? | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-6113@lists.php.net to get a copy of this message | ||
Hi,
while implementing the cpdflib stuff I ran into a problem.
The cpdflib creates a pdf file as a memory stream. This stream can
be saved to a file or send to standard out when the filename is "-".
Here is what I would like to do
...
some cpdflib functions to create the pdf doc
Header("Content-type: application/pdf");
cpdf_save_to_file($cpdf, "-");
This results into an output in Netscape as if the Header has been omitted.
The Browser displays the plain text of the pdf document.
Saving it to a file and doing
$fp = fopen("testcpdf.pdf", "r");
header("Content-type: application/pdf");
fpassthru($fp);
fclose($fp);
instead, works.
The question is: Could this be related to the way clibpdf writes to
stdout? Here is the source code from clibpdf. I wonder if that fdopen()
is OK.
if( strcmp(name, "-") == 0)
fpout = fdopen(1, BINARY_WRITE); /* fd of 1 == stdout */
else {
if((fpout = fopen(name, BINARY_WRITE)) == NULL) {
cpdf_Error(1, "ClibPDF", "Cannot open output file: %s", name);
return(-1);
}
}
Uwe
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net