RE: [PHP] Getting gibberish, sometimes, in PDF output
| From: | David Erickson | Date: | Mon, 21 Oct 2002 17:58:25 +0000 |
| Subject: | RE: [PHP] Getting gibberish, sometimes, in PDF output | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-120778@lists.php.net to get a copy of this message | ||
Well could be several things from my experience.. if you leave off the
trailing empty header(""); or a \n at the end of the last header it could
cause your problem. The other problem I have had is when I put a
session_start() after any of my headers in my code. The session_start()
must be the first thing executed before all headers are processed... That
is if you are using sessions like that.
David Erickson, CCSA
erickson@mddsg.com
>> -----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