public function drawLineBlocks(Zend_Pdf_Page $page, array $draw, array $pageSettings = array()) { if (Mage::getStoreConfig('advancedinvoiceprinting_options/general/enable') == 0) { return parent::drawLineBlocks($page, $draw, $pageSettings); } foreach ($draw as $itemsProp) { if (!isset($itemsProp['lines']) || !is_array($itemsProp['lines'])) { Mage::throwException(Mage::helper('sales')->__('Invalid draw line data. Please define "lines" array.')); } $lines = $itemsProp['lines']; $height = isset($itemsProp['height']) ? $itemsProp['height'] : 10; if (empty($itemsProp['shift'])) { $shift = 0; foreach ($lines as $line) { $maxHeight = 0; foreach ($line as $column) { $lineSpacing = !empty($column['height']) ? $column['height'] : $height; if (!is_array($column['text'])) { $column['text'] = array($column['text']); } $top = 0; foreach ($column['text'] as $part) { $top += $lineSpacing; } $maxHeight = $top > $maxHeight ? $top : $maxHeight; } $shift += $maxHeight; } $itemsProp['shift'] = $shift; } if ($this->y - $itemsProp['shift'] < $this->calFooterTopArea()) { $page = $this->newPage($pageSettings); } foreach ($lines as $line) { $maxHeight = 0; foreach ($line as $column) { $fontSize = empty($column['font_size']) ? 10 : $column['font_size']; if (!empty($column['font_file'])) { $font = Zend_Pdf_Font::fontWithPath($column['font_file']); $page->setFont($font, $fontSize); } else { $fontStyle = empty($column['font']) ? 'regular' : $column['font']; switch ($fontStyle) { case 'bold': $font = $this->_setFontBold($page, $fontSize); break; case 'italic': $font = $this->_setFontItalic($page, $fontSize); break; default: $font = $this->_setFontRegular($page, $fontSize); break; } } if (!is_array($column['text'])) { $column['text'] = array($column['text']); } $lineSpacing = !empty($column['height']) ? $column['height'] : $height; $top = 0; foreach ($column['text'] as $part) { if ($this->y - $lineSpacing < $this->calFooterTopArea()) { $page = $this->newPage($pageSettings); } $feed = $column['feed']; $textAlign = empty($column['align']) ? 'left' : $column['align']; $width = empty($column['width']) ? 0 : $column['width']; switch ($textAlign) { case 'right': if ($width) { $feed = $this->getAlignRight($part, $feed, $width, $font, $fontSize); } else { $feed = $feed - $this->widthForStringUsingFontSize($part, $font, $fontSize); } break; case 'center': if ($width) { $feed = $this->getAlignCenter($part, $feed, $width, $font, $fontSize); } break; } $page->drawText($part, $feed, $this->y - $top, 'UTF-8'); $top += $lineSpacing; } $maxHeight = $top > $maxHeight ? $top : $maxHeight; } $this->y -= $maxHeight; } } return $page; }