Hi All
As part of my program, I need to submit certain documents to one tray(with preprinted paper) and other documents to default tray.
I have used the following options with out luck.
1. Programmatically setting the printer by passing the following code in my attribute set
PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet(); attributeSet.add(MediaTray.MIDDLE);
2. programmatically setting the printer by the following option
Media med[] = (Media[])service.getSupportedAttributeValues(Media.class, null, null); for (int k=0; k<med.length; k++) { if(med[k].getClass().equals(sun.print.Win32MediaTray.class) && med[k].toString().trim().contains("Tray 2")) { SunAlternateMedia am = new SunAlternateMedia(med[k]); attributeSet.add(am); }
3. created a logical printer by disabling all the trays except "tray 2" in printer properties. In this scenario, if I print a pdf document using acrobat reader and selected my newly created logical printer, printer was printing on certified paper. The same is not possible through my java program
4. Created a custom size for tray 2 by adding 0.01 inches more to the letter size and defined the same in my java program as follows.
Any suggestions please!!!float printableX = (float)8.51; float printableY = (float)11.01; PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();; MediaSizeName mediaSizeName = MediaSize.findMedia(printableX,printableY,MediaPrintableArea.INCH); attributeSet.add(mediaSizeName); PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, null); PrintService service =(PrintService)services; if(service.getName().contains("NEW_MAIL2")){ System.out.println(" printername ::"+service.getName()); DocPrintJob job = service.createPrintJob(); Doc doc = new SimpleDoc(is, flavor, null); job.print(doc, attributeSet); }
My printer is HP LaserJet 9050 PCL 5e
Thanks in advance,
Gupta