4

I have a problem with wkhtmltopdf. I have an <article> element that spans across multiple pages. It's is not defined in the CSS, the width is fixed. Yet when the element breaks across pages, sometimes parts of the text are stuck on both the the previous and the next page.

Do you have any idea what might cause that?

And a second question. In the screenshot below you can also see a strange square character, right after the word "Empfindung", that appears at some (not all) of the line endings (yet it's not a line ending, it's supposed to be a regular space). I tried replacing it with a regular space again, yet it stays the same. The encoding of the source website (and the content) is utf-8.

Thank you very much in advance!

enter image description here

1
  • 1
    This is kind of two questions rolled up into one, but what is the byte value of the square character? If you view it in a hex editor, what does that character look like? I had that problem with 0x1F and also the UTF-8 BOM that came from some pasted text right in the middle of text. Feb 12, 2013 at 8:15

1 Answer 1

6

Page breaking is a known problem with wkhtmltopdf and there's not so much you can do about it, but add a special div that forces the page break.

Maybe also look at this: wkhtmltopdf automatic page breaks

With regards to the square character: usually this is a font issue. If you want to know the reality then it's wise to just run it through an online converter that uses wkhtmltopdf (like htm2pdf.co.uk) and/or post the actual HTML you're using.

update from the wkhtmltopdf issuelist (http://code.google.com/p/wkhtmltopdf/issues/detail?id=9):

create a style that forbids to create a page break inside a class

<style>
.nobreak {
    page-break-inside: avoid;
}
</style> 

and put all your table cells, paragraphs, ... that should not be torn apart into a

<div>:

...<tr><td><div class="nobreak">This cell spans several <br> lines but<br> needs to be on the same page</div></td><td><div class="nobreak"> the second cell<br>that is not broken ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.