Greg Trounson wrote:
>
> Greetings,
>
> Does anyone know how (or even if it is possible) to force all incoming
> PS print jobs to 2 pages per sheet? I know this can be done at the
> client end, but this is for a print server in a student environment, and
> we need to limit the amount of paper we chew through per month
Hi Greg,
I implemented a bounce queue for this function. Here are the
printcap entries for printing directly to the printer and through
a queue that puts 4 pages on one sheet (using the duplexer):
(excuse the mixture of German and English -- I've lived in
Germany so long I don't know how to write proper comments
in my files anymore)
----------------------- /etc/printcap -------------------------------
# - Straight to it -
#
hp4000|lp|ps:\
:cm=[edv]HP4000=PS+PCL6/SW,Laser/1200dpi/A4/duplex:\
hp4000:server:\
:tc=.local:\
:lp=/dev/lp1:\
:if=/local0/daemon/LPRng/filters/hpif
-Tmodel=hp4000,status@,pagesize=26:
# - A4 -> A5 booklet -
hpa5|lpa5:
:cm=[edv]HP4000=PS A4->A5 doppelseitig
hpa5:server
:lpd_bounce
:bq_format=l
:lp=hp4000@localhost
:sd=/deliver/printers/%P
:if=/local0/daemon/LPRng/filters/A4toA5
:la:sh:sf:mx#0
--------------------------------------------------------------------
Attached to this mail is the filter, 'A4toA5', a perl script that
makes use of the psutils available for Linux/Unix.
Hope it works for you.
-- Howard
--------------------------------------------------------------------
Dipl.-Phys. Howard Schultens Tel: +49 551 39-5914
Zentrum Physiologie FAX: +49 551 39-5923
Humboldtallee 23
37073 Goettingen mailto:[EMAIL PROTECTED]
Germany http://www.neuro-physiol.med.uni-goettingen.de
--------------------------------------------------------------------
#!/usr/bin/perl
#==============================================================================
# LPRng/filters/A4toA5 Tue May 23 18:07:34 2000 has
#==============================================================================
#
=head1
Printcap filter that pipes an A4 postscript file through
the PSUTILs programs to reformat the file into an A5 booklet
=cut
#
#==============================================================================
# Definitions
#==============================================================================
#
use Getopt::Std;
use Sys::Hostname;
# -- Exit codes --
my $JSUCC = 0;
my $JFAIL = 32;
my $JABORT = 33;
my $JREMOVE = 34;
my $JHOLD = 37;
my $User=""; # User name
my $Client=""; # Client machine
my $Title=""; # Job title
my $Medium=""; # Value of last "/MediaType (...)" in file
my $PSFor=""; # PostScript file client/user name
my @foo = split(/\//, $0);
my $PROG = pop @foo;
my $line="";
my $MacFile=0;
my $BDIR="/usr/bin"; # Where the PSUTILs and tr binaries are
my $CDIR="/local0/share/hp4000"; # Where the configuration files are.
my $tmp = "./A4toA5.$$"; # Name of temporary file for converted output
my $CNVCMD="|$BDIR/psbook | $BDIR/psnup -2 | $BDIR/pstops 2:0U\@1\\(21cm,29.9cm\\),1 >
$tmp";
my $TRCMD="|/$BDIR/tr '\r' '\n'";
#
#==============================================================================
# Subroutines
#==============================================================================
#
#
#------------------------------------------------------------------------------
# Output a message to log file and STDERR
#------------------------------------------------------------------------------
#
# First arg = message type, second arg = message text
#
# LPRng puts STDERR into the file 'status.printer' and appends the
# date/time.
sub Log {
my $now = DateStamp();
print LOG "$PROG($_[0]) $now: $_[1]\n";
print STDERR "$PROG($_[0]): $_[1]\n";
}
#
#------------------------------------------------------------------------------
# Fatal error ('die' with a message and exit value)
#------------------------------------------------------------------------------
#
# First arg = exit value, second arg = message text
sub FATAL {
my $now = DateStamp();
print LOG "$PROG(ERROR) $now: $_[1]\n";
$! = $_[0];
die "$PROG(ERROR): $_[1]\n";
}
#
#------------------------------------------------------------------------------
# Get current time/date
#------------------------------------------------------------------------------
#
sub DateStamp {
my @MONTHS = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" );
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my $month = $MONTHS[$mon];
$year += 1900;
if (length($sec) == 1) { $sec = "0$sec" }
if (length($min) == 1) { $min = "0$min" }
if (length($hour) == 1) { $hour= "0$hour" }
if (length($mday) == 1) { $mday= "0$mday" }
return ("$year-$month-$mday-$hour:$min:$sec");
}
#
#==============================================================================
#==============================================================================
#
my @clargs = @ARGV; # Save all the command-line args
# Get all the filter options LPRng knows
getopts('a:b:cd:e:f:h:i:j:k:l:m:n:p:r:s:t:w:x:y:F:P:R:S:C:H:A:J:L:Q:T:Z:', \%opt);
$datestamp = DateStamp();
# -- Open log file --
$log = "./log";
open( LOG, ">>$log" ) or die "$PROG(ERROR) -- can't open $log: $!\n";
#
$Finfo = `/usr/bin/file $opt{e}`;
FATAL($JREMOVE,"Not a postscript file") if ( $Finfo !~ /postscript/i );
# -- Check for Macintosh file, ie. no <lf> in first 2048 bytes --
open(DFILE, $opt{e}) or
FATAL($JABORT,"can't open spool file $opt{e}: $!");
read(DFILE,$line,2048) or
FATAL($JABORT,"can't read from spool file $opt{e}: $!");
if ( index($line,"\n") == -1 ) { $MacFile=1; } # Mac file
undef $/; # Read and write big chunks
if ( $MacFile ) { $CNVCMD = $TRCMD . $CNVCMD; }
open(CNV,$CNVCMD) or FATAL($JABORT,"Can't convert input file: $!");
while (<STDIN>) { print CNV $_; }
close CNV or Log("WARNING","can't close connection to converter: $!");
# - Prepend special configuration files -
if ( defined($opt{T}) ) {
my @Ts = split(',',$opt{T});
foreach my $t (@Ts) {
open(CFG,"<$CDIR/$t.ps") or FATAL($JABORT,"unknown configuration $t");
while(<CFG>) {print STDOUT $_;}
close(CFG);
}
}
# - Output converted file -
open(OUT,"<$tmp") or FATAL($JABORT,"can't open temporary file: $!");
while(<OUT>) { print STDOUT $_;}
close OUT or Log("WARNING","can't close temporary file: $!");
unlink $tmp or Log("WARNING","can't delete temporary file: $!");
Log("INFO","Job $opt{j} ($opt{J}) converted");
exit $JSUCC;