|
Colin Bean
ccbean at gmail.com
Mon Oct 16 17:10:10 EDT 2006
Could you post just the headers as they appear in WebScarab? -Colin On 10/16/06, Jim Steil <jim at qlf.com> wrote: > I installed WebScarab and tested it and it all looks perfect. I set the > headers as you recommended, but still, IE won't display the content and > Firefox won't give me the name of the file I've put in the filename header > variable. I'm at a bit of a loss as to where to go next. > > -Jim > > Jim Steil > IT Manager > Quality Liquid Feeds > (608) 935-2345 > (608) 341-9896 cell > > -----Original Message----- > From: Colin Bean [mailto:ccbean at gmail.com] > Sent: Monday, October 16, 2006 2:44 PM > To: Jim Steil > Cc: mod_python at modpython.org > Subject: Re: [mod_python] ReportLab integration > > Hi Jim, > > So you're just getting a blank page in IE when you try to access your > pdf? One case is that the content is actually being sent to IE, and > IE isn't displaying to properly, another is the content isn't being > sent correctly / completely. I'm guessing it's the first, since > there's not much that's browser-dependent in your code, but you might > want to check this. In the past, I"ve used a lightweight http proxy > (pick your flavor -- webscarab worked well for me) between browser and > server, to make sure that the complete content is actually being sent > to the browser. > > So, assuming the pdf content is actually being send but IE won't display it: > Just realized that the microsoft KB article never mentions this > (sorry), but if you change "content-disposition: attachment..." to > "content-disposition: inline...", it will set the filename / type for > inline display like you're looking for. > > Here's another snippet that talks about handling pdf content (it's for > java, but mainly deals with headers / filename stuff): > http://www.rgagnon.com/javadetails/java-0404.html > > hth, > Colin > > > > On 10/16/06, Jim Steil <jim at qlf.com> wrote: > > > > > > > > > > It runs my script, but doesn't go anywhere when it is done. The code > looks > > like this: > > > > > > > > --------------------- > > > > # Create the document. > > > > reportPeriod = 'Report for the Month of %s %s' % (months[reportMonth], > > reportYear) > > > > output = StringIO.StringIO() > > > > doc = SimpleDocTemplate(output, pagesize=landscape(letter)) > > > > doc.m = reportPeriod > > > > go(doc, reportMonth, reportYear) > > > > # Return the rendered page content. > > > > content = output.getvalue() > > > > > > > > req.content_type = "application/pdf" > > > > req.headers_out['Content-Length'] = str(len(content)) > > > > > > > > # Internet Explorer chokes on this with PDFs. > > > > #req.headers_out['Pragma'] = 'no-cache' > > > > #req.headers_out['Cache-Control'] = 'no-cache' > > > > #req.headers_out['Expires'] = '-1' > > > > > > > > req.send_http_header() > > > > req.write(content) > > > > return apache.OK > > > > --------------------- > > > > > > > > > > > > This works fine in Firefox, but doesn't do anything in IE. The comment in > > the code about Internet Explorer choking was there in Grahams example. > > > > > > > > I looked at the link you provided, but it seems to speak about doing a > Save > > As when you display the content. That is not what I'm trying to > accomplish. > > I want the pdf to come back to the screen, but have it come back with a > > name. > > > > > > > > -Jim > > > > > > > > Jim Steil > > > > IT Manager > > > > Quality Liquid Feeds > > > > (608) 935-2345 > > > > (608) 341-9896 cell > > > > > > > > > > -----Original Message----- > > From: Colin Bean [mailto:ccbean at gmail.com] > > Sent: Monday, October 16, 2006 2:05 PM > > To: Jim Steil > > Cc: mod_python at modpython.org > > Subject: Re: [mod_python] ReportLab integration > > > > > > > > Hi Jim, > > > > > > > > How does it break in IE? If it it won't recognize the result is a > > > > pdf, try setting the content-disposition header. You can use this to > > > > specify a filename that browser will save your file as; if you give it > > > > a .pdf extension then IE should open it fine. Here's a little more > > > > info on it: > > > |