Re: fdopen(1, ...) in lib goes where?

From: Date: Fri, 28 May 1999 07:15:08 +0000
Subject: Re: fdopen(1, ...) in lib goes where?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-6114@lists.php.net to get a copy of this message
On Fri, 28 May 1999, Uwe Steinmann wrote: > 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); > } > } hmm, as an apache module everything you write to stdout goes "nowhere" you need to use: # define PUTS(s) php3_puts(s) # define PUTC(c) php3_putc(c) # define PHPWRITE(a,n) php3_write(a,n) those macros if you want to send something to the client! so, if you want cpdf_save_to_file($cpdf, "-"); to work, you will have to hack the cpdf-lib to make it use PHPWRITE. regards, tc > > 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 > > > Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany -- 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

« previous php.dev (#6114) next »