py-pdf / fpdf2

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

Why is line_height not available directly in the write() function? #1256

Closed Alexis-Falquier closed 3 weeks ago

Alexis-Falquier commented 2 months ago

Currently to write a block of text and adjust the line height one would need to do this:

...
with pdf.text_columns(line_height=1.3) as text_block:
        text_block.write(text=<block of text>)
...

while it isnt much, it seems logical for the write() function to have the ability to manipulate the text it is writing and therefore have line height as a parameter, as such: pdf.write(text=<block of text>, line_height=1.3)

In fact it would make sense that write() have most of the parameters available in text_columns() is there a reason that they are not?

Lucas-C commented 2 months ago

Hi @Alexis-Falquier

For text regions, the goal is to group together the settings for rendering several lines of text: https://py-pdf.github.io/fpdf2/TextRegion.html

However, if you need to render a single line of text, you can use:

I'll let @gmischler correct me if need be, as he designed the text regions API 🙂

Lucas-C commented 1 month ago

Hi

Unless you want to add something on the subject @Alexis-Falquier and @gmischler, I'm probably going to close this issue before the end of the year 🙂