open (PDF_FILE,"<$pdffile") || die "Could not open file: $pdffile"; print $cgi->header(-type=>"application/pdf",-attachment=>"$pdfid.pdf"); # set the appropriate header while () { # send the PDF bitstream to the client print; } close PDF_FILE;