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
![](https://appgini.bizzworxx.de/wp-content/uploads/2020/11/image-44-379x1024.png)
This is what I want
![](https://appgini.bizzworxx.de/wp-content/uploads/2020/11/image-43-358x1024.png)
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...
![](https://appgini.bizzworxx.de/wp-content/uploads/2020/11/image-45.png)
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.
![](https://appgini.bizzworxx.de/wp-content/uploads/2020/11/image-39.png)
Batch printing multiple records
The same print template can also be used after selecting multiple records on table view (TV).
![](https://appgini.bizzworxx.de/wp-content/uploads/2020/11/image-38-1024x402.png)
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:
![](https://appgini.bizzworxx.de/wp-content/uploads/2020/11/image-40-350x1024.png)
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:
![](https://appgini.bizzworxx.de/wp-content/uploads/2020/11/image-41.png)
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