I am writing this as for the Win32 OS platform and was under the impression that Win32::Printer::Enum was the correct one. Also Printer is non-platform specific so I tried that also. But as I said neither have worked.
Has anyone had any success using either of these or have any others they have successfully printed a file with? If anyone has I could really use a snippet to show me the correct syntax.
Here was my last attempt at using the Print module.
I have not addes a third button for the ques jobs yet but was trying to work on the backend first. I of course get an error here saying the barewaord names I have for hash fields cannot be used while strict subs is in use. However I still do not like the way this is laid out and think there has got to be a better way to simply print a file to a printer.my $printer = new Printer('linux' => 'lp', 'MSWin32' => 'LPT1'); $printer->print_command('linux' => {'type' => 'pipe', 'command' => 'lpr -P lp'}, 'MSWin32' => {'type' => 'command', 'command' => 'gswin32c -sDEVICE=m +swinpr2 -dNOPAUSE -dBATCH $spoolfile'} ); sub print { my $pw = MainWindow->new(-title=>"Printer Options"); my $frame = $pw->Frame->pack(-side => 'top', -fill => 'x'); $frame->Button(-text => "Show Printers", -background => 'navy blue' +, -foreground => 'white', -command => \&show_printers)-> pack(-side => 'right'); $frame->Button(-text => "Print File", -background => 'navy blue', - +foreground => 'white', -command => \&print_file)-> pack(-side => 'left'); sub print_file { $status->delete("1.0", "end"); $status->insert("end", "Printing Document...."); my $target = $t->get("1.0", "end"); $printer->use_default; $printer->print($target); $status->insert("end", "done\n"); } sub show_printers { my %available_printers = $printer->list_printers(); foreach my $key (%available_printers) { foreach my $field (qw/name port/) { print $field, "=", $$key{$field}, " "; } } } sub list_jobs { my @queue = list_jobs(); foreach my $ref (@queue) { foreach my $field (qw/Rank Owner Job Files Size/) { print $field, " = ", $$ref{$field}, " "; } print "\n"; } } }
In reply to Need printer help. by Elijah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |