How to send data to a network printer using Perl on Win32?
I need to print relatively complex layouts to network / shared printers with Perl, and I haven't been able to find modules or examples to help me with the task. Anyone have any links that might help me?
I am assuming that what I want to do will work as Postscript.
update : Ok, I don't need help generating PDF or Postscript. I'm sure this is well documented. I want to know what I am using to send PDF to printer in windows from perl .
source to share
Win32 :: Printer exposes the Win32 printing API, including printer selection and low-level print commands.
However, (IMHO) an easy way to print a PDF file to any printer was to use Ghostscript to output PCL or PS (depending on the language the printer is supported in) and then to the copy
resulting file to the printer (using its UNC path). You may need to specify a switch /b
for the command copy
.
source to share
If you have a PDF file and the user has Adobe Reader installed (which is pretty standard), you should be able to print the file to the default printer using ShellExecute in Win32 :: FileOp :
use Win32::FileOp 'ShellExecute';
ShellExecute(print => 'A:/Path/to/File.pdf');
source to share
Wx :: Perl has very nice, licensed Win32 pinning capabilities.
I haven't worked with Postscript or PDF from WxPerl, so I don't know what will be involved. Googling wxPerl print pdf turns this post into a wxperl list .
Subject: Re: [wxperl-users] print PDF from wxPerl Actions ... From: Mark Dootson (mark ... @ znix.com) Date: Apr 5, 2007 5:02:40 pm List: org.perl.wxperl -users
Hello,
After writing the last answer, a huge kludge occurred to me that, as it turns out, it works just fine.
use Wx :: ActiveX :: IE to pass url to your pdf file and print fun. eg.
my $obj = Wx::ActiveX::IE->new( $frame, -1, wxDefaultPosition, wxDefaultSize );
$obj->LoadUrl("file:///C:/mytest.pdf");
$obj->Print(0); # for no print dialog
$obj->Print(1); # for print dialog
Sure, downloading IE and the Acrobat plugin might seem a bit overwhelming just to print the document, but heck it's windows and four lines of code pretty impressive.
Mark
This command line program can be another option. I haven't tried and can't vouch for it, but it claims to work for printing postscript data for headerless printers.
source to share