[reportlab-users] reportlab basic problem

Robin Becker reportlab-users@reportlab.com
Wed, 15 Sep 2004 10:47:59 +0100


jpywtora@calpoly.edu wrote:

>>hello i have started readingthe user guide for replort lab, but i have
>>hit a probelm right away
>>
>>from reportlab.pdfgen import canvas
>>def hello(c):
>>~    c.drawString(100,100, "Hello World")
>>c = canvas.Canvas("c:\hello.pdf")
>>c.showPage()
>>c.save
> 
> 
> Could it be that save is a function and should be c.save() vs c.save?
> 
> 
> 
>>print "finished"
>>
>>this code does not error, but produces no pdf file as the examples
>>says it should... have i installed it incorrectly or is the user guide
>>wrong?
>>
> 
> 
> Johnny P
> 
I belive that's part of the problem. Another thing is that like many other 
languages Python regards \ as an escape so you should change the Canvas call to 
  one of

c = canvas.Canvas("c:\\hello.pdf") #escape the escape
c = canvas.Canvas(r"c:\hello.pdf") #use raw string \ not treated specially
c = canvas.Canvas("c:/hello.pdf")  #windows allows this as well

-- 
Robin Becker