Selecting printer trays is failing.

By: Stuart Guthrie - stuartguthrie
Selecting printer trays is failing.
2005-04-10 23:52
This is either a comprehension problem or a bug or undocumented feature.

I've had some success getting cheques printing for a client however the javax.print, jasper and cups.

The problem is that it seems to ignore the tray selection I'm requesting and send all prints to the top tray.

The requirement is to print a cheque on cheque stationery then a copy of the cheque on paper stationery in the lower tray.

The process is printing both to the top tray!

I think it's just ignoring te attribute. Perhaps CUPS is stripping it off as it goes to print?

java ver is java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)

OS is gentoo linux as at current as at d7/m4/y2005

Any suggestions most welcome. Code is as follows. Second bit commented out is the bit that just prints on the same tray whereas I'm directing it to the bottom tray.


// Find the Print Service
PrinterJob job = PrinterJob.getPrinterJob();
//DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
PrintRequestAttributeSet aset = new
HashPrintRequestAttributeSet();

PrintServiceAttributeSet pset = new
HashPrintServiceAttributeSet();
//aset.add(MediaSize.A4);
//MediaSize.
// This indicates the Cheque tray.

PrintService[] services =
PrintServiceLookup.lookupPrintServices(flavor, aset);
int i = 0;
while ( i < services.length)
{
logger.info("Checking Printer
Service:"+services.getName()+" len:
"+services.getName().length());
logger.info("Against User Printer
Service:"+sessionClient.getDefaultPrinter()+" len:
"+sessionClient.getDefaultPrinter().length());
if
(services.getName().equalsIgnoreCase(sessionClient.getDefaultPrinter())){
logger.info("Found a service.");
//Set the printer name!
pset.add((PrinterName)services.getAttribute(PrinterName.class));
// THIS CURRENTLY DOES NOTHING.
aset.add(MediaTray.BOTTOM);
// OK now try to print!!!
JRExporter exporter = new JRPrintServiceExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT,
jasperPrint);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET,
pset);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET,
aset);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,
Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG,
Boolean.FALSE);

// Print!!
exporter.exportReport();
logger.info("Printed Cheque.");

// Now Print the same thing to the top tray...

// THIS DOES NOT WORK. STILL LOOKING FOR A SOLUTION...

// Maybe re-get the service...

// aset = new HashPrintRequestAttributeSet();
// aset.add(MediaTray.TOP);
// exporter = new JRPrintServiceExporter();
// exporter.setParameter(JRExporterParameter.JASPER_PRINT,
jasperPrint);
//
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET,
pset);
//
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET,
aset);
//
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG,
Boolean.FALSE);
//
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG,
Boolean.FALSE);
//
// // Print!!
// exporter.exportReport();
// logger.info("Printed Paper Version.");

printSucceeded = true;
break;
}
i++;
}



TIA

Stuart Guthrie




By: Ruben Misrahi - rnmisrahi
RE: Selecting printer trays is failing.
2005-07-13 07:35
I have the same problem.

Is the tray funcitonality going to work on a future update?

Are we left to our devices now that Jasper became sort of commercial?




By: cando - cando05
RE: Selecting printer trays is failing.
2005-07-13 08:29
I also had trouble specifing the tray using java 1.4.2.
I tried all of the tray options and found that MediaTray.BOTTOM never worked me.
MediaTray.MIDDLE would consistantly do tray 2
MediaTray.TOP would select the top tray, but this may have been a default.

There are a lot of moving parts, I was happy to get tray 2 working, and moved on.

Hope this helps.




By: snowghost - the-snowghost
RE: Selecting printer trays is failing.
2005-08-03 00:00
I have the same problem with the printer tray - I can?t get another tray than the default to work.

It would be really great if someone can provide an example for this problem....

Thanks.
Snowghost
2004 IR Help's picture
Joined: Aug 17 2006 - 3:49am
Last seen: 15 years 9 months ago

0 Answers:

No answers yet
Feedback