[Zope] IE and HTML pdf's generated on the fly

Dennis Allison allison@sumeru.stanford.EDU
Mon, 14 Oct 2002 15:15:50 -0700


I have a Zope DHTML document which generates a form in which the user
selects what he/she wants to print.  The form action (target="_blank")
is a python script called print_plan that collects and edits several
HTML and DTML and structured text documents and constructs a single
legal HTML document.

The script then opens a pipe to HTMLDOC, stuffs the document down the
pipe anbd sucks back a pdf through the return pipe and hods it as a
StringIO entity.  Now the script has the pdf in hand and sends it off
to the client first setting the HTTP headers. The HTTP headers and 
content look like:

   Content-Type: application/pdf 
   Content-Disposition: inline; filename=foo.pdf

   %PDF-1.3 %âãÏÓ 1 0 obj<</Producer(htmldoc 1.8.22
   Copyright 1997-2002 Easy Software Products, All Rights
   Reserved.)/CreationDate(D:20021010181751+0700)/Title(

where I have truncated the pdf file and inserted linebreaks to make it
readable, save space, etc.  This all works with browsers other than IE
and the browsers either display or save the file.  IE fails to recognize
the pdf as a pdf and activate the reader.  Nor does it offer to save
the file....

It's been suggested that IE gets the returned content type from the 
request URL's extension.  That would imply that the form would need
a name like "printplan.pdf" (not possible).  It was also suggested
that a possible workaround would be to use a dummy variable as 
part of the action ( action="printplan?dummy=foo.pdf") in hopes that
IE would recognize it as a pdf generator.  Does IE really work 
this way?  

My web research suggests that IE does not implement "Content-Dispositon"
but tries to grok the type by examining the incoming stream.  If that's
the case, perhaps there is some difference between HTMLDOC generated 
pdf files and other pdf's, and IE detect it.   Whatever, it's frustrating
no end.

Any help much appreciated.