Reputation: 263
I have two lines of text from Magento's static block which I need to include in pdf. Im using zend php pdf functions.
Can anyone tell me how to bring about the line break btw two lines.
protected function financeAdvert($page){
$finance_advert = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('pdf_advert')->toHtml();
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
$page->setFont($font, 8);
$fin_ad[]= wordwrap($finance_advert,50,'<br>',true);
$page->setFillColor(new Zend_Pdf_Color_Html('#000000'))->drawText(strip_tags($fin_ad), 70, 245, 'UTF-8');
}
Upvotes: 2
Views: 1394
Reputation: 263
And the answer is
protected function financeAdvert($page){
$font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
$page->setFont($font, 8);
$finance_advert = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('pdf_advert')->toHtml();
$yPos = 245;
foreach (explode('|', $finance_advert) as $str) {
foreach (Mage::helper('core/string')->str_split($str, 100, true, true) as $part) {
$fin_advert[] = $page->setFillColor(new Zend_Pdf_Color_Html('#000000'))->drawText(strip_tags($part), 50, $yPos, 'UTF-8');
foreach ($fin_advert as $yPosition){
$yPos-=10;
}
}
}
}
This brings about a line break after every 100 char when it spots "|" symbol.
Upvotes: 1