Reputation: 34024
I am trying to convert rml to pdf using,
import cStringIO
buf = cStringIO.StringIO()
rml2pdf.go(rml, outputFileName=buf)
buf.reset()
pdfData = buf.read()
response = HttpResponse(mimetype='application/pdf')
response.write(pdfData)
response['Content-Disposition'] = 'attachment; filename=output.pdf'
return response
But I am getting error saying No module named cStringIO
Upvotes: 1
Views: 1437
Reputation: 2344
cStringIO is not available in your environment.
I suggest you do something like this:
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
Update
For Python 3, please use this io module and BytesIO class:
from io import BytesIO
Upvotes: 2