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

We have a old Perl program that has been around for a decade or so. It originally lived on a Solaris 8 Unix system. In 2008 it was ported to run on a Windows 2003 server.

One function of this program automatically prints a text file to a network printer. The challenge being that the output to the printer needs to be landscape, duplex, edge-to-edge, and scaled to fit 11x8.5 paper. It took quite a bit of work, but in 2008 we got it done.

Here is the code in the Perl program.

use Win32::Printer::Direct; ... $v_error = Printfile("\\\\hardcopy\\pur", $printfile);

This year a new printer is being brought online. Changing the above line to the new printer loses all the print configuration. Nothing we do to configure the printer has an affect on the output produced by the new printer. $v_error = Printfile("\\\\hardcopy\\pml_pur_1", $printfile);

What we can not figure out is how the first printer is working. Looking at the print driver on the win 2003 server, the print server or the printer itself and none of them are setup to produce output in landscape, duplexed, edge-to-edge and scaled to fit.

How could the Perl code possibly be connecting to the //hadcopy/pur printer through the Win32::Printer module? Where could that configuration information be hidden?

Replies are listed 'Best First'.
Re: How does a perl program connect to a windows network printer?
by BrowserUk (Patriarch) on Feb 08, 2011 at 17:22 UTC

    What do you see if you look in start->control panel->printers?

    Ie. Do you see a printer icon that matches up with the new printer?

    If not, try clicking "Add printer", then "Add network printer" and see if Windows can find it.

    (Note: the above options were taken from Vista, so the details may differ.)


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Yes the printer is listed in the windows printer and faxes control panel. That was a great deal of the confusion. Changing anything in the printer control dialog for the new printer did not have any affect on the output produced by the Perl code. Also, looking at the printer control dialog of the current printer that is producing proper results showed none of the settings required to produce the desired output!

      The solution has been found. A different set of settings on the HP printer. The PCL settings. I don't really know what the PCL settings are, how they differ from the other printer settings normally accessed through the print driver dialog, nor why the Perl Win32::Print::Direct printfile function sends the jobs utilizing the PCL settings rather then the print driver settings. But changing the appropriate options on the PCL configuration through the printer control panel produced the desired output!

      Hurray!!!

        The PCL settings. I don't really know what the PCL settings are, how they differ from the other printer settings normally accessed through the print driver dialog

        PCL is Printer Command Language.

        nor why the Perl Win32::Print::Direct printfile function sends the jobs utilizing the PCL settings rather then the print driver settings.

        I'm guessing that is what the "Direct" bit in the name means. It bypasses the Windows mechanisms by talking printer native PCl directly to the printer.

        Anyway. Well done for coming back and leaving a record of the solution. You never know who it might help in the future.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: How does a perl program connect to a windows network printer?
by locked_user sundialsvc4 (Abbot) on Feb 08, 2011 at 15:45 UTC

    Depending very-much on the exact printer that is involved, you can set up “profiles” for a printer in Windows which control exactly how printing is to be done.

    Here is a node that might help: http://www.perlmonks.org/?node_id=678462.

    Googling perl printfile landscape windows seemed to produce some promising-looking results.   If you no longer see the shell-commands that would have been needed in Solaris, nor anything directly comparable to them, then the necessary setup most likely isn’t in the Perl software anymore at all.   Windows is heavily dependent upon settings that must be “correctly” made elsewhere.

      "Here is a node that might help: http://www.perlmonks.org/?node_id=678462."

      Unfortunately that was my node from 2008 when I was porting the code from Unix to Windows. I have never managed to get the Win32:Printer method to work with a text file. The currently working printer does not use that functionality.

      "Windows is heavily dependent upon settings that must be 'correctly' made elsewhere."

      That is what I am hoping to find. Other "elsewhere" locations that Window's printer settings can be made. Because the ones I know about and have looked at are not apparently controlling the current printer.