Weasyprint: Random Line Breaks

Created on 9 Jul 2020  Â·  3Comments  Â·  Source: Kozea/WeasyPrint

First and foremost: many thanks for this awesome tool! It’s far and away the best html-to-pdf solution I’ve come across 😊

One issue I’m having though is that the pdfs I generate contain random line-breaks from time to time, with seemingly no pattern to this behaviour. For example, a list item generated by Trix with only text inside (i.e. no additional HTML) will sporadically get broken like this (note the second list item has the exact same content in this case):

<ul>
  <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
  <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</li>
</ul>

Screen Shot 2020-07-09 at 17 00 16

One workaround I’ve found is to set display: inline-block on the offending elements (and hacking list styles with content: "•" on li::before) , which makes the lines break as intended. _But_ doing this also seems to prevent these elements from breaking as intended at the end of a page. The generator no longer splits the element across two pages:

Screen Shot 2020-07-09 at 17 13 11

So, in short, the issue I have at the moment is that I’m either stuck with random line breaks or unwanted page breaks. I cannot exclude the possibility of this being related to Trix, though it seems unlikely given that the HTML it generates doesn't differ from hard-coded HTML.

Has anyone experienced the same problem and, if so, were you able to find a solution?

All 3 comments

Hello,

Thanks a lot for reporting this issue!

I think (hope?) that it’s a duplicate of #1051. Could you please try the current master branch and tell if the bug is fixed?

That was it! Thanks a million for this and the quick response!

Good news. Have fun with WeasyPrint!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grewn0uille picture grewn0uille  Â·  4Comments

Tontyna picture Tontyna  Â·  4Comments

amarnav picture amarnav  Â·  5Comments

whitelynx picture whitelynx  Â·  5Comments

mjbeyeler picture mjbeyeler  Â·  4Comments