I am trying to use Java Print Services for sending print jobs to printers automatically but its quickly turning into a nightmare. Coming to the problem at hand, here is the code:
DocAttributeSet docAset = new HashDocAttributeSet();
docAset.add(MediaSizeName.NA_LETTER);
Doc myDoc = new SimpleDoc(book, psInFormat, docAset);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new JobName("Test Job Name", null));
aset.add(MediaSizeName.NA_LETTER);
aset.add(Sides.ONE_SIDED);
aset.add(Fidelity.FIDELITY_TRUE);
// new JobState()
DocPrintJob job = services[8].createPrintJob();
try {
job.print(myDoc, aset);
//System.out.println(" Thread " + this.getId() + ": Envío de impresión OK");
} catch (PrintException ex) {
Logger.getLogger(PrototypeMain2.class.getName()).log(Level.SEVERE, null, ex);
}
This code is ignoring the media size completely and printing to the default A4 size paper.
Any helps here is very much appreciated.
Seems like the printer is taking the default paper based on the preferences I set, so if I set the preferences to use letter size it asks for a letter size page, by default it will print on A4 size paper.