I am generating an invoice of order. when the order is big means it has a lot of different items in it. It shrinks the text inside the invoice. I want to make it go on two pages or more if the order is big.

These are the template settings given to my template

enter image description here

Can anyone help me regarding how to add multiple pages or add any option like that there which can allow multiple pages to invoice.

  • Means do you want more than one page in pdf of invoice? – Mayur Sisodiya Feb 20 at 4:31
  • Yes @MayurSisodiya – Zeeshan Feb 20 at 6:16

You have to override the getPdf method in \Magento\Sales\Model\Order\Pdf\Invoice

and in the foreach that prints the items you can create a new page:

            foreach ($invoice->getAllItems() as $item) {
                if ($item->getOrderItem()->getParentItem()) {
                //CREATE NEW PAGE
                if ($this->y >= 100 /*YOUR PAGE BOTTOM*/){
                    $page = $this->newPage();
                /* Draw item */
                $this->_drawItem($item, $page, $order);
                $page = end($pdf->pages);
| 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.