[reportlab-users] ReportLab and Django Examples

Andy Robinson andy at reportlab.com
Mon Nov 26 14:39:49 EST 2018


Hi Mike,

That snippet went up in about 2006 when we did our first Django
project ;-)  Which version of Python are you using?

- Andy


- Andy
On Mon, 26 Nov 2018 at 19:14, Mike Hostetler <mike at squarepegsystems.com> wrote:
>
> Hi,
>
> I'm new(ish) to RML but not reportlab and Django. I'm following the code snippet for Django on the latest rlextras:
>
>    buf = io.StringIO()
>    buf = rml2pdf.go(rml,outputFileName=buf)
>    buf.reset()
>
> But I get the following exception:
>
>  File "/Users/mikeh/Projects/asdf/app/reporting/services.py", line 48, in generate_fto_project
>     buf = rml2pdf.go(rml,outputFileName=buf)
>   File "rlextra-3.5.11/src/rlextra/rml2pdf/rml2pdf.py", line 6391, in go
>   File "rlextra-3.5.11/src/rlextra/rml2pdf/rml2pdf.py", line 6165, in _checkDone
>   File "/Users/mikeh/.pyenv/versions/asdf/lib/python3.6/site-packages/reportlab/pdfgen/canvas.py", line 1240, in save
>     self._doc.SaveToFile(self._filename, self)
>   File "/Users/mikeh/.pyenv/versions/asdf/lib/python3.6/site-packages/reportlab/pdfbase/pdfdoc.py", line 218, in SaveToFile
>     f.write(data)
> TypeError: string argument expected, got 'bytes'
>
> The API docs say that I can send a StringIO in, but that doesn't seem to be the case.
>
> Ideas?
>
> --
> Mike Hostetler
> SquarePeg Systems
> http://www.squarepegsystems.com
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users



-- 
Andy Robinson
Managing Director, ReportLab
Wimbletech Zone 2
35 Wimbledon Hill Road
London SW19 7NB, UK
Tel +44-20-8191-7277


More information about the reportlab-users mailing list