note 14509 added to function.pdf-findfont.php
| From: | bob at nijman dot de | Date: | Thu, 02 Aug 2001 10:45:47 +0000 |
| Subject: | note 14509 added to function.pdf-findfont.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-16223@lists.php.net to get a copy of this message | ||
Try this:
<?php
//Create & Open PDF-Object
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_set_info($pdf, "Author","Bob Nijman");
pdf_begin_page($pdf, 300, 300);
$font = pdf_findfont($pdf, "Times New Roman", "host", 1);
if ($font) {
pdf_setfont($pdf, $font, 30);
}
$string = "Hello Berlin-Mitte!";
$width = pdf_stringwidth($pdf, $string);
pdf_set_text_pos($pdf, (300-$width)/2, 200);
pdf_show($pdf, $string);
//close it up
pdf_end_page($pdf);
pdf_close($pdf);
$data = pdf_get_buffer($pdf);
header('Content-type: application/pdf');
header('Content-disposition: inline; filename=myTest.pdf');
header('Content-length: ' . strlen($data));
echo $data;
?>
http://www.php.net/manual/en/function.pdf-findfont.php