Printing multiple custom detail views page by page can cause problems because they are printed continuously by default and not page by page. I show a simple trick using CSS to solve this problem. This trick is not new - and yet I hope it helps some of you.
Problem
Record after Record but not not page by page:
This is what I have

This is what I want

Custom print templates
For specially adapted printouts you can create your own template in HTML and switch it on in the init-function by changing $options->TemplateDVP
.
function dienstreisen_init(&$options, $memberInfo, &$args) { $options->TemplateDVP = 'templates/dienstreisen_templateDVP_custom.html'; return TRUE; }
This print template can be used for printing a single record...

With a little work and HTML/CSS knowledge, you can produce quite respectable printouts like this one. In this case it is an internal accounting document for the accounting of travel expenses of employees.

Batch printing multiple records
The same print template can also be used after selecting multiple records on table view (TV).

It can be problematic that all data records are printed one after the other but not page by page. The red arrows indicate the places where a page-break shoul be, but isn't:

Page-break options in CSS
There is a simple trick using HTML and CSS in your print template for adding page-breaks after each record:
Add the following line of HTML code at the end of your print template:
<p style="break-after: always;"></p>
or
<p style="page-break-after: always;"></p>
A page break is added after this paragraph - after each record. This leads to exactly the print output I want:

There are more options for page-break. The following place is a good starting point for learning and experimenting:
- https://developer.mozilla.org/en-US/docs/Web/CSS/break-after
- https://developer.mozilla.org/en-US/docs/Web/CSS/break-before
I hope you enjoyed reading the article and learned something new today
Kind Regards,
Jan