Rick Cochran wrote:How about writing a program to create a PPD file automatically by querying the printer?
This would be great, but how do they do this, I only know how to retreive PJL options from a PJL-capable printer. See the "foomatic-getpjloptions" script of the foomatic-db-engine package on linuxprinting.org:
http://www.linuxprinting.org/cvsweb.cgi/~checkout~/foomatic-db-engine/foomatic-getpjloptions.in?rev=3.0&content-type=text/plain
but only a small part of the printer's options are PJL options (for example PageSize and Resolution are usually PostScript commands to insert in the job data) and some printers (as the Brother HL-5040) do not answer to the script.
See attached files. This is as far as I got.
If there is no way to detect some printer features via PostScript, one could think about using SNMP.
I think Adobe had or has something like this. One sees references to it in the comments of some PPD files.
Did they somewhere publish the protocols for this?
All the stuff I'm using is in the PostScript spec.
If you want to write such a tool, join the Foomatic project and then one can make a queue for a PostScript printer simply with foomatic-configure, without needing to have a PPD file or the Foomatic database installed.
I might be interested if the project is really feasible.
Some of the commercial PPDs seem _way_ more complicated than they need to be.
Some manufacturer's, as HP, have implemented some options completely in PostScript (as N-up or watermarks), so to the appropriate option choices not simple PostScript commands but complete subroutines are assigned.
But HP's PPDs on http://www.linuxprinting.org/download/PPD/ are free software, so one can rip out this code and paste it into another PPD (for example of an Epson printer) to add these options there. I have already accidentally created a print queue for an Epson AcuLaser C2000 PS using HP�s PPD file for the HP LaserJet 4050, and HP�s N-up option worked nicely on the AcuLaser. If I had Epson�s PPD and pasted the N-up option there I would have it even in color, but I didn�t find Epson�s PPD.
A sore point.
I have to carefully remove HP's N-up code from their PPD files because it interferes with my use of EndPage to implement my banner page alternative.
Why does HP go to all the trouble to implement a feature which is already implemented in the fine Adobe PostScript driver without pre-empting everyone else's use of EndPage?
-Rick
-- |Rick Cochran phone: 607-255-7618| |Cornell CIT - Systems & Operations - Net-Print FAX: 607-255-8521| |730 Rhodes Hall, Ithaca, N.Y. 14853 email: [EMAIL PROTECTED]|
#!/usr/common/bin/perl
use strict;
use Socket;
my $printer_name = $ARGV[0];
$| = 1;
my $infile = 'querynp.ps';
open(F, $infile)
or die "Unable to open $infile ($!)\n";
my $outfile = 'query_printer.out';
#open(G, ">$outfile")
# or die "Unable to create $outfile ($!)\n";
# Open socket connection to printer
my $port = 9100; # "Standard" TCP port used by TCP printers
my $proto;
$proto = getprotobyname('tcp');
my(undef, undef, undef, undef, @printer_ip) = gethostbyname($printer_name);
if ( @printer_ip < 1 ) {
die "ERROR: Printer not found: $printer_name ($!)\n";
}
my $printer_addr = pack("S n a4 x8", AF_INET, $port, $printer_ip[0]);
socket(SOCK, AF_INET, SOCK_STREAM, $proto)
or die "ERROR: socket failed ($!)\n";
connect(SOCK, $printer_addr)
or die "ERROR: connect failed ($!)\n";
select((select(SOCK), $| = 1)[0]); # enable command buffering
#print SOCK "[EMAIL PROTECTED] JOB\n";
#print SOCK "[EMAIL PROTECTED] ENTER LANGUAGE = Postscript\n";
while ( <F> ) {
print SOCK;
}
close(F);
print SOCK "(rumplestiltskin\n) print flush\n";
my $buf;
while ( <SOCK> ) {
last if /rumplestiltskin/;
print;
}
#close(G);
#print SOCK "\004";
#print SOCK "[EMAIL PROTECTED] EOJ\n";
close(SOCK);
exit(0);
querynp.ps
Description: PostScript document
