[reportlab-users] outlined font
Robin Becker
robin at reportlab.com
Wed Feb 10 04:59:46 EST 2010
On 10/02/2010 03:59, Francis Pieraut wrote:
> Hi guys,
>
> I can't find any do on how to create outlined font as presented in
> attachment file (see watermark at the buttom).
> I am working on a contract and my customer want this font.
> I was thinking of using your great toolkit but can't find doc about that
> feature. Does reportlab supports it?
> Any information about that will be very appreciated.
>
> Btw, great work!
> Thanks,
> http://fraka6.blogspot.com/2010/01/jython-pypdf-reportlab-experimentation.html
........
I found out the other day that although we don't support this directly it can be
done using a trick to set up the text mode for the canvas.
If you have access to a canvas you need to do something like
t=canv.beginText(-1,-1)
t.setTextRenderMode(1)
canv.drawText(t)
eg try out this script
##########################################
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.colors import green, red
def setTextRenderMode(canv,mode):
''' mode
0 = Fill text
1 = Stroke text
2 = Fill then stroke
3 = Invisible
4 = Fill text and add to clipping path
5 = Stroke text and add to clipping path
6 = Fill then stroke and add to clipping path
7 = Add to clipping path"""
'''
t=canv.beginText(-1,-1)
t.setTextRenderMode(mode)
canv.drawText(t)
canv = Canvas('thello.pdf')
canv.setFillColor(green)
canv.setStrokeColor(red)
canv.setLineWidth(0.5)
canv.setFont('Helvetica',20)
y=10*72
for mode in (0,1,2):
setTextRenderMode(canv,mode)
canv.drawString(72,y,'Hello World')
y -= 30
canv.save()
##########################################
--
Robin Becker
More information about the reportlab-users
mailing list