Pylons and Pisa (xhtml2pdf): blank page in IE
I'm using pylons to serve a dynamically generated pdf document for reporting: my approach works in firefox & chrome (it displays the pdf inline if the plugin is available or otherwise downloads it) but IE (7 & 8) only show a blank page and doesn't prompt for download. IE correctly shows PDFs generated by other websites, though.
Don't know if it matters but the page is accessed through HTTPS.
My controller does the开发者_如何转开发 following:
- renders the source page through mako
- converts the html to pdf using pisa
- adds these headers to the response:
Content-type: application/pdf
andContent-disposition: inline; filename=file.pdf
Do you have any suggestion? I seem to be stuck and cannot think of anything else to try.
Not sure if this helps, but in IE6 I was getting all sorts of strange browser errors when I tried to stream dynamically generated PDFs. The errors were different depending on whether the content disposition header said inline or attachment, but it was a train-wreck either way.
The issued turned out to be that IE6 must cache the PDF in order to pass it to Acrobat Reader, and the default headers in a Pylons response say "don't cache this". I allowed caching for 10 seconds by adding:
del response.headers['Cache-Control']
del response.headers['Pragma']
response.cache_expires(seconds=10)
to the controller that returns the PDF, and all was well.
In django I do this:
response['Content-Disposition'] = 'attachment; filename=rawr.pdf'
So try changing inline
to attachment
and see what happens.
精彩评论