Invoice / Quote Page numbers


#1

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!


#2

Last Update: 08.08.2017


#3

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


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

within application/helpers/mpdf_helper.php


#5

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:


#7

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:


#8

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:


#10

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>');
        
    }

How to get a page count in PDF quote or PDF invoice?
#11

Great, works perfect!!


#12

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


#13

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>');
}