I am trying to add a couple of lines as my magento 2 store's pdf invoice's footer - technically trying to set it just after the Totals.

So I have overriden the file Magento\Sales\Model\Order\Pdf\Invoice.php in my custom module. To add the footer I have written the below function:

protected function _drawFooter(\Zend_Pdf_Page $page)

            $page->setFillColor(new \Zend_Pdf_Color_RGB(1, 1, 1));
            $page->setLineColor(new \Zend_Pdf_Color_GrayScale(0.5));
            $page->setFillColor(new \Zend_Pdf_Color_RGB(0.1, 0.1, 0.1));
            $page->setFont(\Zend_Pdf_Font::fontWithName(\Zend_Pdf_Font::FONT_HELVETICA), 10);

        $page->drawText('EFT Details: ', 35, $this->y -10, 'UTF-8');
            $page->drawText('Account Name:  , 40, $this->y -25, 'UTF-8');
        $page->drawText('BSB: XXXXXXX Account No: XXXXXX' , 250, $this->y -25, 'UTF-8');

        $page->drawText('Please put your order number as reference' , 40, $this->y -35, 'UTF-8');

         $page->drawText('Return and Refund Policy: ', 35, $this->y -50, 'UTF-8');
            $page->drawText('Products returned due to change of mind, not being suitable or if the job did not go forward, must be returned within' , 40, $this->y -65, 'UTF-8');
            $page->drawText('30 days of the purchase. The amount paid will be applied as a store credit to your account. ' , 40, $this->y -75, 'UTF-8');
             $page->drawText('If a refund is required, the following fees will apply: ' , 40, $this->y -85, 'UTF-8');
            $page->drawText('2% credit card process fee applicable for all orders paid with Visa or Master. ' , 50, $this->y -100, 'UTF-8');
            $page->drawText('3% credit card process fee applicable for all orders paid with AMEX. ' , 50, $this->y -110, 'UTF-8');
            $page->drawText('Shipping cost will be deducted from refund (i.e. shipping to customers and pick up cost).' , 50, $this->y -120, 'UTF-8');
            $page->drawText('Restocking fee may apply.' , 50, $this->y -130, 'UTF-8');

               $page->drawText('Warranty' , 35, $this->y -145, 'UTF-8');

                $page->drawText(' LED Products have either a 3 or 5 years full product replacement warranty.' , 40, $this->y -160, 'UTF-8');

                 $page->drawText(Lighting Products have 2 years full product replacement warranty.' , 40, $this->y -170, 'UTF-8');
             $page->drawText('For warranty claims regarding transit damage, the claim must be made within 5 . business days of receiving of goods.' , 40, $this->y -180, 'UTF-8');
             $page->drawText('The warranty service is limited to the replacement or repair of products that have become defective due to normal usage,' , 40, $this->y -190, 'UTF-8');

                $page->drawText('For Labour Warranty conditions please refer to our website.' , 40, $this->y -210, 'UTF-8');


And then called this function below the within the getPdf function like this

 public function getPdf($invoices = [])
return $pdf;


it is generating output as following if there is only one or two items - as there are plenty of spaces on the page enter image description here

but if there are lots of products and the footer needs to move to the next page then it gets cut off at the middle like this:

enter image description here

I am very new to magento and totally at loss..please help.

1 Answer 1


I found a simple solution to the issue and posting this answer as someone else might find it useful.

I modified the _drawFooter function as following:

 protected function _drawFooter(\Zend_Pdf_Page $page)
            $page = $this->newPage();

all remaining codes were same.

This way the terms and conditions were going to a new page irrespective of how many orders were placed. Also the next page had the logo of the business. Hope this is helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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