Lately I had to use window.print() to do some reports printing and I encountred a small problem – how to print some dynamic generated html code from one window on a separate pages. After some research I’ve found a solution – CSS styles.

Page-break-after and page-break-before are properties that I’ve been looking for. By creating f.e. DIV element and setting style=”page-break-before: always” property You can be sure that code inside this div will be always printed on a separate new page. By adding style=”page-break-after: always” property You can expect that everything after Your DIV will be printed on a separate new page. These are simple two properties but for me they are lifesavers 😀