- To: slug@xxxxxxxxxxx
- Subject: Re: [SLUG] How to get a PDF file in memory to a users Web browser
- From: Michael Lake <mikel@xxxxxxxxxxxxxxxxx>
- Date: Sun Sep 29 17:37:02 2002
Rick Welykochy wrote:
>
> Michael Lake wrote:
> > I wish to create some PDF docs using pdflib on the server and send them
> > to a users browser.
.....
> Suggestion 1: make the script output the PDF as the content, no HTML:
>
> print "Content-type: application/x-pdf\r\n"; # or whatever the content type should be
> print "Content-length: $pdflen\r\n"
> print "\r\n"
> print $pdfbuf;
GREAT ! This works now....
# Send the doc to the users browser.
my $length = length ($document);
my $filename = "out.pdf";
my $q = new CGI; # create new CGI object
print "Content-Type: application/pdf\n";
print "Content-Length: $length\n";
print "Content-disposition: inline; filename=$filename\n\n";
print $document;
And it is quite fast too. Netscape renders the image of the PDF
immediately, so much faster for the client too !
It seems strange to me thought that it needs a filename. I dont quite
understand why its required.
Thanks
Mike
--
--------------------------------------------------------------------
Michael Lake
Active caver, Linux enthusiast and interested in anything technical.
--------------------------------------------------------------------