At least one item in the last page of the print format

Hi,

First the question and then the (longish) explanation: How to ensure that there is at least one item that appears in the last page of the PDF of a print format?

Actual Question: What function (Jinja, CSS, HTML, etc.) to use to count the number of items in the last page of the PDF of a Print format and if that is 0, insert a page break after the (N-1)th item where N is the number of items in the transaction?

Here’s the background:

All of us know customers get very obsessed with Print Formats. So rather than fight that obsession, let’s see if we can profit off it. :slight_smile:

I have broken up a print format for a typical item related transaction into the following components:

Header: This has the logo of the company, address and a few other things.
Part A: This is the content before the Item Table. Typically it has the Label (Quotation, Sales Invoice, Purchase Order, etc. Etc.), The party name address, GST Invoice QR-Code and a few other things
Part B: This is the item Table
Part C: This is the content after the Item Table. It has the Charges and Taxes, Terms and Conditions, Bank details for remittance and the signature area (many formats move the signature to the Footer)
Footer: This has the signature area, some branding, etc.

Now if a particular transaction fits into one page (and that will depend on the number of items in the transaction), it has all 5 components in the page.

If it spills into 2 pages, the first page has Header, Part A and a part of Part B (the item table) and the second page has a part of Part B (the item table), Part C and the Footer.

Similarly if a particular transaction spills into 3 or more pages, the first page will have Header, Part A and a part of Part B (the item table), Footer; the last page will have Header, a part of Part B (the item table), Part C and the Footer and the intermediate pages will have the header, item table and the footer.

Now here’s the question:

How to ensure that there is at least one item in the last page?

It’s possible to imagine that the number of items in the transaction is such that the last page just has Part C and the footer. Meaning all the items have managed to fit into the previous pages and the last page has just Part C and the Footer. Or even Part C has got split between the last page and the page prior to the last page. And customers get super annoyed and obsessive about it.

Actual Question: What function (Jinja, CSS, HTML, etc.) to use to count the number of items in the last page of the PDF of a Print format and if that is 0, insert a page break after the (N-1)th item where N is the number of items in the transaction?

Any ideas?

Thanks

Jay

1 Like

Hi @JayRam
I am facing same issues. Can’t figure it out. Please let me know the process if you resolved it.

Thank you.

You can try this.