Yes, it's a good start! If I have n documents in the app you will have to add the function at the beginning of each but it is not a big problem, thank you!
Remaining on the subject, there are 2 other issues related to double-sided management:
If I am within a cycle in a single report, how do I manage the jump page? Let me explain: let's suppose that I have to print a section in a report several times, and I want it to always start on an even page. Not having the $pdf.pages and not being able to use counters because we do not know how long the previous page can be, how could you do?
In the case of headers added via pdf utils using the merge whole document option, these are also rendered over the blank pages. Is there a workaround to prevent this from happening?