Re: Printing API and Attributes
Marian Schedenig wrote:
Firstly: I have written Java apps which successfully print Postscript
files to a HP 1320, however I am relatively new to Java so beware:
I can print .ps files with no problems on my windows box at work, but
the printer completely ignores all attributes I specify.
Do you mean your programs reads a disk file that contains Postscript?
The printer is a HP LaserJet 1320 PS. It correctly gives me a list of
media trays. But regardless of which tray I select, or what orientation
or number of copies, I always get exactly one printout in portrait mode
from the standard tray. Now the printer really has only one tray plus a
manual feed, but I figure even if all other reported trays are
redirected to the standard tray by the driver, at least the manual feed
should work separately - and if not that, I'd still expect it to handle
at least the Copies attribute correctly.
Here's the code I use for printing:
public void print(PrintService ps, MediaTray mt, int copies, boolean
landscape, InputStream in) throws PrintException
DocPrintJob pj = ps.createPrintJob();
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
If the printer is a Postscript printer and the Java print system
AUTOSENSEs that your input stream is postscript - I wonder how the Java
print stream can possibly insert the appropriate setpagedevice
statements into the appropriate place in the existing Postscript from
the InputStream. This isn't trivial for arbitrary Postscript files and I
wouldn't be surprised if the Java print system didn't attempt it.
Doc doc = new SimpleDoc(in, flavor, null);
What is in the InputStream?
PrintRequestAttributeSet attributes = new
if (mt != null)
I'd do a System.out.println("Media tray '"+mt.someMethod()+"'"); to see
if mt contains what you think it does.
You also need to be sure that the 1320 doesn't simply switch to tray 2
if it thinks tray 1 (manual feed) is empty or if you haven't explicitly
told it to wait for manual feed.
I'd be inclined to get the app to print to file using the Windows driver
for the 1320 and compare that with whatever is in the inputstream (which
I'd simplify for testing purposes).