[reportlab-users] [Tip] How to change underline thickness : canvas.setLineWidth(...)

KLEIN Stéphane stephane at is-webdesign.com
Tue Dec 16 05:23:20 EST 2008


Hi,

I write to post one tip that I don't found in reportlab user guide
documentation.

How to change underline tichness : call canvas.setLineWidth(your_value)

Example :

from reportlab.pdfgen.canvas import Canvas
from reportlab.platypus import Paragraph
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm
c = Canvas('test.pdf', pagesize = A4)
style = getSampleStyleSheet()["Normal"]
c.setLineWidth(0.5 * cm)
p = Paragraph("foo <u>bar</u> foo", style)
p.wrap(10 *cm, 10*cm)
p.drawOn(c, 5 * cm, 5*cm)
c.showPage()
c.save()

Regards,
Stephane




More information about the reportlab-users mailing list