Skip to main content

How to specify custom (print request) attributes using Java Printing API ?

1 reply [Last post]
tngmech
Offline
Joined: 2009-05-24

I was wondering how to send faxes using the Linux fax driver for the Brother MFC7820N...

As I figured out from the driver one basically needs to pass the option "fax-number=" to the installed printer BRFAX.

This can be done using the brpcfax tool which is basically a shell script using a Java GUI to enter a phone number and passing it to the lpr command. So nothing magic. Just a
lpr -P BRFAX -o fax-number=12345678 fax.ps

Actually I'd like to do this with native Java code using the Java Printing API. Doing a lookup of the printer was no problem, but unfortunately after dumping all Attributes for that service and checking the Javadoc there is obviously no way to pass "custom" attributes to the printer. As far as I understood these attributes are basically nothing else than key-value pairs.

I tried to implement an Attribute class "FaxNumber" with the name "fax-number" and tried to add it as print request attribute, doc attribute, whatever.
However nothing made it to the printer, even after trying to wrap the "real" BRFAX print service with another one that I register after adding my custom fax number attribute class because the returned attribute sets were unmodifiable.

In fact after registering such a proxy service at runtime I can sucessfully query the service and it will tell me that it would support a faxnumber attribute ;-).
But that didn't do the trick for job.print(...), i.e. no faxnumber is passed to the printer.

When setting CUPS to debug mode, I can see some "argv[5]" line that has e.g. media sizes, etc. but not the custom fax-number attribute I try to add. However if I do things with lpr I can see a "fax-number" key-value pair.
So it "should" work, if I can somehow convience Java to send such a "fax-number" option along.

To conclude: Has anyone successfully passed custom attributes from Java comparable to a "lpr -o myOption=myValue" with the Java Printing API?

Given all the add(...) methods of the respective attribute sets available, it should work somehow...

Cheers,
Michael

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
adfrench
Offline
Joined: 2010-04-05

Have you found a solution yet?