my ($offset,$bytes,$buffer,$contents); open(PDF, "<$print_pdf") || print_debug("Couldn't open file $print_pdf");; $offset = 0; $contents = ''; binmode PDF; until(eof(PDF)) { $bytes += read(PDF,$buffer, 1048576, $offset); $offset += 1048576; $contents .= $buffer; } close PDF; print header( -type => 'application/pdf', -Content_Disposition => "inline; filename=charges.pdf", -Content_Length => "$bytes" ); #print "Content-Disposition: inline; filename=charges.pdf\n"; #print "Content-Length: $bytes\n"; #print "Content-Type: application/pdf\n\n"; #binmode STDOUT; print $contents;