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

Greetings!

I am new to perl, and hope to glean wisdom from others with more experience than myself.

I have a program on a Win32 platform (the source of which is not available) that generates a report at regular intervals, and sends that report directly to a printer. In addition to the report being printed I would like to save the report in a file (preferrably pdf) at the same time. I don't think it would be very difficult to set the program up to print to pdf, but to have the pdf then printed automatically would need some sort of scheduled script. I thought perl might do this nicely, but I am not sure how to proceed.

If anyone can show me how to get started, or can see a more simplistic solution to my goal of having the report in file and hardcopy simutaneously I welcome the feedback.

Much thanks!

2006-01-10 Retitled by planetscape, as per Monastery guidelines
Original title: 'Printing Delima'

Replies are listed 'Best First'.
Re: Printing Dilemma
by ww (Archbishop) on Jan 09, 2006 at 18:34 UTC
    Is this (un-named) program started using a scheduler?

    If so, the most straight-forward approach is apt to be intervening there, by modifing the scheduled task. Alternately (and perlishly), you might replace the MS schedule entry running the program, with an entry running a script.

    In the latter case, you may be able to use a backtick or 'exec,' (and read carefully the third paragraph of the output of perldoc -f system for why 'system' is NOT appropriate) to execute the program with output to a .pdf printer (be that Adobe's Distiller or other .pdf printer_driver for which, on W32, you may wish to search using ppm (C:> ppm s pdf).

    You could also redirect input from the program to such a script and then use one of the many .pdf modules. The same script could print the data, either from the input or from the completed .pdf, as you see fit.

    More generally (as if the preceding weren't generalization enough), search and supersearch are helpful if you feed them appropriate keywords.

Re: Printing Dilemma
by radiantmatrix (Parson) on Jan 09, 2006 at 21:53 UTC

    I guess I don't really understand where Perl needs to be a part of this.

    If your application is sending to a Win32 printer, check out the free PDF Creator -- it's a Win32 print driver that outputs PDF files, and can be configured in an automation-friendly manner.

    If you create a batch file that calls your application (causing the PDF to be generated) and then uses Adobe Reader to send the PDF to another printer, you get hard copy and PDF.

    See this document on Adobe's site for information. Basically, something like

    AcroRd32.exe /t document.pdf PrinterName DriverName Port
    <-radiant.matrix->
    A collection of thoughts and links from the minds of geeks
    The Code that can be seen is not the true Code
    "In any sufficiently large group of people, most are idiots" - Kaa's Law
Re: Printing Dilemma
by TedYoung (Deacon) on Jan 09, 2006 at 18:23 UTC

    Hi,

    With regards to initiating the print, if you have Acrobat Reader installed and .pdf associations set up correctly, then just executing `print $file` would work. Of course, you could probably do that with just a bat file.

    As far as scheduling, setting up a scheduled task in windows should meet your needs.

    Ted Young

    ($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
A reply falls below the community's threshold of quality. You may see it by logging in.