[reportlab-users] rotated text (90?) in a table cell
Paulino
paulino1 at sapo.pt
Tue Oct 17 19:31:52 EDT 2006
Maybe it's better to send the entire script:
----------------------
from reportlab.platypus.flowables import Flowable
from reportlab.platypus import SimpleDocTemplate, Paragraph, Table
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet
stylesheet=getSampleStyleSheet()
normal = stylesheet['Normal']
class TTR(Flowable): #TableTextRotate
'''Rotates a tex in a table cell.'''
def __init__(self, text ):
Flowable.__init__(self)
self.text=text
def draw(self):
canvas = self.canv
canvas.rotate(90)
canvas.drawString( 0, -1, self.text)
doc=SimpleDocTemplate('vertical.pdf')
cli=Paragraph( 'Clientes de cobranca muito duvidosa', style=normal)
data=[ [ 'codigo', TTR('nivel'), 'descricao'],
[ '11', '0', 'Caixa'],
[ '21', '1', cli ] ]
st=[( 'ALIGN',(1,0), (1, -1), 'CENTER' ),
('INNERGRID', (0,0), (-1,-1), 0.25, colors.blue ),
('BOX', (0,0), (-1,-1), 0.25, colors.blue ),
('VALIGN', (0,0), (-1,-1), 'MIDDLE' ) ]
tb=Table(data, colWidths=(40, 40, 100), style=st )
story=[tb]
doc.build(story)
-------------------
> With this simple class I am able to put text in a table cell in a
> vertical orientation, but the row's height doesn't adjust to it's
> content, thetext goes over into the upper cell.
>
> How can I fix this?
>
>
> class TTR(Flowable): #TableTextRotate
> '''Rotates a tex in a table cell.'''
> def __init__(self, text ):
> Flowable.__init__(self)
> self.text=text
> def draw(self):
> canvas = self.canv
> canvas.rotate(90)
> canvas.drawString( 0, -1, self.text)
>
More information about the reportlab-users
mailing list