public function testDraw() { $expectedPageSettings = array('table_header' => true); $expectedPdfPage = new Zend_Pdf_Page('a4'); $expectedPdfData = array(array('lines' => array(array(array('text' => array('Downloadable Documentation'), 'feed' => 35), array('text' => array('downloadable-docu', 'mentation'), 'feed' => 255, 'align' => 'right'), array('text' => '$20.00', 'feed' => 330, 'font' => 'bold', 'align' => 'right'), array('text' => '$-5.00', 'feed' => 380, 'font' => 'bold', 'align' => 'right'), array('text' => '1', 'feed' => 445, 'font' => 'bold', 'align' => 'right'), array('text' => '$2.00', 'feed' => 495, 'font' => 'bold', 'align' => 'right'), array('text' => '$17.00', 'feed' => 565, 'font' => 'bold', 'align' => 'right')), array(array('text' => array('Test Custom Option'), 'font' => 'italic', 'feed' => 35)), array(array('text' => array('test value'), 'feed' => 40)), array(array('text' => array('Download Links'), 'font' => 'italic', 'feed' => 35)), array(array('text' => array('Magento User Guide'), 'feed' => 40))), 'height' => 20)); $this->_model->setItem(new Varien_Object(array('name' => 'Downloadable Documentation', 'sku' => 'downloadable-documentation', 'row_total' => 20.0, 'discount_amount' => 5.0, 'qty' => 1, 'tax_amount' => 2.0, 'hidden_tax_amount' => 0.0, 'order_item' => new Varien_Object(array('product_options' => array('options' => array(array('label' => 'Test Custom Option', 'value' => 'test value')))))))); $this->_model->expects($this->any())->method('getLinksTitle')->will($this->returnValue('Download Links')); $this->_model->expects($this->any())->method('getLinks')->will($this->returnValue(new Varien_Object(array('purchased_items' => array(new Varien_Object(array('link_title' => 'Magento User Guide'))))))); $this->_pdf->expects($this->once())->method('drawLineBlocks')->with($this->anything(), $expectedPdfData, $expectedPageSettings)->will($this->returnValue($expectedPdfPage)); $this->assertNotSame($expectedPdfPage, $this->_model->getPage()); $this->_model->draw(); $this->assertSame($expectedPdfPage, $this->_model->getPage()); }
/** * * * @param bool $newSegmentOnly * @param null $outputStream * @param bool $toFileName * @param bool $toBrowser * * @return bool | string | void */ public function render($newSegmentOnly = false, $outputStream = null, $toFileName = false, $toBrowser = false) { if (self::COMPAT_MODE) { return parent::render($newSegmentOnly, $outputStream); } else { $pdf = null; foreach ($this->pages as $printObjects) { if (!empty($printObjects['orderIds'])) { $pdf = $printObjects['instance']->renderPdf(array(), $printObjects['orderIds'], $pdf, true); } else { $pdf = $printObjects['instance']->renderPdf($printObjects['objectArray'], null, $pdf, true); } } if ($pdf->getPdfAnyOutput()) { if ($toFileName) { if ($toBrowser) { return $pdf->Output($toFileName, Mage::getStoreConfigFlag('sales_pdf/all/allnewwindow') ? 'D' : 'I'); } else { return $pdf->Output($toFileName, 'F'); } } else { return $pdf->Output('output.pdf', 'S'); } } else { return false; } } }
/** * constructor to init settings */ public function __construct() { parent::__construct(); $this->encoding = 'UTF-8'; $this->colors['black'] = new Zend_Pdf_Color_GrayScale(0); $this->colors['grey1'] = new Zend_Pdf_Color_GrayScale(0.9); // get the default imprint $this->_imprint = Mage::getStoreConfig('general/imprint'); }
/** * constructor to init settings */ public function __construct() { parent::__construct(); $this->encoding = 'UTF-8'; $this->colors['black'] = new Zend_Pdf_Color_GrayScale(0); $this->colors['grey1'] = new Zend_Pdf_Color_GrayScale(0.9); $helper = Mage::helper('firegento_pdf'); $this->colors['text'] = $helper->getTextColor(); $this->colors['labels'] = $helper->getLabelColor(); $this->colors['header'] = $helper->getHeaderColor(); $this->colors['footer'] = $helper->getFooterColor(); // get the default imprint $this->_imprint = Mage::getStoreConfig('general/imprint'); }
public function newPage(array $settings = array()) { $pageWidth = $this->_convertInchToPoints((double) $this->_config(self::XML_PAGEWIDTH)); $pageHeight = $this->_convertInchToPoints((double) $this->_config(self::XML_PAGEHEIGHT)); $settings = array('page_size' => $pageWidth . ":" . $pageHeight . ":"); $page = parent::newPage($settings); $this->x = floor($this->_convertInchToPoints((double) $this->_config(self::XML_SIDEMARGIN))); $this->y = floor($pageHeight - $this->_convertInchToPoints((double) $this->_config(self::XML_TOPMARGIN))) - $this->_getConfigFontSize(); $page->setFillColor(new Zend_Pdf_Color_GrayScale(0)); $this->_setFontRegular($page, $this->_getConfigFontSize()); $this->_currLabel = 1; $this->_currRow = 1; $this->_currColumn = 1; return $page; }
/** * Create new page and assign to PDF object * * @param array $settings * @return Zend_Pdf_Page */ public function newPage(array $settings = array()) { $page = parent::newPage($settings); if (!empty($settings['table_header'])) { $this->_setFontRegular($page); $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92)); $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5)); $page->setLineWidth(0.5); $page->drawRectangle(25, $this->y, 570, $this->y - 15); $this->y -= 10; $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4)); $this->_drawHeader($page); $page->setFillColor(new Zend_Pdf_Color_GrayScale(0)); $this->y -= 20; } return $page; }
/** * Create new page and assign to PDF object * * @param array $settings * @return Zend_Pdf_Page */ public function newPage(array $settings = array()) { $page = parent::newPage($settings); if (!empty($settings['table_header'])) { $this->_drawHeader($page); } return $page; }