I am using wkhtmltopdf to convert my HTML to PDF. My concern is regarding the page-break-* : ignore;
directives. I am trying to prevent the PDF from cutting to a new page right after a heading (among others), so the title and the content always stick together. Somehow, it really doesn't seem to work! I have tried in many different ways but the result is always the same, ignoring the CSS... any of the page-break-inside: avoid !important;
, page-break-after: avoid !important;
or page-break-before: avoid !important;
seem to work.
Edit:
A sample of my code would be:
index.html
...
<h2>HEADING</h2>
<div class="toctree-wrapper compound"></div>
<p>content content content content content content content
content content content content content content content content
content content content content content content content content
content content content content content content content content
content content content content content content content content
content content content </p>
...
style.css
...
p{
background: green !important; /* color to see where it breaks */
page-break-before: avoid !important;
}
h1, h2, h3, h4, h5, h6{
background: blue !important; /* color to see where it breaks */
page-break-after: avoid !important;
page-break-inside: avoid !important;
}
.toctree-wrapper.compound{
background: pink !important; /* color to see where it breaks */
page-break-after: avoid !important;
page-break-inside: avoid !important;
page-break-before: avoid !important;
}
Gives the following result:
Any ideas? Thanks!