cgi to send PDF file to browser?

Alex Martelli alex at magenta.com
Fri Jul 21 17:21:07 EDT 2000


"Richard van de Stadt -at home-" <richard at vandestadt.org> wrote in message
news:3976F56C.E412E20A at vandestadt.org...
    [snip]
> > I am looking for some advice on how to send a PDF file to a client
browser
    [snip]
> What you basically need is to print the string "application/pdf" followed
by
> the contents of the pdf file.
>
> I did that a few years ago, but went back to making links to the pdf
files.
> because too many users had problems configuring their browsers to work
with
> this. They just wanted to be able to download the files themselves by
> clicking on the links.

If your script had also sent a header of (warning: not 100% sure of
correct syntax, but that should be easy to check...):

Content-Disposition: attachment; filename=whatever.pdf

it should have fixed that (although, if I recall correctly, there
once was a bug with that with some Internet-Explorer sub-release;
but it's long been fixed by MS).

This one's a handly trick to keep in mind for any kind of filetype
that might be "registered" for special disposition on the user's
machine, by the way.


Alternatively, they could have fixed that on their end by setting
the preferences on their Acrobat Reader installation (removing the
"Web Integration" setting, if I recall correctly).  Although this
is PDF-specific, only, it's also handy if, like me, you detest the
way Acrobat Reader work when it integrates itself with a browser:-).


Alex






More information about the Python-list mailing list