fpdf2
fpdf2 copied to clipboard
Rotate text for table header
Please explain your intent I would like to rotate text for a table header. In particular, have the heading text rotated so that it vertical in the table.
As far as I can tell this not currently possible.
Describe the solution you'd like
When using the pdf.table
functionality as described in the docs, it would be great if there was a way to rotate the text in the cells (particulary for the table header).
Wishful thinking... but perhaps defined something like this
with pdf.table() as table:
headings = table.row()
headings.cell("Long heading name 1", rotate=90)
headings.cell("Long heading name 2", rotate=90)
headings.cell("Age")
headings.cell("City")
I have looked into using the pdf.rotation
approach described here but it does not seem compatible with pdf.table
e.g. the following row.cell
will not be changed by the pdf.rotation (and would be difficult to know the x and y coordinates to use anyway)
with pdf.table() as table:
row = table.row()
with pdf.rotation(angle=90, x=10, y=300):
row.cell(text='Long heading name 1')
Additional context See below for example format (not produced by fpdf2) to clarify the format I am referring to.