note 26274 added to function.pdf-open-file
| From: | jon at logicworks dot cc | Date: | Thu, 24 Oct 2002 16:48:49 +0000 |
| Subject: | note 26274 added to function.pdf-open-file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38514@lists.php.net to get a copy of this message | ||
When creating a pdf in memory, it appears that the code is executed twice. This does not seem to
happen when creating a pdf as file. Not a problem when outputing a pdf, but does cause a problem if
doing other writes in the same code:
// the write to the file is executed twice
$fp = fopen("testfile.htm", "a");
fwrite($fp, "testline/") ;
fclose($fp);
//--------------
$pdf = pdf_new();
if (!pdf_open_file($pdf, "")) {
print error;
exit;
};
pdf_begin_page($pdf, 8.5*72, 11*72);
pdf_set_font($pdf, "Helvetica-Bold", 24, "host");
pdf_set_text_pos($pdf, 50, 700);
pdf_show($pdf,"Hello,world!");
pdf_end_page($pdf);
pdf_close($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;
--
http://www.php.net/manual/en/function.pdf-open-file.php
http://master.php.net/manage/user-notes.php?action=edit+26274
http://master.php.net/manage/user-notes.php?action=delete+26274
http://master.php.net/manage/user-notes.php?action=reject+26274