use strict; my $image_dir="D:\\my"; display_pdf("in.pdf"); sub display_pdf{ my $file = shift; my $full_path = "$image_dir\\$file"; my $buffer=""; print "Content-type: application/pdf\n\n"; open(FIN,"< $full_path") || print "File Not Found"; binmode FIN; $buffer = join '', ; close(FIN); print $buffer; }