[reportlab-users] Writing to stdout

Tim Roberts timr at probo.com
Sun Feb 28 14:51:55 EST 2021


On Feb 28, 2021, at 9:55 AM, Rob Allen <rob at akrabat.com> wrote:
> 
> This is my test application, based on page 11 of the manual where I changed the filename to sys.stdout:
> 
> $ cat test.py
> import sys
> from reportlab.pdfgen import canvas
> 
> def hello(c):
>   c.drawString(100, 100, "Hello World")
> 
> c = canvas.Canvas(sys.stdout)
> hello(c)
> c.showPage()
> c.save()

sys.stdout.buffer has a “write” member,  You should be able to say

    c = canvas.Canvas(sys.stdout.buffer)
— 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list