[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Printing Postscript Direct.



Hi all,

Thanks for the suggestions. Here is the code. Danny Thomas
<D.Thomas@vthrc.uq.edu.au> alerted me to the fact that opening Dev:Printer
may not work properly using with either desktop printers and/or quickdraw
GX. It works with my desktop printer (tho I only have one), but it bypasses
the normal printer driver so, for instance, stopping the print queue has no
effect.

The code was from Dan Herron <herron@cogsci.ucsd.edu>.

#!/usr/local/bin/perl

# Reads from either the file specified or standard input.

open(STDIN, $ARGV[0]) || die "Can't open $ARGV[0]: $!\n"
        if $ARGV[0];

if (!open(OUTFILE, "+>Dev:Printer")) {
        &MacPerl'Answer("Couldn't connect to printer.", "OK");
        exit;
}
select((select(OUTFILE), $|=1, $/="\012")[0]);

# print PS file
while (<STDIN>) {
        print OUTFILE;
}

# finish the print job and check for messages from the printer

shutdown(OUTFILE,1);

while (<OUTFILE>) {
        s/\012/\015/g;
        &MacPerl'Answer("Message from printer:\n$_", "OK");
}


-- Richard Padley, Consultant Programmer --
-- RDP Computing, 7 Whichelo Place       --
-- Brighton BN2 2XE, UK                  --
-- voice/fax +1273 381069                --