new problem with CUPS-PDF
Gary Stainburn
gary.stainburn at ringways.co.uk
Fri Sep 11 12:42:53 UTC 2015
On Friday 11 September 2015 13:16:04 Ed Greshko wrote:
> On 09/11/15 17:06, Gary Stainburn wrote:
> > Can anyone suggest how I can do the same thing with CUPS-PDF?
>
> Looking at the various options and checking what others have said it seems
> not possible out of the box since everything is pretty much hardwired.
>
> The one solution that someone came up with was to modify the source.
>
> http://ubuntuforums.org/showthread.php?t=1602473
>
Hi Ed, Thanks for this, I'll look into that as my next option.
I'm currently looking at
http://aplawrence.com/MacOSX/macosxcupstofile.html
I've only just started work on this but so far I've got the following. I'll
let you know how I get on.
lpadmin -p tofile -E -v socket://localhost:12000 -m raw
and
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use IO::Socket::INET;
my $myport=12000;
my $pname='default';
my $dirname='/var/spool/cups-pdf/inet';
my $debug=1;
if (!GetOptions('p|port=i'=>\$myport,'d|
dir=s'=>\$dirname,'printer=s'=>\$pname,'D|Debug'=>\$debug)) {
die "$0 invalid usage";
}
if (! -e $dirname) {
mkdir($dirname) || die "Cannot create spool directory: $!\n";
}
if (! -d $dirname) {
die "Spool directory is not a directory";
}
open (J,">$dirname/$$") ||die "Cannot create files in the spool directory: $!
\n";
close(J);
unlink("$dirname/$$");
my $pserve=IO::Socket::INET->new(LocalPort =>
$myport,Type=>SOCK_STREAM,Reuse=>1,Listen=>1) or die "can't do that $!\n";
while (my $pjob=$pserve->accept()) {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$year+=1900;$mon++;
my $ts=sprintf('%04d-%02d-%02d_%02d:%02d:%02d',$year,$mon,$mday,$hour,$min,
$sec);
my $fname="$dirname/$ts_$pname.ps";
open(J,">$fname") or print "having issues $!\n";
while (<$pjob>) {
print J "$_";
}
close J;
close $pjob;
if (-e "/usr/local/bin/perlCupsFilter_$pname") {
system("/usr/local/bin/perlCupsFilter_$pname") || warn "Unable to start
filter: $!\n";
} else {
system("/usr/local/bin/perlCupsFilter $pname") || warn "Unable to start
filter: $!\n";
}
}
More information about the users
mailing list