[reportlab-users] Shape + Stroke problem

Robin Becker robin at reportlab.com
Thu Jun 7 09:01:13 EDT 2012


Andy claims it is a deliberate feature that strokes with zero width appear in
postscript/pdf. He says the intent was to implement some drawing convention eg a
hairline.

Anyhow you can eliminate by setting the strokeColor to None eg

#coding=utf-8
from reportlab.pdfgen.canvas import Canvas
from reportlab.graphics import shapes
from reportlab.graphics import renderPDF
from reportlab.lib import colors

output = "output.pdf"
width = 400
height = 400
canvas = Canvas(output, pagesize=(width, height))
d = shapes.Drawing(width, height)

p = shapes.Path(strokeColor=None,fillColor=colors.red)
p.moveTo(0, 0)
p.lineTo(100, 100)
p.lineTo(20, 100)
p.closePath()
# Even if I have set the strokeWidth to 0, the stroke is always present but
thiner than 1...
p.strokeWidth = 0
d.add(p)
renderPDF.draw(d, canvas, 0, 0)
canvas.showPage()
canvas.save()


On 07/06/2012 13:18, khalid y wrote:

> Hi,

>

> I'm using reporlab2.5 to draw some graphics and I'm using shapes for that

> but I can not disable stroke ...

>

> Here is my code :

>

> #coding=utf-8

> from reportlab.pdfgen.canvas import Canvas

> from reportlab.graphics import shapes

> from reportlab.graphics import renderPDF

> from reportlab.lib import colors

>

> if __name__=='__main__':

> output = "output.pdf"

> width = 400

> height = 400

> canvas = Canvas(output, pagesize=(width, height))

> d = shapes.Drawing(width, height)

>

> p = shapes.Path()

> p.moveTo(0, 0)

> p.lineTo(100, 100)

> p.lineTo(20, 100)

> p.lineTo(0, 0)

> # Even if I have set the strokeWidth to 0, the stroke is always present

> but thiner than 1...

> p.strokeWidth = 0

> d.add(p)

> renderPDF.draw(d, canvas, 0, 0)

> canvas.showPage()

> canvas.save()

>

>

> Cheers,

>

> Thanks

>

> Khalid

>

>

>

>

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at lists2.reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users



--
Robin Becker


More information about the reportlab-users mailing list