开发者

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?


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>


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


You could use page breaks in your print CSS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜