-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Page Break in PDF #2982
Comments
@aiphee - Even with Unfortunately, v.0.12.4 has it's own issue that prevents me from using it. |
Well the answer is correct, if it is not working for some reason for you, then you need to fill full bug report, so it can be solved. AFAIK, the biggest pain in the ass for the open source developer, is dealing with overwhelming and incomplete bug report. |
There are a lot of reported problems with page-break-xxxx within various parts of tables. I don't recall seeing such reports for other elements (but that doesn't mean they don't exist!). Make sure your page-break CSS is within any correct media so that wkHTMLtoPDF is seeing it, and try to avoid page breaks within tables. See if that helps at all. Do some experimentation, such as a page break before every |
I'm using the basic The relevant part of my css is:
Which works perfectly if I just ⌘-P from the browser, but isn't working in wkhtmltopdf. |
use this classes for page break :
|
Hi @ansezz how should looks the html then? I mean, will be nice to have an example. something like this?
UPD: damn! It works :) 👍 |
Hi @ ansezz and adamasantares, still I am facing problem with the page break. can you help me out? |
This build is based on d08d0bf. This commit was created by the following Travis CI build and job: https://travis-ci.org/greenelab/manubot-rootstock/builds/255655530 https://travis-ci.org/greenelab/manubot-rootstock/jobs/255655531 [ci skip] The full commit message that triggered this build is copied below: page-break control using HTML classes (#35) Refs wkhtmltopdf/wkhtmltopdf#2982 (comment)
This build is based on d08d0bf. This commit was created by the following Travis CI build and job: https://travis-ci.org/greenelab/manubot-rootstock/builds/255655530 https://travis-ci.org/greenelab/manubot-rootstock/jobs/255655531 [ci skip] The full commit message that triggered this build is copied below: page-break control using HTML classes (#35) Refs wkhtmltopdf/wkhtmltopdf#2982 (comment)
I can try. What is your html code? |
I have the same issue with WKHTMLTOPDF 0.12.4, regardless of browser used. in a webapp. Even when I say media="print" the print-window/-console does not adhere to the setting, in any browser on Windows. Very frustrating, even making all elements display:block; (which is a prerequisite). It does not matter if I try this on a Hx, p, table, tr, td or div, on all HTML-tags this CSS-setting is ignored. Anyone having this working anywhere? The settings page-break-before and page-break-after at least are working in the print-window/-console. But not the -inside setting :-( CSS: .contentBlock, div, h2, h3, p {
display:block ! important;
page-break-inside:avoid ! important;
} HTML: <html>
<body>
<div id="header"></div>
<div id="sidebar"></div>
<div id="content">
<div id="container">
<div class="contentBlock">
<h2>Some header</h2>
<p>[some content goes here]</p>
</div>
<div class="contentBlock">
<h2>Some header</h2>
<p>[here goes some other content]</p>
</div>
<div class="contentBlock">
<h2>Some header</h2>
<p>[final block of content goes here]</p>
</div>
</div>
</div>
</body>
</html> UPDATE: If i strip the page down to its bare necessities (without html, body and the containing divs) I can get WKHTMLTOPDF to adhere the the page-break-inside:avoid setting :-) That means rendering the same page differently for WKHTMLTOPDF than for the browser. I achieve this with a stylesheet for all rendered HTML-elements that are to be hidden ( Leftover HTML sent to WKHTMLTOPDF: <div class="contentBlock">
<h2>Some header</h2>
<p>[some content goes here]</p>
</div>
<div class="contentBlock">
<h2>Some header</h2>
<p>[here goes some other content]</p>
</div>
<div class="contentBlock">
<h2>Some header</h2>
<p>[final block of content goes here]</p>
</div> |
Everyone having problems with page breaks not working with CSS rules, make sure none of the parents divs are floated to either side. I had a parent container with |
Thanks for the tip @matejsvajger, helped me realize why my Here's a basic example that worked for me:
You could also add the |
Sanity restored, your solution worked! |
Thank you brother. You saved me 👍 |
For dynamic repetitive content, we may use the following three properties together -
|
Hi, Im using wkhtmltopdf 0.12.5 version. Page break before is not working fine for me.I tried all the above solutions. Please suggest. |
@Krishnaveni26 i suggest you post the code snippet you are using. |
i'm also having problems with this, tried @BoontjieBoon exact same code but it didn't work (ps: downgraded to version 0.10.0 rc2 and is working) |
|
@Krishnaveni26 well because you are using |
Hi @TheAndroidGuy .... I tried the above one, but still the page break is not working. |
@Krishnaveni26 I don't know then. It works properly on my environment. |
Any news on this issue? The CSS property |
I'd same problem and spent days changing versions, trying out solutions and finally found this solution for page break working -
You have to use standard page-break-after/before CSS as mentioned in above replies + set this overflow and it should work! |
Thanks - the issue was overflow related for me also. Removing overflow-x: hidden in parent elements fixed it. To be clear I found this different to how the same CSS is currently rendered in Chrome, FF and IE11, where I didn't need to remove overflow-x to get page breaks working as expected. |
What mean by " to be hidden"?? |
I recently upgraded from 0.12.2.4 (Ubuntu 16) to 0.12.5 (Ubuntu 18), and now page breaks are not working for me. The code has not changed. My html: <title>This is the HTML Title</title> <style> .new-page { page-break-before: always !important; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size:16px; width:100%; text-align:right; } </style>text content here And I use it with this command: |
Hi
I want to convert some html files to pdf but on some points i want to have page breaks.
Maybe we can have some pagebreak tag in html and use that for splitting pages in pdf
I did not find any parameter for this, Please help me with it.
The text was updated successfully, but these errors were encountered: