0

I'm dynamically loading HTML from a database, then formatting it and printing it to paper. Many times, the page break is in the middle of a DIV or other container element. How can I format my output so that it doesn't do that?

enter image description here

Shawn
  • 3,031
  • 4
  • 26
  • 53

2 Answers2

1

You will need to create a print stylesheet with a media query to target only print devices. There is a subset of CSS which can be used to style printed media. You can find detailed syntax help here.

CSS Printing: Avoiding cut-in-half DIVs between pages?

Community
  • 1
  • 1
Seth Ficke
  • 26
  • 1
0

the answer was CSS

page-break-inside: avoid;

used like this:

<div style="page-break-inside: avoid;">
  text goes here
</div>
Shawn
  • 3,031
  • 4
  • 26
  • 53