Do you just want to print from the filename itself? Or do you want to open the file in an editor to see it, before you print it? In either case, you probably would use the same code in the callbacks. For MS Windows I would use a Windows only module, but on Linux you can use Net::CUPS::Printer, or use a forked system call to run the lpr command. You could also print directly to the printer, if you wanted more control.
or use the moduleopen(LPR, "|lpr -Plp0 >/dev/null 2>&1"); open (FILE,"< $0 ") or die "Couldn't open: $!"; my $text = do {local $/; <FILE>}; close FILE; print LPR $text; close LPR;
#!/usr/bin/perl use warnings; use strict; use Net::CUPS::Printer; use Data::Dumper; my @printers = cupsGetPrinters (); print "printers-> @printers\n"; my $printer = cupsGetDefault(); print "Default printer-> $printer\n"; my %options =(); my $jobid = cupsPrintFile($printer,"./$0",'Job1',\%options); print "jobid-> $jobid\n"; my $jobs = cupsGetJobs('lp0',1,0); print "jobs-> $jobs\n"; print Dumper([$jobs]),"\n"; my $cancel = cupsCancelJob('lp0', $jobid); print "cancel-> $cancel\n"; #my $jobs = cupsGetJobs('lp0',1,0); #print "jobs-> $jobs\n"; #print Dumper([$jobs]),"\n"; my $user = cupsUser(); print "user-> $user\n"; exit;
In reply to Re: Perl tk - open file and print content
by zentara
in thread Perl tk - open file and print content
by Giorgio C
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |