Net::Printer - Perl extension for direct-to-lpd printing.
use Net::Printer; # Create new Printer Object $lineprinter = new Net::Printer( filename => "/home/jdoe/myfile.txt", printer => "lp", server => "printserver", port => 515, lineconvert => "YES" ); # Print the file $result = $lineprinter->printfile(); # Optionally print a file $result = $lineprinter->printfile("/home/jdoe/myfile.txt"); # Print a string $result = $lineprinter->printstring("Smoke me a kipper, I'll be back for breakfast."); # Did I get an error? $errstr = $lineprinter->printerror(); # Get Queue Status @result = $lineprinter->queuestatus();
Perl module for directly printing to a print server/printer without having to create a pipe to either lpr or lp. This essentially mimics what the BSD LPR program does by connecting directly to the line printer printer port (almost always 515), and transmitting the data and control information to the print server.
Please note that this module only talks to print servers that speak BSD. It will not talk to printers using SMB, SysV, or IPP unless they are set up as BSD printers. CUPS users will need to set up cups-lpd to provide legacy access. ( See "Using Net::Printer with CUPS" )
Constructor returning Net::Printer object
A hash with the following keys:
[optional] absolute path to the file you wish to print.
[default: "lp"] Name of the printer you wish to print to.
[default: "localhost"] Name of the printer server
[default: 515] The port you wish to connect to
[default: "NO"] Perform LF -> LF/CR translation
[default: "NO"] Use RFC 1179 compliant source address. Default "NO". see "RFC-1179 Compliance Mode and Security Implications".
The blessed object
Getter for error string, if any.
String containing error text, if any. Undef otherwise.
Transmits the contents of the specified file to the print server
Path to file to print
1 on success, undef on fail
Prints the given string to the printer. Note that each string given to this method will be treated as a separate print job.
String to send to print queue
1 on succes, undef on fail
Retrives status information from print server
Array containing queue status
When printing text, if you have the infamous "stair-stepping" problem, try setting lineconvert to "YES". This should, in most cases, rectify the problem.
RFC 1179 specifies that any program connecting to a print service must use a source port between 721 and 731, which are reserved ports, meaning you must have root (administrative) privileges to use them. This is a security risk which should be avoided if at all possible!
Net::Printer does not natively speak to printers running CUPS (which uses the IPP protocol). In order to provide support for legacy clients, CUPS provides the cups-lpd mini-server which can be set up to run out of either inetd or xinetd depending on preference. You will need to set up this functionality in order to use Net::Printer with CUPS server. Consult your system documentation as to how to do this.
Christopher M. Fuhrman
<cfuhrman at panix.com>
$Id: 24489f5c582d84f45aaba799eec85819234a6549 $
Copyright (c) 2000-2004 Christopher M. Fuhrman, All rights reserved.
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the LICENSE file included with this module.