Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

cgi to send PDF file to browser?

15 views
Skip to first unread message

Erik Myllymaki

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
Hello,

I am looking for some advice on how to send a PDF file to a client browser
from a cgi script. I could just show a listing of the directory where the
PDF files are located and have the client select the right one, but for
various reasons I would like to just ship it out transparently.

I have looked briefly at BaseHTTPServer, and I think this is where my answer
lies???

Thanks in advance.

--
Erik Myllymaki
er...@pacific-shores.com

Richard van de Stadt -at home-

unread,
Jul 20, 2000, 3:00:00 AM7/20/00
to
Erik Myllymaki wrote:
>
> Hello,
>
> I am looking for some advice on how to send a PDF file to a client browser
> from a cgi script. I could just show a listing of the directory where the
> PDF files are located and have the client select the right one, but for
> various reasons I would like to just ship it out transparently.
>
> I have looked briefly at BaseHTTPServer, and I think this is where my answer
> lies???

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.

Richard.

Alex Martelli

unread,
Jul 21, 2000, 3:00:00 AM7/21/00
to
"Richard van de Stadt -at home-" <ric...@vandestadt.org> wrote in message
news:3976F56C...@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


0 new messages