我需要有关如何在magento pdf invoice底部添加自定义文本的帮助。
pdf发票底部的“感谢您与我们合作”的示例
提前谢谢
答案 0 :(得分:0)
您可以通过创建模块并覆盖Mage_Sales_Model_Order_Pdf_Invoice
类来完成此操作。然后,您可以将getPdf()方法复制到新类,并将更改添加到每张发票的末尾(确保在发票循环中执行此操作,因为您可以一次打印多张发票)。
/**
* Return PDF document
*
* @param array $invoices
* @return Zend_Pdf
*/
public function getPdf($invoices = array())
{
$this->_beforeGetPdf();
[...]
foreach ($invoices as $invoice) {
[...]
/* Add totals */
$this->insertTotals($page, $invoice);
if ($invoice->getStoreId()) {
Mage::app()->getLocale()->revert();
}
// Add your custom stuff here
$this->insertMyCustomStuff();
}
$this->_afterGetPdf();
return $pdf;
}
/**
* Insert custom stuff to pdf page
*
* @param Zend_Pdf_Page $page
* @param Mage_Sales_Model_Abstract $invoice
* @return Zend_Pdf_Page
*/
public function insertMyCustomStuff($page, $invoice)
{
$page->drawLine(25, $this->y, 570, $this->y); //right
$this->y -= 25;
$page->drawText(Mage::helper('sales')->__('Thank you for working with us!'), 35, $this->y, 'UTF-8');
}