Thank you for the code.

This does not return the PPD file, but many useful printer capabilities. At first you retrieve make and model exactly as it stands in the PPD file, so you could get the data from the printer and then search the PPD database for this make and model to find exactly the correct PPD file. Then you search querying code in the PPD file, many options, especially "Installable Options" have such query code. You find querying code usually between the "*OpenUI" and "*CloseUI" lines, as the last entry after all the possible choices of the option. The auto-setup code always begins after '*?<option>: "'.

Example (HP LaserJet 4050):

----------------------------------------------------------------------
*OpenUI *Option3/Duplex Unit: Boolean
*DefaultOption3: False
*Option3 True/Installed: ""
*Option3 False/Not Installed: ""
*?Option3: "
  save
    currentpagedevice /Duplex known
    {(True)}{(False)}ifelse = flush
  restore
"
*End
*CloseUI: *Option3
----------------------------------------------------------------------

With this option one selects whether a duplex unit is installed. After the two choices ("Installed", "Not Installed") there is an entry starting with '*?Option3: "' and ending with '"'. All between the two '"' is PostScript code which returns "True" if a duplex unit is installed and false otherwise. So you do your query with this code and know whether there is a duplex unit. Then you set the default of this option appropriately. This you do with all installable options and so you can configure a printer fully automatically. The newbie using your printer config program will have real "plug'n'print".

Till


Rick Cochran wrote:
Till Kamppeter wrote:

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


------------------------------------------------------------------------


#!/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);



----------------------------------------------------------------------------- YOU MUST BE A LIST MEMBER IN ORDER TO POST TO THE LPRNG MAILING LIST The address you post from MUST be your subscription address

If you need help, send email to [EMAIL PROTECTED] (or lprng-requests
or lprng-digest-requests) with the word 'help' in the body.  For the impatient,
to subscribe to a list with name LIST,  send mail to [EMAIL PROTECTED]
with:                           | example:
subscribe LIST <mailaddr>       |  subscribe lprng-digest [EMAIL PROTECTED]
unsubscribe LIST <mailaddr>     |  unsubscribe lprng [EMAIL PROTECTED]

If you have major problems,  send email to [EMAIL PROTECTED] with the word
LPRNGLIST in the SUBJECT line.
-----------------------------------------------------------------------------

Reply via email to