Subtotal for every page when invoice has multiple pages

Hi there
First of all, I love Invoice Plane, so thanks for this project.

Invoice Plane version: 1.4.3

I have created my own template and now I would like to implement a pages subtotal and a subtotal for all pages so far for every page when an invoice or a quote has multiple pages. Only at the last page should be the normal total, balance and paid info. This should be in the table footer like:

<?php echo lang('pagetotal'); ?>: <?php echo format_currency($invoice->invoice_pagetotal); ?> <?php echo lang('pagessubtotal'); ?>: <?php echo format_currency($invoice->invoice_pagessubtotal); ?>

Is that somehow possible? I’m not scared of some PHP programming, if only I knew where to find how many pages the mPDF generates and to store that in a variable.

I don’t know if this is possible with mPDF but I doubt that it works as expected as the PHP cannot determine when a page breaks due to the styling and so on.

There are two things which you can use in the pdf footer for the page numbers:
{PAGENO} and {nb}
the first one is not working somehow but the second is, if I could get those two things into a variable
I could use them to programm a IF statement or switch cases.

if total_pages > 1
if actual_page < total_pages
just the page subtotal in the table footer
the normal table footer
normal handling

Do have an idea how to get the two system defined variables into a variable so that I can use them in my custom template?

Anybody an idea?

I’m not able to help. Maybe another contributor or developer?
@Contributors @Developers

Not possible.

You’re effectively rendering an HTML document which is one continuous page. Browsers render this different even with proper HTML and CSS. mPDF isn’t as advanced as most browser rendering engines. Your best shot at doing this is to set a conservative number of line items per page if it goes over that number force a page break at the same time keeping a running total from page to page.


The original mPDF class has pages available but you’d need to extend it and pass through an argument after your parsing of HTML.

So @mgronlund has the short answer of not possible, but it is with significant changes to mPDF and IP.

Probablly adding Invoice ID and invoice date at PDF footer is the best option to avoid mistake of filling for multipage invoices.