Hannoun Yassir
Hannoun Yassir

Reputation: 21222

Paged printing with javascript

I have 4 divs that I want to print each one on a separate page. Is this possible if so how?

Upvotes: 2

Views: 308

Answers (3)

tvanfosson
tvanfosson

Reputation: 532665

Add a print stylesheet, if you don't already have one. Set media="print" when including that stylesheet. Among other things, add a class with the page break settings, such as:

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

Then apply that style wherever you need a page break forced.

<div id="div1" class="break-after"></div>
<div id="div2" class="break-after"></div>
<div id="div3" class="break-after"></div>
<div id="div4" class="break-after"></div>

Upvotes: 3

Darin Dimitrov
Darin Dimitrov

Reputation: 1039418

You could use page breaks in your print CSS.

Upvotes: 1

Anomie
Anomie

Reputation: 94834

Use the CSS page-break-before:always on each DIV. See the documentation for more info.

Upvotes: 3

Related Questions