将html添加到发票pdf Magento

时间:2017-06-12 12:12:30

标签: php magento pdf invoice

我正在尝试在我的发票PDF中添加免责声明文字。 目前,文本已在Sales/Model/Order/Pdf/Invoice.php中进行了硬编码。

public function getDesclaimer($page)
{
    $page->drawLine(25, $this->y, 570, $this->y); 
    $this->y -= 25;
    $this->_setFontRegular($page, 12);
    $page->drawText(Mage::helper('sales')->__('Declaration'), 35, $this->y-20, 'UTF-8');
    $this->_setFontRegular($page, 8);
    $page->drawText(Mage::helper('sales')->__('The goods sold are intended for end user consumption and not for resale.'), 35, $this->y-50, 'UTF-8');
    $page->drawText(Mage::helper('sales')->__('The goods sold are intended for end user consumption and not for resale.'), 35, $this->y-60, 'UTF-8');
    $page->drawText(Mage::helper('sales')->__('of goods specified in this tax invoice is made by me/us and that the transaction of sale covered by this tax invoice has been effected by me/us'), 35, $this->y-70, 'UTF-8');
    $page->drawText(Mage::helper('sales')->__('and it shall be accounted for in the turnover of sales while filling of return and the due tax,if any payable on the sale has been paid or shall be paid.'), 35, $this->y-80, 'UTF-8');
    $page->drawText(Mage::helper('sales')->__('This is a computer generated invoice.'), 35, $this->y-100, 'UTF-8');
}

这很有效。不,我在magento设置中添加了一个配置,并在相同的功能下调用它。

这会显示正确的文字,但HTML无效。

当我搜索到时,zend pdf不允许在pdf中使用html。我们需要使用TCPDF。我也尝试了这一点,但它提供了一个没有其他数据的全新页面。

1 个答案:

答案 0 :(得分:0)

您不应该编辑核心文件。您必须为覆盖发票pdf函数创建模块

使用此网址,您可以覆盖发票pdf功能。

http://inchoo.net/magento/how-to-add-custom-attribute-to-magentos-pdf-invoice/

尝试上述网址并根据您的要求进行自定义。

相关问题