note 35930 rejected from ref.pdf by didou
| From: | didou@php.net | Date: | Fri, 19 Sep 2003 13:33:23 +0000 |
| Subject: | note 35930 rejected from ref.pdf by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-56765@lists.php.net to get a copy of this message | ||
Note Submitter: adrydonof@yahoo.com
----
When i try to use the script to generate pdf:
....
$buf = pdf_get_buffer($pdf);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=foo.pdf");
print $buf;
pdf_delete($pdf);
...
I have an error in the next page i visit.
The "http header" in the instruction
header("Content-Length: $len");
is not correctly formed because the instruction
$len = strlen($buf);
doesn't give the correct size of the $buf so next html page i call get the "%EOF" of
the pdf file and gives error.
Try this:
$buf = pdf_get_buffer($pdf);
$len = strlen($buf) + 6;
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=foo.pdf");
print $buf;
pdf_delete($pdf);
and it will work fine!