Giter Club home page Giter Club logo

Comments (8)

viniciustozzi avatar viniciustozzi commented on July 18, 2024 1

Oh I misunderstood, I assumed line_height was about the cell height but it makes more sense that it is about the text line. I tried now with different and smaller values and it solves my problem, thank you!

from fpdf2.

Lucas-C avatar Lucas-C commented on July 18, 2024 1

Oh I misunderstood, I assumed line_height was about the cell height but it makes more sense that it is about the text line. I tried now with different and smaller values and it solves my problem, thank you!

Great, glad that helped you 😊

from fpdf2.

Lucas-C avatar Lucas-C commented on July 18, 2024

Have you tried passing line_height=10 to FPDF.table()?

cf. https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.table

from fpdf2.

Lucas-C avatar Lucas-C commented on July 18, 2024

Hi @viniciustozzi

Feedbacks and extra questions are welcome regarding this 😊

But without any answer from you we will close this issue at some point.

from fpdf2.

viniciustozzi avatar viniciustozzi commented on July 18, 2024

Hi @Lucas-C, sorry for the delay in my response. I tried what you suggested:

with self.table(
    headings_style=FontFace(fill_color=235), line_height=10
) as table:
    for data_row in table_data:
        table.row(data_row)

but it does not really solve the issue, I noticed that this is enough if the text has only one line, then the spacing between the text and the table border is smaller, but when I have a multiple line text as in this example, the vertical distance between the lines of text is still quite big.

from fpdf2.

Lucas-C avatar Lucas-C commented on July 18, 2024

but it does not really solve the issue, I noticed that this is enough if the text has only one line, then the spacing between the text and the table border is smaller, but when I have a multiple line text as in this example, the vertical distance between the lines of text is still quite big.

OK.
If what matters is "the spacing between the text and the table border", then you should consider setting some cell padding:
https://py-pdf.github.io/fpdf2/Tables.html#setting-cell-padding

However, if you want control over the line height on a per-row or per-cell basis, this is currently not supported.
But it's a feature that could potentially be added to fpdf2.

from fpdf2.

viniciustozzi avatar viniciustozzi commented on July 18, 2024

I think it would be a nice feature to have. In the pdf file I uploaded as an example, I think it's weird that there is so much space between each line of text, but when I look at the padding documentation images in the link you provided there seems to be not much space between the lines inside a call in the table, I wonder why. Maybe it's the font I am using?

from fpdf2.

Lucas-C avatar Lucas-C commented on July 18, 2024

In the pdf file I uploaded as an example, I think it's weird that there is so much space between each line of text, but when I look at the padding documentation images in the link you provided there seems to be not much space between the lines inside a call in the table, I wonder why. Maybe it's the font I am using?

In fpdf2, the line spacing in tables is only controlled by one setting: line_height.
Fonts do not have any impact on this spacing.

Have you tried to lower the value of line_height below 10, to see how that reduce the line spacing?
Does that solve your problem?

from fpdf2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.