[reportlab-users] Returning PDF to a browser?
Sat, 29 Nov 2003 09:51:25 +0200
Carl Waldbieser wrote:
>You are a little vague on some points, though I think Iget the general gist
>of what you are trying to accomplish. I wrote up a little demo at work that
>uses Reportlab to dynamically create a PDF file and send it back to an
>Internet Explorer browser as the HTTP response. Like you, I was getting the
>raw PDF showing up in the browser instead of Acrobat reader popping up in
>the browser. The trick to making it work was to observe the headers that
>were sent when I typed in the URL of a static PDF file and observe what
>headers were returned to the browser. I believe that the "Accept-Ranges:
>bytes" might do the trick for you, though I won't be back to work to double
>check until Tuesday due to the holidays here.
You should also check for Internet Explorer that the URL actually ends
with a .pdf as it sometimes seems to get the type from the extension
rather than the Content type in my experience
>----- Original Message -----
>From: "Ben Mitchell" <email@example.com>
>Sent: Friday, November 28, 2003 5:23 PM
>Subject: [reportlab-users] Returning PDF to a browser?
>>I'm trying to write a PDF that I've dynamically generated as a result
>>of a form submission back to the requesting browser.
>>I'm having trouble getting it to display in the browser - it just
>>presents itself as the raw PDF data...
>>My (simplified) code looks like this:
>> print '''Content-Disposition: inline; filename=foo.pdf
>> doc = SimpleDocTemplate(sys.stdout)
>> doc.topMargin = inch*2.25
>> Story = 
>> style = styles["Normal"]
>> parastr = "foo"
>> p = Paragraph("<para leading=\"20\" fontName=\"helvetica\"
>>fontSize=\"10\">%s</para>" % parastr, style)
>> doc.build(Story, pagetemplate, pagetemplate)
>>So if I call "go" as the first and only function after receiving the
>>form input (which I'm now doing for test reasons) I think I'm returning
>>the appropriate headers, followed by the document, which is printing to
>>But like I said, all I get is a browser full 'o raw PDF.
>>Can anyone point me in the right direction here?
>>reportlab-users mailing list
>reportlab-users mailing list