py-pdf / fpdf2

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

FlexTemplate multiline: It looks like that it puts space/newline between lines. Expected behavior? #1237

Open yi0n opened 1 month ago

yi0n commented 1 month ago

Hi,

for this behavior, I searched here and in the 'forked from' repo this kind of issue and also SO, but haven't found anything that's close related. I posted the problem already on SO with my Code and Screenshots. Please have a look: https://stackoverflow.com/questions/78817119/fpdf2-template-multiline-space-between-text-like-a-newline Maybe a line_height issue?

Thanks in advance.

andersonhc commented 1 month ago

Hi @yi0n , At first glance you can adjust the space between the lines by adjusting the difference between 'y1' and 'y2'. Let me know if that doesn't help and I'll take a look in the code.

gmischler commented 1 month ago

The multiline text in the templates is just a wrapper around multi_cell(), where h = y2 - y1.

It is important to remember that this is the height of one single line, not of the complete block of text.

yi0n commented 1 month ago

Thank you. That explains a lot. Now I tried by setting the y1-y2 difference at first by the font size what resulted in still to much space. I figured out that it seems like a good value for the line height is half the size of the font-size.

Sidenote: As I consulted the docs for table cell padding at https://py-pdf.github.io/fpdf2/fpdf/table.html, i noticed that it says padding (left, top, right, bottom) for the cell. but through my testing I experienced its: (top, right, bottom, left) Maybe someone can change that.

Lucas-C commented 3 weeks ago

Hi @yi0n 🙂

Given your last comment, I understand that your problem is solved?

Do you have any more questions, or can we close this issue?