Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utf8 encoding not correct #1

Open
digi604 opened this issue May 12, 2010 · 1 comment
Open

utf8 encoding not correct #1

digi604 opened this issue May 12, 2010 · 1 comment

Comments

@digi604
Copy link

digi604 commented May 12, 2010

utf8 characters like umlauts (öäü) are not rendered correctly... maybe an encoding problem

@digi604
Copy link
Author

digi604 commented May 12, 2010

something like this fixes it:

def transform_to_pdf(response):
    import codecs
    content = codecs.BOM_UTF8 + response.content
    response['mimetype'] = 'application/pdf'
    response['Content-Disposition'] = 'attachment; filename=report.pdf'
    result = StringIO.StringIO()
    pdf = pisa.pisaDocument(StringIO.StringIO(content),
            result, link_callback=fetch_resources)
    response.write(result.getvalue())
    if not pdf.err:
        return response
    else:
        return HttpResponse("We had some errors<pre>%s</pre>" % pdf.err)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant