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