Zend_Pdf drawing multi-line text

Here is an easy trick to enter multi-line text with Zend_Pdf which I use in some Magento PDF creators

$this->y = 150;
$description = wordwrap(strip_tags($product->getDescription()), 110, "<br />");
 foreach (explode("<br />", $description) as $i => $line) {
     $page->drawText($line, 65, $this->y - $i * 12, 'UTF-8');
}

Leave a Reply

Your email address will not be published. Required fields are marked *