View Full Version : Help with displaying PDF file in a browser.

10-21-2009, 11:13 PM
I am using PDF::Create to dynamically create PDF on the fly.
The user would click on my html form and input the variables they want
for the application and then press the submit button.
THe perl script would take the input and then generate the PDF file for that user. In reading the PDF::Create module it says to end your code with $pdf->close; and then that subroutine will write the pdf file to the server's disc.
So far everything works great, user submits data and the pdf file is created and saved on the server's disc.

I now want to display the pdf file in a browser window back to the user
so they can either print it out or save it to their local machine.

Here is the code I tried.. but it will not work. It just dumps out the
raw pdf coding to a ms-dos window.

Could someone help me with this problem.
Here is the code.


# Wrap up the PDF and close the file to create the PDF
# File Name is Add_Multi_Digit.pdf


# everything works to here... file is created
# in the same directory as the script

# open and display file to browser.

open(PDF, "Add_Multi_Digit.pdf") or die "could not open PDF [$!]";
binmode PDF;
my $output = do { local $/; <PDF> };
close (PDF);

print "Content-Type: application/pdf\n";
print "Content-Length: " .length($output) . "\n\n";
print $output;


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum