简体   繁体   中英

How to ensure when a html file is printed pdf, at some points new pages must start?

How to print multiple html files into a single pdf file?

The current question stems from the above question.

If I merge multiple HTML files into a single HTML file, I want to make sure when I print the single file to pdf, the original HTML pages all started with a new pdf page. How can I achieve this? Is there an html tag that a browser might understand when printing an HTML file to pdf?

You can achieve this with CSS by specifying a print media rule that applies the page-break-before or page-break-after to a specific element inserted in HTML as a divider between each original html page. Alternatively if you have some container element to each original HTML, you could apply the rule to that.

Something like:

@media print {
    .divider {
        page-break-after: always;
     }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM