crabbly / Print.js

A tiny javascript library to help printing from the web.
MIT License
4.28k stars 672 forks source link

HTML Page Breaks being ignored #625

Open pipratcl opened 2 years ago

pipratcl commented 2 years ago

I wonder if you can help. I have an HTML document with pagebreaks specified which are being ignored on print/print preview with PrintJS.

I am using PrintJS v1.5.0 and seeing this behaviour in Edge and Chrome (not tried other browsers).

In my HTML document I have specified the following css class:

Then at different point in my document the class is referenced e.g.

But on opening the print dialog with PrintJS, in the preview pane the page breaks are being ignored. (They are interpreted using CTRL + P).

Based on historic similar issues I have tried: 1) Calling print JS with the targetStyles: [''] parameter i.e. printJS({ printable: 'REPORT_DATA', type: 'html', targetStyles: [''] }); 2) Placing my @media print css in a separate file and referencing the file URL in the PrintJS css parameter 3) Avoided the @media print css, replacing it with css: '.pagebreak { page-break-after: always; }'

However none of these steps have resolved my issue of the page breaks being ignored.

Can you help?