in reply to Finding the right PDF module

I also think there is nothing wrong in letting the webserver handle the PDF download. If you must deliver the download by your script itself your may use File::Temp to create temporay files, read them and deliver them.

I create PDFs using the command line tool wkhtmltopdf. My webapp constructs some HTML temporary file that wkhtmltopdf converts into a nice pdf file which I then deliver.