Text drawing operations also exist in the context of a PDF page. You can draw a single line of text at any position on the page by supplying the x and y coordinates of the baseline. Current font, font size and page fill color are used for text drawing operations (see detailed description below).
<?php
/**
* Draw a line of text at the specified position.
*
* @param string $text
* @param float $x
* @param float $y
* @param string $charEncoding (optional) Character encoding of source
* text.Defaults to current locale.
* @throws Zend_Pdf_Exception
* @return Zend_Pdf_Page
*/
public function drawText($text, $x, $y, $charEncoding = '');
Example 647. Set font color
<?php
...
$pdfPage->setFillColor(Zend_Pdf_Color_Html::color('#990000'))
->drawText('Hello world (in red)!', 72, 720);
....
By default, text strings are interpreted using the character encoding method of the
current locale. if you have a string that uses a different encoding method (such as a
UTF-8 string read from a file on disk, or a MacRoman string obtained from a legacy
database), you can indicate the character encoding at draw time and
Zend_Pdf will handle the conversion for you. You can supply
source strings in any encoding method supported by PHP's
iconv()
function:
Example 648. Draw a UTF-8-encoded string on the page
<?php
...
// Read a UTF-8-encoded string from disk
$unicodeString = fread($fp, 1024);
// Draw the string on the page
$pdfPage->drawText($unicodeString, 72, 720, 'UTF-8');
...




