I'm currently working on magento 1.9 and wanted to add some additional text to invoice when we print in from admin panel like this : As you can see above red numbers are the additional text for the invoice. How do I do that in magento 1.9 ? Please help me on this and I really appreciate if you show me step by step to achieve this.
asked Aug 8, 2017 at 2:56 Gujarat Santana Gujarat Santana 583 2 2 gold badges 6 6 silver badges 18 18 bronze badgesyou can do this by creating the Invoice.php in the following path : local/[Vendor]/Module/Model/Order/Pdf/Invoice.php .
class YouClass extends Mage_Sales_Model_Order_Pdf_Invoice < /** * @param Zend_Pdf_Page $page * @param '??' $order * @return void */ protected function _drawBottomText(Zend_Pdf_Page $page, $order) < $this->_setFontRegular($page, 10); /* Getting the DPP */ $Dpp = $order->getGrandTotal() / 1.1; $Ppn = $Dpp * 0.1; // dpp * 10% /* Convert the number to currency */ $DppCurrency =number_format($Dpp, 2, '.', ','); $PpnCurrency= number_format($Ppn, 2, '.', ','); $Currency = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); $page->drawText('DPP : ' . $Currency .' '. $DppCurrency,35,$this->y,'UTF-8'); $page->drawText('PPN : ' . $Currency .' ' . $PpnCurrency,35,$this->y-20,'UTF-8'); $page->drawText('Harga BKP sudah termasuk pajak',35,$this->y-40,'UTF-8'); $page->drawText('PT KAYU RAYA INDONESIA',35,$this->y-55,'UTF-8'); $page->drawText('Kawasan Industri dan Pergudangan Taman tekno BSD',35,$this->y-65,'UTF-8'); $page->drawText('City Sektor XI Blok C No 2, Kota Tangerang Selatan',35,$this->y-75,'UTF-8'); $page->drawText('NPWP: 76.406.266.7-411.000',35,$this->y-85,'UTF-8'); $page->drawText('PKP: 76.406.266.7-411.000',35,$this->y-95,'UTF-8'); > /** * Return PDF document * * @param array $invoices * @return Zend_Pdf */ public function getPdf($invoices = array()) < $this->_beforeGetPdf(); $this->_initRenderer('invoice'); $pdf = new Zend_Pdf(); $this->_setPdf($pdf); $style = new Zend_Pdf_Style(); $this->_setFontBold($style, 10); foreach ($invoices as $invoice) < if ($invoice->getStoreId()) < Mage::app()->getLocale()->emulate($invoice->getStoreId()); Mage::app()->setCurrentStore($invoice->getStoreId()); > $page = $this->newPage(); $order = $invoice->getOrder(); /* Add image */ $this->insertLogo($page, $invoice->getStore()); /* Add address */ $this->insertAddress($page, $invoice->getStore()); /* Add head */ $this->insertOrder( $page, $order, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId()) ); /* Add document text and number */ $this->insertDocumentNumber( $page, Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId() ); /* Add table */ $this->_drawHeader($page); /* Add body */ foreach ($invoice->getAllItems() as $item)< if ($item->getOrderItem()->getParentItem()) < continue; >/* Draw item */ $this->_drawItem($item, $page, $order); $page = end($pdf->pages); > /* Add totals */ $this->insertTotals($page, $invoice); if ($invoice->getStoreId()) < Mage::app()->getLocale()->revert(); > /* Add bottom text for details tax and company*/ $this->_drawBottomText($page,$order); > $this->_afterGetPdf(); return $pdf; > >
and register the class in your config.xml file in etc folder :
YourClass
It is hard for me to adjust the text to match exactly like the screen shot, but this one displaying additional text and does the work.