Re: Getting gibberish, sometimes, in PDF output

From: Date: Mon, 21 Oct 2002 18:59:14 +0000
Subject: Re: Getting gibberish, sometimes, in PDF output
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-120790@lists.php.net to get a copy of this message
'accidental output' rang a bell .... turns out the include file to access my database was the culprit, though only effecting IE. When I took it out & simply called the database from within the script (which is how it had been for weeks, when it was working), the file opened pdf, no gibberish. I guess I could put it back and use the ob_ functions, but for now it's fine. thanks all. s. Matt Schroebel wrote: > > Content-length must be right for IE. Check what David said about > outputing something accidently, thus messing up the content length. I > use ob_start(), ob_get_length(), and ob_end_flush(), but your code > should work fine. Maybe you could start ob just to see if the > pdf_get_buffer() value matches the ob_get_length() value? > > > -----Original Message----- > > From: Sarah Gray [mailto:sarah@fabled.net] > > Sent: Monday, October 21, 2002 2:16 PM > > To: PHP > > Subject: Re: [PHP] Getting gibberish, sometimes, in PDF output > > > > > > My file outputs in NS4.79 but not IE6 (although it used to > > work in IE no > > problem. not sure why it stopped). These are my last lines of code: > > > > pdf_close($p); > > $buf = pdf_get_buffer($p); > > $len = strlen($buf); > > $filename = "Certificate.pdf"; > > header("Content-type: application/pdf"); > > header("Content-disposition:inline;filename=$filename"); > > header("Content-length: $len"); > > print $buf; > > pdf_delete($p); > > ?> > > > > (I'm not using sessions). > > > > Anything? > > thanks, > > s. > > > > > > > > Matt Schroebel wrote: > > > > > > > -----Original Message----- > > > > From: Sarah Gray [mailto:sarah@fabled.net] > > > > Sent: Monday, October 21, 2002 12:21 PM > > > > To: PHP > > > > Subject: [PHP] Getting gibberish, sometimes, in PDF output > > > > > > > > > > > > hi > > > > I'm generating a pdf file and giving users a link to the file > > > > (an online > > > > certificate). The link is just a regular link with a query string. > > > > > > > > Sometimes in the browser the pdf file opens correctly, > > and other times > > > > the page spews out gibberish (uncompiled). > > > > > > > > I am including the header header("Content-type: > > application/pdf"); in > > > > the file and it is on the first line (before includes, etc.). > > > > > > > > This is the first time I am outputting pdf files and suspect that > > > > probably I am missing something simple -- a step, call to > > a plugin, > > > > header, something. Can anyone tell me what that might be? > > > > > > Make sure to send a content-length header, or IE won't like > > the pdf. IE > > > has this terrible habit of remembering the content-type > > within a window > > > of the browser, so if you ever had sent the page without the > > > content-type, then IE will treat it as text and you get > > gibberish. The > > > same is true in reverse -- if you get a parse error and had > > previously > > > sent a content-type header, you'll get a broken icon image > > unless you > > > close the window and re-open the page. > > > > > > Also, you may want to move the content-type header to a place right > > > before you output the pdf, so that if there are parse errors, the > > > browser will show them and not try to send the page to Aacrobat. > > > > > > These are the headers I send: > > > header('Content-type: application/pdf'); > > > header("Content-Disposition: inline; filename=$fileName"); > > > header("Content-Length: $length"); > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > >

« previous php.general (#120790) next »