Re: Sending a pdf file with perl



Bill H wrote:
In one of my perl scripts I need to send a visitor a pdf file when
they visit a web page. Since the pdf file is not in "public" space on
the server, I need to send it to them instead of using a
"Location: ....". I use MIME:Lite for email pdf's on another site, is
there a similar thing for sending pdf's to a browser or can I use
Mime:Lite?

When you let the visitors download a file, you print to STDOUT, which is quite another thing. Example code:

open my $fh, '<', "$path/$filename" or die $!;
binmode STDOUT;
print "Content-Type: application/pdf\n",
"Content-Disposition: attachment; filename=$filename\n",
'Content-Length: ' . (stat "$path/$filename")[7] . "\n\n";
while ( read $fh, my $buffer, 1024 ) {
print $buffer;
}

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.



Relevant Pages

  • Re: Have FP2000 Need help to get hover button to cause download to start...Thanks JCO...Still need h
    ... Your server is case sensitive ... | that make up my web site. ... | question is a .pdf file. ... |>> load, but my HTML programming skills are almost non-existent and I ...
    (microsoft.public.frontpage.client)
  • php and pdf
    ... The problem I have is that this is on a hosted server and they do not provide PDFlib as part of their PHP installation. ... In order to have PDFlib, I would have to install my own copy of PHP there, and that is a major effort -- and subject to unanticipated bugs and problems -- so I would rather not do that if I don't have to. ... Another question is if there is a good "HTML code to PDF file" module/library/function/class that could convert HTML format and produce a PDF file. ...
    (comp.lang.php)
  • Re: Perl PDF modules - help please
    ... Bill - and I'm happy to have given the rest of you ... Use Acrobat's Form Tool to add form fields to your PDF file in the places ... >Submit Form Data, Import Form Data. ... >To see the format of an FDF file, submit a blank form to the HTML version of ...
    (comp.lang.perl.misc)
  • Re: Have FP2000 Need help to get hover button to cause download to start...Thanks Crash and Stefan..
    ... server was probably not running Windows and would be case sensitive. ... Stefan for catching that one for me. ... >| is the green one that says click here for a coupon. ... >| question is a .pdf file. ...
    (microsoft.public.frontpage.client)
  • Re: Did SF predict the Internet?
    ... It offers to download Abobe software because it thinks I already ... Wherever in your server is stored "how to display ... a .pdf file for your sort of terminal that's attached to this server" is the ... one that's offering to download/display Adobe for you ... ...
    (rec.arts.sf.written)