note 43562 added to function.pdf-findfont

From: Date: Fri, 25 Jun 2004 17:14:57 +0000
Subject: note 43562 added to function.pdf-findfont
Groups: php.notes 
Request: Send a blank email to php-notes+get-71684@lists.php.net to get a copy of this message
Display UTF-8 string with your PDFlib and true type font <?php /* UTF-8 : Unicode encoded string with PDFlib & Php */ $pdf = pdf_new(); if (!pdf_open_file($pdf, "")) exit; PDF_begin_page($pdf, 600,800); // set the textformat parameter to utf8 pdf_set_parameter($pdf, "textformat", "utf8"); // path of your TTF font directory $fontdir = "/path/to/font/directory/"; // Open few .TTF (true type font) // be sure that your font file contains enough character for your language pdf_set_parameter($pdf, "FontOutline", "ArialUnicode=$fontdir/ARIALUNI.TTF"); pdf_set_parameter($pdf, "FontOutline", "ArialItalic=$fontdir/ariali.ttf"); // UTF-8 encoded string (this is bulgarian (cyrillic alphabet)) $utf_8_string ="Потребление" ; // Set the font $font = PDF_findfont($pdf, "ArialUnicode", "unicode",0); pdf_setfont($pdf, $font, 15); // output the encoded string with Arial Unicode font pdf_show_xy($pdf, "Arial Unicode : $utf_8_string" ,40 ,700); // output the encoded string with Arial Italic font $font = PDF_findfont($pdf, "ArialItalic", "unicode",0); pdf_setfont($pdf, $font, 15); pdf_show_xy($pdf, "Arial Italic : $utf_8_string" ,40 ,650); 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"); echo $buf; pdf_delete($pdf); ?> ---- Manual Page -- http://www.php.net/manual/en/function.pdf-findfont.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43562 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43562&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43562&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#71684) next »