Connecting Tech Pros Worldwide Forums | Help | Site Map

PDF display from perl script

Newbie
 
Join Date: Oct 2009
Posts: 2
#1: Oct 19 '09
I am using PDF::Create to dynamically create PDF on the fly.
That works.

I end my code with the $pdf->close;

and the pdf file is created.
I now want to display it in a browser. Here is the code I tried.. but i will not work.
Expand|Select|Wrap|Line Numbers
  1. # Wrap up the PDF and close the file to create the PDF 
  2. # File Name is Add_Multi_Digit.pdf
  3.  
  4. $pdf->close; 
  5.  
  6. # everything works to here... file is created 
  7. #  in the same directory as the script
  8.  
  9. # open and display file to browser.
  10.  
  11. open(PDF, "Add_Multi_Digit.pdf") or die "could not open PDF [$!]";
  12. binmode PDF;
  13. my $output = do { local $/; <PDF> };
  14. close (PDF);
  15.  
  16. print "Content-Type: application/pdf\n";
  17. print "Content-Length: " .length($output) . "\n\n";
  18. print $output;
  19.  

nithinpes's Avatar
Expert
 
Join Date: Dec 2007
Posts: 400
#2: Oct 20 '09

re: PDF display from perl script


To read from the PDF file, you can make use of PDF::Core module.
Newbie
 
Join Date: Oct 2009
Posts: 2
#3: Oct 20 '09

re: PDF display from perl script


I don't want to read it. I created it using PDF::Create.
I want to display back to the browser window so the person can print the pdf out or save it to his computer.
Reply