[reportlab-users] Finding out the width/height of text
whit sheldon
whit.sheldon at gmail.com
Mon Jan 18 08:44:30 EST 2010
I have been using Reportlab and PIL to write text to an image for use as a
watermark. In PIL one can do something like this:
from PIL import Image as IMG
from PIL import ImageFont, ImageDraw, ImageOps
tmpimg = IMG.new("RGB", (some_x,some_y), bgcolor)
# get space needed to render text
draw = ImageDraw.Draw(tmpimg)
sizex, sizey = draw.textsize(txt, font=font)
# resize image to hold text
tmpimg = tmpimg.resize((sizex,sizey),IMG.ANTIALIAS)
--Whit
On Mon, Jan 18, 2010 at 7:03 AM, Jotham <jotham.read at gmail.com> wrote:
> Hello,
>
> I am wanting to use ReportLab to generate both a bitmap (for live preview
> in a client application) and PDF for dispatch to a printer. I have a client
> application that allows some basic alterations to be made by the user, for
> this to work I need to be able to find out some geometry information for a
> given piece of text at a given font and style. I can't see how to do this
> in ReportLab. Ideally I would be able to render out just the text in
> question to a bitmap surface of some kind, work with that, and once
> everything is finalised generate the PDF.
>
> Any help would be appreciated,
>
> Regards.
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20100118/887fbbff/attachment.htm>
More information about the reportlab-users
mailing list