Kev
Kev

Reputation: 2716

Printing html file with pagebreaks

I am trying to create a program / service that can read an html file and print it.

I need to include page breaks; but don't know how to define them or make them print correctly.

The html files are mine, so I can add any elements to them to represent the page break position. I was thinking a hidden field, or using the page-break-before:always css style in the next element.

How should I approach this?

Upvotes: 0

Views: 1157

Answers (1)

muetzenflo
muetzenflo

Reputation: 5682

Css is the way to go. I'd recommend to create a class "page-break":

.page-break { page-break-before: always; }

Whereever you add this class to an HTML-element you get a page-break before this element (e.g. before every h1). This tutorial covers almost every part of CSS and printing: http://coding.smashingmagazine.com/2011/11/24/how-to-set-up-a-print-style-sheet/

hope this helps

Upvotes: 1

Related Questions