I am trying to print using javax. A simple print job is always printed as double sided even though the javax defaults to single sided, plus the printer is setup as 1 page per sheet.
The printer is HP 2015DN and here is my code:
String filename = "test.txt";
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintService printService[] = PrintServiceLookup.lookupPrintServices(
flavor, pras);
PrintService defaultService = PrintServiceLookup
.lookupDefaultPrintService();
PrintService service = ServiceUI.printDialog(null, 200, 200,
printService, defaultService, DocFlavor.INPUT_STREAM.AUTOSENSE, pras);
if (service != null) {
DocPrintJob job = service.createPrintJob();
FileInputStream fis = new FileInputStream(filename);
DocAttributeSet das = new HashDocAttributeSet();
Doc doc = new SimpleDoc(fis, flavor, das);
pras.add(new Copies(1));
job.print(doc, pras);
fis.close();
}
I know that the printer can print single-sided because Notepad++ is able to do so..
Any help would be appreciated.. Thanks..