We serve PDFs, both in-browser, and out. Here the lines to set the type
and disposition:
response = HttpResponse(pdfbytes, mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=foo.pdf'
return response
Here pdfbytes are the actual bytes of the PDF file. With the
Content-Disposition line, Firefox will display the Save As dialog to
save the file someplace. Without that line, the PDF is displayed in the
browser.
--Ned.
Malcolm Tredinnick wrote:
> On Mon, 2007-04-02 at 18:02 -0700, queezy wrote:
>
>> Hi All!
>>
>> We have a Django application that uses a form to allow users to select
>> offices and it sends them off to a pdf. At the present time we are using
>> FireFox on a Linux box and we are just using the Django loopback server for
>> the time being. This means that we don't have a secondary, or even a
>> primary instance of Apache working for us.
>>
>> So when you select an office and the pdf is served up you see binary codes
>> dumped on your screen.
>>
>
> That sounds like you haven't set the mimetype correctly. Firefox should
> ask what application to use for anything it can't render natively. The
> fact that you are seeing bytes sent to the screen suggests you are
> sending it across with the HTML or some text-derivative mimetype so that
> Firefox things it should display this directly.
>
>
>> By itself, if I fire up FireFox and go to the pdfs, I am prompted for what
>> viewer to use, and choose postscript viewer and all is well. So the browser
>> is capable of rendering pdfs properly.
>>
>> Any constructive comments on this? Any advice on getting the browser to
>> actually render the pdfs?
>>
>
> Browsers usually (I was going to say always, but I'm not sure what
> native-PDF-underneath-MacOS does) hand off PDF rendering to a
> third-party app. Sometimes that third-party app it is configured as a
> browser plugin.
>
> I personally have no experience to share here because I prefer to use an
> external app for PDF rendering, as my browser window is not the right
> size for viewing generated-for-print-page documents, so I like being
> able to resize them separately.
>
> Regards,
> Malcolm
>
>
> >
>
>
>
>
--
Ned Batchelder, http://nedbatchelder.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---