Problem when justifying text in a <p> tag that contains another tag (b,u, i...) #930
-
It seems that when align="justify" is applied to text in the tag that contains another tag (b,u, i...), the resulting text is divided by a line break. from fpdf import FPDF, HTMLMixin
class PDF(FPDF, HTMLMixin):
def header(self):
self.set_font('Arial', 'B', 12)
self.cell(0, 10, 'My PDF Document', 0, 1, 'C')
def footer(self):
self.set_y(-15)
self.set_font('Arial', 'I', 8)
self.cell(0, 10, 'Page %s' % self.page_no(), 0, 0, 'C')
pdf = PDF()
pdf.add_page()
html_content = """
<p align="justify">This is a sample text that will be justified in the PDF. <u>This</u> is a sample text that will be justified in the PDF. This is a sample text that will be justified in the PDF. This is a sample text that will be justified in the PDF.</p>
"""
pdf.write_html(html_content)
pdf.output('output.pdf')``` |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @Taoufiq-El, thank you for reporting this. I'm currently working on PR #897, which will hopefully fix it. Unfortunately I can't tell yet when it will be ready to merged, since it involves some nontrivial new functionality. |
Beta Was this translation helpful? Give feedback.
-
@Taoufiq-El, I've just checked in #897, which should solve the problem (as long as it doesn't happen within a table).
Edit: Published with release 2.7.6 |
Beta Was this translation helpful? Give feedback.
@Taoufiq-El, I've just checked in #897, which should solve the problem (as long as it doesn't happen within a table).
You can install the currently unreleased code (about to be released as 2.7.6 very soon) like this:pip install git+https://github.com/py-pdf/fpdf2.git@master
and test it in your environment.Edit: Published with release 2.7.6