[Qgis-developer] python plugin and reportlab

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Oct 16 10:02:42 EDT 2009


On Fri, Oct 16, 2009 at 2:23 PM, Luca Mandolesi <mandoluca at gmail.com> wrote:
> Hi to all.
> Selecting feautures from qgis canvas, I can visualize data from postgres.
> Then I wanna export a pdf report through reportlab.
> If my script run as standalone, export correctly the report, but, if I
> launch the script whithin my Qgis plugin (pyarchinit), it's impossible open
> the pdf, which have 0 KB size. Only closing Qgis, the pdf result correct and
> it's possible open it.
> Does reportlab and Qgis have problems or it's my mistake?

 I just ran the reportlab hello world code from the Qgis python
console and it worked okay:

from reportlab.pdfgen import canvas
def hello(c):
 c.drawString(100,100,"Hello World")

c = canvas.Canvas("hello.pdf")
hello(c)
c.showPage()
c.save()

 Maybe there's some buffer not being flushed. Is this Windows? If you
do the above in Python (outside of Qgis) is the PDF file complete
after c.save() or do you need to quit python? That would make it a
reportlab/windows issue, and not a qgis problem.

Barry


More information about the Qgis-developer mailing list