in reply to Perl CGI output in PDF
In other words, you should probably use
print $query->header(-expires=>'now', -type=$mimetype, -content_dispos +ition=>"inline; filename=sample.pdf"); [download]