So I'm trying to export a section of a website to PDF, and Im able to export the HTML successfully, but the CSS codes just outputs as actual text.
def exportPDf(results, css, html):
result = StringIO.StringIO()
results_2 = StringIO.StringIO(results.encode("UTF-8"))
css_encode = StringIO.StringIO(css.encode("UTF-8"))
pdf = pisa.pisaDocument(results_2 , result)#ISO-8859-1
if not pdf.err:
return HttpResponse(result.getvalue(), mimetype='application/pdf')
return HttpResponse('We had some errors<pre>%s</pre>' % escape(html))
def get_data(request):
results = request.GET['css'] + request.GET['html']
html = request.GET['html']
css = request.GET['css']
return ExportPDf(results, css, html)