This is the code I am trying to execute. It works and I see the document in the printer queue, but the printer does not print the page.
Printing from other apps does not get stuck in the queue.
Any idea what the problem is?
My printer is HP Deskjet 3512 on port USB001
public static void main(String[] args) {
PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
String printText = "Hello World";
try {
SimpleDoc doc;
doc = new SimpleDoc(printText.getBytes(), javax.print.DocFlavor.BYTE_ARRAY.AUTOSENSE, null);
DocPrintJob job = pservice.createPrintJob();
job.print(doc, new HashPrintRequestAttributeSet());
System.out.println("Job sent to printer succesfully");
} catch (Exception e) {
e.printStackTrace();
}
}