note 35930 added to ref.pdf
| From: | adrydonof at yahoo dot com | Date: | Fri, 19 Sep 2003 13:29:14 +0000 |
| Subject: | note 35930 added to ref.pdf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-56764@lists.php.net to get a copy of this message | ||
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!
----
Manual Page -- http://www.php.net/manual/en/ref.pdf.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35930
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35930&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35930&report=yes