[reportlab-users] Building/Storing PDF's in memory

Andy Robinson andy at reportlab.com
Thu Dec 27 11:25:44 EST 2012


On 27 December 2012 16:03, J. R. Carroll <jrcarroll at jrcresearch.net> wrote:


> Hi Andy,

>

> Thanks - that would be great. I am currently using Canvas, but see myself

> doing some platypus work very soon as I am generating quite a few reports.

> If you have examples for both that would help quite a bit, but if not,

> Canvas is preferred.

>

>

Going from (my own, human) memory here...

buf = StringIO.StringIO()

c = Canvas(buf)
c.drawString(100,100, 'Hello world')
c.save()


raw_pdf_content = buf.getvalue()


In Platypus, wherever you would pass in the file name, do the same thing.

A very common use for this pattern is to send files as a response from a
web request without ever saving them to disk.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20121227/d95a7cb3/attachment.html>


More information about the reportlab-users mailing list