merrymonk has asked for the wisdom of the Perl Monks concerning the following question:

I use Perl to create Excel documents.
I need to create pdf versions of these.
Does any Monk know of a third part product (or any other available tool) that will allow me to do this using Perl.
I was thinking of running Perl that had lines something the following
$command_a = $pathto exe . '\\' . $pdfconversion_product.exe; $command_b = $product.exe $excelfile.xls $pdfversion_of_excelfile; $ppc = Win32::Process::Create( $process, $command_a, $command_b, 0, NORMAL_PRIORITY_CLASS, '.' ); $process->Wait(INFINITE);

Replies are listed 'Best First'.
Re: Converting Excel to Pdf
by Corion (Patriarch) on Jun 15, 2009 at 07:52 UTC

    If you're on Windows and have Excel installed, the easiest way is to install a PDF printer driver and use Win32::OLE to drive Excel to print to the PDF printer driver.

    The alternative approach would be to use OpenOffice.org to do the conversion. You can launch OpenOffice in "server mode" where it listens to a TCP port (8100?) and where you can send commands to it. Potentially, OpenOffice::UNO works for that, but I haven't done that myself.

    Another approach could be to use Spreadsheet::ParseExcel or the Excel HTML export or the XLSX export to create a file that you can process form Perl and then use PDF::Template to write the data into a PDF file, but that method will certainly lose fancy formatting and charts.

      Many thanks for that.
      I do have a PDF printer driver so that using Win32::OLE seems an excellent idea.
      I have looked at the link you sent.
      However, I could not see an obvious way of using this or a reference to printing.
      Therefore any clues about how Win32::OLE can be used will be more than welcome!

        I gave you several links, and all of them mean you will have to do some work yourself. Printing to PDF is easiest done by following the instructions of Use The Macro Recorder, Luke (Re: Using Win32::OLE and Excel - Tips and Tricks), as with any automation of Microsoft Office products. I wish that OpenOffice had the same facility, but as OpenOffice is more oriented towards you wading through the horrendous Java API than towards you getting things done by showing it an example and then parametrizing that example, that'll remain a pipe dream I guess.