Print format page numbering

Hello everyone,

I’m working on a custom print format in Frappe and I’ve run into a tricky situation. Here’s what I’m trying to achieve:

  1. The print format needs to contain invoice details.
  2. These details need to be printed twice on the same format - once for the transporter and once for the supplier.
  3. Each set of details (transporter’s and supplier’s) should have its own page numbering.

Currently, I’ve managed to create a print format that duplicates the content, but I’m stuck on the page numbering. When I use the existing method to show page numbers in the footer, it continues the numbering from the transporter’s section to the supplier’s section.

For example, if the transporter’s section is 2 pages, the supplier’s section starts at page 3 instead of page 1.

What I need:

  • Transporter’s section: Page 1 of 2, Page 2 of 2
  • Supplier’s section: Page 1 of 2, Page 2 of 2 (restarting the count)

Important note: The client specifically doesn’t want two separate print formats. They prefer a single print format that handles both sections.

Has anyone encountered a similar situation? How can I implement independent page numbering for each section within a single print format?

Any suggestions or code samples would be greatly appreciated. Thanks in advance for your help!