[Zope] [HELP] PDF and IE
Jim Washington
jwashin at vt.edu
Mon Oct 20 13:59:20 EDT 2003
fbarsukow at fede.generali.fr wrote:
>
> hi,
>
> i 've some problems for the edition of PDF Document on IE (5.5 or 6.0
> are my differents configurations).
> IE recognizes the stream only as text format. the problem doesn't
> exist with netsacpe (i use netscape 7.0)
>
> The pdF is generated and sent as a stream
>
> the code is :
>
> #stResult recover the pdt stream
> stResultat = context.Editique_GetDocumentPDF(stURL)
>
>
> RESPONSE = REQUEST.RESPONSE
> RESPONSE.setHeader('Content-Type', 'application/pdf')
> RESPONSE.setHeader('MIME-Version', '1.0')
> RESPONSE.setHeader('Content-Transfer-Encoding', 'base64')
>
> #exit on the browser :
> RESPONSE.write(stResultat)
>
> zope version : 2.1.2
> python version : 2.1
>
IE is unfriendly sometimes. Here are a few tips I have found to be useful:
1. Assure the URL the browser sees is "[something].pdf", i.e., rename
your method so that it ends with ".pdf". You can set the name of the
actual pdf file downloaded with the "Content-Disposition" header.
2. Making Content-Disposition say "attachment" instead of "inline" may
help with some versions of Acrobat Reader.
3. Set the "Content-length" header.
As an example, I am having success with something like the following:
theFile = asPDF(dummy)
REQUEST.RESPONSE.setHeader("Content-type","application/pdf")
REQUEST.RESPONSE.setHeader("Content-Disposition",'attachment;filename=ThisIsTheRealFileName.pdf')
REQUEST.RESPONSE.setHeader("Cache-Control",'private')
REQUEST.RESPONSE.setHeader('Content-length','%s' % len(theFile))
REQUEST.RESPONSE.write(theFile)
hth,
-- Jim Washington
More information about the Zope
mailing list