[reportlab-users] How to write text upside down?

Gregory Piñero gregpinero at gmail.com
Sat Dec 1 23:51:50 EST 2007


Ah, I figured it out, you need to make height and width negative when
drawing strings upside down:

def write_text(c,front_text,inside_text):
c.setFillColor(black)
c.setFont("Helvetica", 22)
c.drawCentredString(3*(width/4), int(.4*height), front_text) #want
right side up
c.setFont("Helvetica", 18)
c.rotate(180) #write text upside down so it's right when folded.
c.drawCentredString(-width/4, -int(.75*height), inside_text) #want
upside down
c.rotate(180) #put back right side up
c.setFont("Helvetica", 8)
c.drawCentredString(width/4, int(.13*height),
"Created while fondly thinking of you at") #want right side up

Thanks,

Greg

On Dec 1, 2007 11:03 PM, Gregory Piñero <gregpinero at gmail.com> wrote:

> I'm trying to write some text, one string I want to put upside down

> since the printed document is meant to be folded.

>

> Here's what I'm currently trying, with calling c.rotate(180) but no

> text seems to show up on the document after I call that.

>

> def write_text(c,front_text,inside_text):

> c.setFillColor(black)

> c.setFont("Helvetica", 22)

> c.drawCentredString(3*(width/4), int(.4*height), front_text) #want

> right side up

> c.setFont("Helvetica", 18)

> c.rotate(180) #write text upside down so it's right when folded.

> c.drawCentredString(width/4, int(.75*height), inside_text) #want upside down

> c.setFont("Helvetica", 8)

> c.drawCentredString(width/4, int(.13*height),

> "Created while fondly thinking of you at") #want right side up

>

> Is there a different method I should be using?

>

> Thanks again,

>

> Greg

>




--
Gregory Piñero
Chief Innovation Officer
Blended Technologies
(www.blendedtechnologies.com)


More information about the reportlab-users mailing list