I want to add text to the pdf invoice in the marked arena (see photo).

I'm using Magento version

How can I do this?

pdf invoice


You can add specific text after total price follow the code

First override that block add this code in your config file between <global/>:


Create file in app/code/local/Namespace/Module/Model/Order/Pdf/Invoice.php and add the below function at the end of the file:

class Mage_Sales_Model_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Abstract 
   public function insertText($page)
     $page->drawLine(25, $this->y, 570, $this->y); 
     $this->y -= 25;
     $page->drawText(Mage::helper('sales')->__('Add here Your custom text'), 35, $this->y, 'UTF-8');

Now, you need to call this insertText() function in the getPdf() function and add this getPdf() function after insertText() function like here:

public function getPdf($invoices = array())

    $pdf = new Zend_Pdf();
    $style = new Zend_Pdf_Style();
    $this->_setFontBold($style, 10);

    foreach ($invoices as $invoice) {
        if ($invoice->getStoreId()) {
        $page  = $this->newPage();
        $order = $invoice->getOrder();
        /* Add image */
        $this->insertLogo($page, $invoice->getStore());
        /* Add address */
        $this->insertAddress($page, $invoice->getStore());
        /* Add head */
            Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId())
        /* Add document text and number */
            Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId()
        /* Add table */
        /* Add body */
        foreach ($invoice->getAllItems() as $item){
            if ($item->getOrderItem()->getParentItem()) {
            /* Draw item */
            $this->_drawItem($item, $page, $order);
            $page = end($pdf->pages);
        /* Add totals */
        $this->insertTotals($page, $invoice);
        if ($invoice->getStoreId()) {
    $this->insertText($page);  // your custom text is added here
    return $pdf;

$this->insertText($page); that call your custom text function so you need to add before $this->_afterGetPdf(); this function.

| improve this answer | |
  • Thank for your comment. In which config file should I add the code and what do you mean with Namespace? – NielN98 Nov 20 '16 at 15:58
  • Actually you have to create your own module to override model class.So please follow this link for understand about Namespace and also how to create module : code.tutsplus.com/tutorials/… – Sneha Panchal Nov 21 '16 at 8:54

I was able to add text to the invoice pdf by creating a local copy of the core directory(files/folders) app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php as app/code/local/Mage/Sales/Model/Order/Pdf/Invoice.php and added the insertText() function as stated above.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.