-
Notifications
You must be signed in to change notification settings - Fork 330
Description
The following code should write two strings on the same position.
Instead the blue string wraps in the correct way and is printed in the correct position, while the red string does wrap in the correct way, but is printed after skipping one empty line.
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
pdf.set_font(family='Helvetica', size=20)
# print one blue long line without spaces
pdf.set_xy(10, 10)
pdf.set_text_color(255, 0, 0)
pdf.write_html('X' * 50)
# print one red long line with spaces
pdf.set_xy(10, 10)
pdf.set_text_color(0, 0, 255)
pdf.write_html('Y' * 25 + ' ' + 'Y' * 25)
pdf.output('html.pdf')The code above is a simple minimal example, and it's hard to believe that one may need such a long text to correctly wrap. But in my real application I play with margins and use write_html to write formatted text in a table-like format (because tables do not allow font tags or other formatting techniques inside a cell.)
Here is an example of the result of my function, where write_html has ben used to write text in different sizes and colors in a table format. Notice the text highlighted in red, which is shifted down one line:

Environment
- Operating System: Windows
- Python version: 3.7
fpdf2version used: 2.7.4
