py-pdf / fpdf2

Simple PDF generation for Python
https://py-pdf.github.io/fpdf2/
GNU Lesser General Public License v3.0
993 stars 227 forks source link

HTML: indent of lists on new line not flush #1212

Open xbln opened 1 week ago

xbln commented 1 week ago

The indentation of list items is not flush on a new line

Should be:

But is:

* jfjkjkfjfd dflfdlflklkfd lkfdklfdklmf fdklfdklfd ldfklfdklfd lkdfklfkld dflkfdkldf ldfklkkldfl fdldflkfdklklfd ldflkfdlkdfl ldf df fd lldf ldfllkfdklfkl lkfdklfdkl kldfklfdlkfd lkdflkfdlkdflk lkdfkllkfdkfd ldfl fd

Use of tag_indents={"li": 5} doesn´t help I checked also ver 2.7.10 (master), but no improvement

gmischler commented 1 week ago

Welcome to fpdf2, @xbln !

As requested in the bug report template (that you summarily deleted instead of using it), please show us a minimal code example that produces the described result.

The explanation you gave us does not make it possible to reproduce the effect you're seeing. And if we can't reproduce an error, then we can't fix it.

Lucas-C commented 1 week ago

I agree with @gmischler, we need some SHORT code snippet to be able to help you 🙂

As mentioned in the bug report template that you must have seen, this page provides good explanation on how to craft a good minimal, reproducible example: https://stackoverflow.com/help/minimal-reproducible-example

xbln commented 6 days ago

Sorry, here is the code:

from fpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.write_html("""
<p>Is:</p>
<ul>
    <li>Unordered list</li>
    <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>
<ol>
    <li>Ordered list</li>
    <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>
</ol>
Should be:
<ul>
    <li>Ordered list</li>
    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dolore magna aliqua. Ut enim ad minim veniam</li>
    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dolore magna aliqua. Ut enim ad minim veniam</li>
</ul>
<ol>
    <li>Ordered list</li>
    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dolore magna aliqua. Ut enim ad minim veniam</li>
    <li>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dolore magna aliqua. Ut enim ad minim veniam</li>
</ol>
""")
pdf.output("html.pdf")

Output is:image

gmischler commented 6 days ago

A few days ago #1170 has been merged, which fixes this (already reported in #1073).

Most likely your test with 2.7.10 (current HEAD) was just before that. Can you try that again please?