Skip to content

How to horizontally center a table? align="CENTER" is not working for me #1304

Answered by Lucas-C
DerekRobin asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @DerekRobin

Thank you for the report.

Despite being mentioned in our documentation: https://py-pdf.github.io/fpdf2/Tables.html#setting-table-column-widths

align can be passed to table() to set the table horizontal position relative to the page, when it's not using the full page width. It's centered by default.

...it seems that this never worked properly... 😅

I tested the following code with fpdf2 version 2.7.0, where tables were originally introduced in this documentation was redacted:

from fpdf import FPDF

TABLE_DATA = (
    ("First name", "Last name", "Age", "City"),
    ("Jules", "Smith", "34", "San Juan"),
    ("Mary", "Ramos", "45", "Orlando"),
    ("Carlson", "Banks", "19", "L…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by DerekRobin
Comment options

You must be logged in to vote
5 replies
@Lucas-C
Comment options

@DerekRobin
Comment options

@DerekRobin
Comment options

@Lucas-C
Comment options

@DerekRobin
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants