I have an HTML page that is generated dynamically, based on a specific form. Once an HTML page is generated, it can be converted to PDF using wkhtmltopdf
.
If the page is too long, wkhtmltopdf
will automatically split it into multiple pages, but I want to have control over WHERE the split will happen.
I need this because each page will contain specific charts for the specific information that will be displayed on the page and whenever automatic split happens, I sometimes get a chart not being related to the text displayed on the page.
So ideally I want to be able to determine whether the form generated content is too long for 1 page or not and then manually add a new page with controlled content.
To add a new page, I'm basically using the following CSS rule, which works fine:
@media print {
.new-page {
page-break-before: always;
}
}
The application is built in Laravel
+ Svelte.js
(but I don't think it matters much, because I'm just trying to figure out how to approach the issue in general).
Perhaps I could get some recommendations?
To control where to split your page, you can use the page-break-after attribute.
Example :
<div style="page-break-after:always;"></div>
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.