[reportlab-users] vertical text in table cell with height None

238 views
Skip to first unread message

Arkadi Colson

unread,
Apr 18, 2017, 7:58:54 AM4/18/17
to reportl...@lists2.reportlab.com

Hi

I'm using this function to rotate the text vertically:

class RotatedParagraph(Flowable):
        def __init__(self, text):
                Flowable.__init__(self)
                self.text       = text

        def draw(self):
                canvas = self.canv
                canvas.rotate(90)
                fs = canvas._fontsize
                canvas.translate(0, -(self.width/2) -(self.aW/2))
                self.text.canv = canvas
                try:
                        self.text.draw()
                finally:
                        del self.text.canv

        def wrap(self, aW, aH):
                self.aW, self.aH = aW, aH
                w, h = self.text.wrap(aH,aW)
                self.width,self.height = h, w
                return h, w*1.1

Since we upgraded from reportlab 2.5 to 3.3 this is the result:


It looks like that the available height value has been changed. It's now a very high number. Any idea what's the problem here and how I can put vertically rotated text in a variable height cell?

Thanks!

BR
Arkadi

Robin Becker

unread,
Apr 18, 2017, 9:49:15 AM4/18/17
to reportlab-users
I think you might not be specifying a height for the row in question. By default
the width of a paragraph is the same as aW (in this case aH). We improved
paragraph wrapping in later reportlab so this is just exposing a bug in how
layouts used to fail ie the old case didn't wrap properly and then wrote outside
the actual height of the cell. Since paragraphs don't ask for extra width the
dynamic row height mechanism isn't going to help.


On 18/04/2017 12:58, Arkadi Colson wrote:
> Hi
>
> I'm using this function to rotate the text vertically:
>
> class RotatedParagraph(Flowable):
> def __init__(self, text):
> Flowable.__init__(self)
> self.text = text
>
> def draw(self):
> canvas = self.canv
> canvas.rotate(90)
> fs = canvas._fontsize
> canvas.translate(0, -(self.width/2) -(self.aW/2))
> self.text.canv = canvas
> try:
> self.text.draw()
> finally:
> del self.text.canv
>
> def wrap(self, aW, aH):
> self.aW, self.aH = aW, aH
> w, h = self.text.wrap(aH,aW)
> self.width,self.height = h, w
> return h, w*1.1
>
> Since we upgraded from reportlab 2.5 to 3.3 this is the result:
>
>
> It looks like that the available height value has been changed. It's now a very
> high number. Any idea what's the problem here and how I can put vertically
> rotated text in a variable height cell?
>
> Thanks!
>
> BR
> Arkadi
>
>
>
> _______________________________________________
> reportlab-users mailing list
> reportl...@lists2.reportlab.com
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
>
--
Robin Becker


_______________________________________________
reportlab-users mailing list
reportl...@lists2.reportlab.com
https://pairlist2.pair.net/mailman/listinfo/reportlab-users
Reply all
Reply to author
Forward
0 new messages