[reportlab-users] reportlab basic problem
Tim Roberts
reportlab-users@reportlab.com
Thu, 16 Sep 2004 09:44:48 -0700
On Thu, 16 Sep 2004 12:01:30 +1000, Tim Smith <tims@cqpl.com.au> wrote:
>
>ok it's outputs a file now, but i don't see "hello world" when i open
>it? it just a blank page, i'm in win98 using adobe 6
>
>|>> 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
>
If that's the exact text of your program, then a blank page is exactly
what you should get. You define a function to print "Hello World", but
you never call that function. All you do is create an empty canvas and
save it.
So, you either need to do this:
from reportlab.pdfgen import canvas
def hello(c):
~ c.drawString(100,100, "Hello World")
c = canvas.Canvas("c:\hello.pdf")
hello(c) # <<<<< add this
c.showPage()
c.save()
or just write the string in-line:
from reportlab.pdfgen import canvas
c = canvas.Canvas("c:\hello.pdf")
c.drawString(100,100, "Hello World")
c.showPage()
c.save()
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.