'How to solve line discontinuity in html table (python fpdf2 generate PDF documents)
I try to generate a PDF document. I use PYPDF2. The PDF contains a table which is generated by :
class HTMLMixin:
HTML2FPDF_CLASS = HTML2FPDF
def write_html(self, text, *args, **kwargs):
"""Parse HTML and convert it to PDF"""
kwargs2 = vars(self)
# Method arguments must override class & instance attributes:
kwargs2.update(kwargs)
h2p = self.HTML2FPDF_CLASS(self, *args, **kwargs2)
text = html.unescape(text) # To deal with HTML entities
h2p.feed(text)
I did not write this class, it is part of the library. Certain columns however has more content so they contains line-breaks. Because of these line-breaks the result is like this:
How can I have full, continuous side-lines for each columns in the table? (Just like for column 'Teilnehmer')
Solution 1:[1]
This is a current limitation of the library, reported here on the project bug tracker: https://github.com/PyFPDF/fpdf2/issues/91
The documentation also lists the limitations of the HTMLMIxin
: https://pyfpdf.github.io/fpdf2/HTML.html#supported-html-features
Notes:
- tables should have at least a first
<th>
row with awidth
attribute.- currently multi-line text in table cells is not supported. Contributions are welcome to add support for this feature! ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Lucas Cimon |