pdf/Firefox and turning off GZipMiddleware

10 views
Skip to first unread message

BjornSteinarF...@gmail.com

unread,
Jan 25, 2008, 3:08:25 PM1/25/08
to Django users
I've been tearing my hair out for a little while trying to figure out
why I can't display pdfs from Django in Firefox. I'm getting blank
windows and I know it used to work ;-)

I'm using the code from the documentation (http://
www.djangoproject.com/documentation/outputting_pdf/), removing
"attachment;" from the Content-Disposition to make the pdf display in-
browser and not open an external viewer.

I've printed the response object, and everything looks ok. It works
fine in IE7. I can view other pdf files in FF (e.g.
http://www.merlinautomation.co.uk/automation/pub/Test%20Product%20PDF.pdf).

I read in an old thread that older versions of IE could have problems
with the pdf/gzip combination, so that gave me the idea to turn off
GZipMiddleware... and that "fixed it".

I'd prefer to not turn of compression for all of my pages though, so
two questions (1) does it seem reasonable that GZipMiddleware is the
problem and if so (2) is there a way to turn it off on a per-view
basis?

-- bjorn

Ned Batchelder

unread,
Jan 25, 2008, 7:51:55 PM1/25/08
to django...@googlegroups.com
We just ran into this problem also. It's reported in ticket 6027:
http://code.djangoproject.com/ticket/6027

GzipMiddleware and responses with files for content (rather than
strings) don't get along...

--Ned.

--
Ned Batchelder, http://nedbatchelder.com

BjornSteinarF...@gmail.com

unread,
Jan 26, 2008, 7:58:43 AM1/26/08
to Django users
Interesting, although I'm seeing behavior that's inconsistent with the
bugreport... With GZipMiddleware turned on, the pdf displays in an
external viewer from both IE7 and FF2 (when I don't set the Content-
Disposition); and it also displays in-browser in IE7. The only place
it doesn't display is in-browser in FF2 (this is happening to
everyone, not just my FF2, but I've cleared the file associations and
reinstalled Acrobat Reader without any change in behavior just to be
sure). Using Firebug I can see that the browser is receiving data,
although it seems to be truncated near the start of the binary data in
the pdf -- could be a Firebug artifact, I don't know.

-- bjorn


On Jan 26, 1:51 am, Ned Batchelder <n...@nedbatchelder.com> wrote:
> We just ran into this problem also. It's reported in ticket 6027:http://code.djangoproject.com/ticket/6027
>
> GzipMiddleware and responses with files for content (rather than
> strings) don't get along...
>
> --Ned.
>
>
>
> BjornSteinarFjeldPetter...@gmail.com wrote:
> > I've been tearing my hair out for a little while trying to figure out
> > why I can't display pdfs from Django in Firefox. I'm getting blank
> > windows and I know it used to work ;-)
>
> > I'm using the code from the documentation (http://
> >www.djangoproject.com/documentation/outputting_pdf/), removing
> > "attachment;" from the Content-Disposition to make the pdf display in-
> > browser and not open an external viewer.
>
> > I've printed the response object, and everything looks ok. It works
> > fine in IE7. I can view other pdf files in FF (e.g.
> >http://www.merlinautomation.co.uk/automation/pub/Test%20Product%20PDF...).
Reply all
Reply to author
Forward
0 new messages