Invoice / Quote Page numbers

It would be useful to have page numbers on the PDF invoices and quotes so that the client views things in a logical order if for example they printed it out.

We tend to create multiple pages when creating quotes/invoices 3 or 4 pages sometimes more. So would be nice in the bottom corner the page number could be displayed for example…

1 of 3
2 of 3
…and so on.

If there’s an easy way to implement this I’m open to ideas.

Thanks!

Last Update: 08.08.2017

This could maybe help? https://mpdf.github.io/paging/page-numbering.html

1 Like
// Pagination
$mpdf->nbpgPrefix = ' of ';
$mpdf->setFooter('{PAGENO}{nbpg}');

within application/helpers/mpdf_helper.php

Thanks guys…I’ll have a look at this as soon as I can probably won’t be until the weekend now as I’m busy with work.

I’ll let you know how I get on! :grin:

Thank you @musa that code certainly pointed me in the right direction, however inserting that code exactly as you showed then overwrites the custom pdf_invoice_footer, so i changed the code slightly and concatenated it into the existing footer call.

For anyone else who wants this please see the code below and alter to your requirements:

// Set the footer if voucher is invoice and if set in settings
    if (!empty($CI->mdl_settings->settings['pdf_invoice_footer'])) {
        $mpdf->setAutoBottomMargin = 'stretch';
        $mpdf->nbpgPrefix = ' of ';
        $mpdf->SetHTMLFooter('<div id="footer">' . $CI->mdl_settings->settings['pdf_invoice_footer'] . '</div>' . '<p align=right>Page {PAGENO}{nbpg}</p>');
        
    }

within application/helpers/mpdf_helper.php

@Developers @Contributors If you think other people will find this useful do we think it could be included as standard or at least a setting to enable/disable this function? :thinking:

I’m trying to add paging to my pdf file to, but can someone explain how to add this? Where do i add witch code.
my coding knowledge is not that good :roll_eyes:

My post above should still work :blush:

You just need to edit the file:
application/helpers/mpdf_helper.php

And alter the code starting on line 78 to match the code below, remember to take a back up of the file first :wink:

// Set the footer if voucher is invoice and if set in settings
    if (!empty($CI->mdl_settings->settings['pdf_invoice_footer'])) {
        $mpdf->setAutoBottomMargin = 'stretch';
        $mpdf->nbpgPrefix = ' of ';
        $mpdf->SetHTMLFooter('<div id="footer">' . $CI->mdl_settings->settings['pdf_invoice_footer'] . '</div>' . '<p align=right>Page {PAGENO}{nbpg}</p>');
        
    }
1 Like

Great, works perfect!!

1 Like

Hi, does this code also work for quote if I change the invoice to quote?

Cable Guy…
Immediately following the “invoice” section is the section “quote” so you would just repeat it there …

// Set the footer if voucher is quote and if set in settings
if (!empty($CI->mdl_settings->settings['pdf_quote_footer']) && strpos($filename, trans('quote')) !== false) {
    $mpdf->setAutoBottomMargin = 'stretch';
    $mpdf->nbpgPrefix = ' of ';
    $mpdf->SetHTMLFooter('<div id="footer">' . $CI->mdl_settings->settings['pdf_invoice_footer'] . '</div>' . '<p align=right>Page {PAGENO}{nbpg}</p>');
}

The code provided by nmay1990 is working great for me. Can we also add the invoice number to it so that it gets displayed on every page of a multi-page invoice?

application/helpers/mpdf_helper.php

// Set the footer if voucher is invoice and if set in settings
if (!empty($CI->mdl_settings->settings['pdf_invoice_footer'])) {
    $mpdf->setAutoBottomMargin = 'stretch';
    $mpdf->nbpgPrefix = ' of ';
    $mpdf->SetHTMLFooter('<div id="footer">' . $CI->mdl_settings->settings['pdf_invoice_footer'] . '</div>' . '<p align=right>Page {PAGENO}{nbpg}</p>');
    
}

// Set the footer if voucher is quote and if set in settings
if (!empty($CI->mdl_settings->settings['pdf_quote_footer'])) {
    $mpdf->setAutoBottomMargin = 'stretch';
    $mpdf->nbpgPrefix = ' of ';
    $mpdf->SetHTMLFooter('<div id="footer">' . $CI->mdl_settings->settings['pdf_quote_footer'] . '</div>' . '<p align=right>Page {PAGENO}{nbpg}</p>');
    
}