Skip to content

table: raise a clear error when text_align has too few values - #2056

Open
RavSinghChandan wants to merge 1 commit into
py-pdf:masterfrom
RavSinghChandan:table-text-align-length
Open

RavSinghChandan wants to merge 1 commit into
py-pdf:masterfrom
RavSinghChandan:table-text-align-length

Conversation

@RavSinghChandan

Copy link
Copy Markdown

FPDF.table() accepts a tuple for text_align, one value per column. With fewer values than columns, such as text_align=("CENTER", "RIGHT") for a 4-column table, rendering failed with a bare IndexError: tuple index out of range.

It now raises ValueError: Invalid .text_align specified: missing alignment for table() column 3 on row 1, the same kind of message col_widths already gives when it is too short. Tables with enough values behave as before. Added a test for the message.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant