Hi,
I'm trying to use Java's printing API to print a PDF file onto a network/local printer.
My code works fine when I try printing onto Canon printers but the behavior is erratic on HP LaserJet printers.
I've tried using two different models of HP LaserJet (4050 Series and 1020 Series )
1. On HP LaserJet 4050 Series PS the print job is processed, but the printer outputs junk/ascii characters instead of the actual pdf
2. On HP LaserJet 1020 Series the print job reaches the queue but stays there indefinitely with the status message 'Printing'.
After this the only way to bring the printer back alive is to shut it down and restart it again.
In both these cases printing from any other application works fine, I run into these issues while using the printing API.
Here's a code snippet that demonstrates the way my client code is written.
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
pras.add(new Copies(1));
pras.add(MediaSizeName.ISO_A4);
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
ByteArrayInputStream bytesinputStream = new ByteArrayInputStream(myPDFfileContent);
//'printJob' was obtained by iterating over PrintServiceLookup.lookupPrintServices(null, pras);
DocPrintJob job = printJob.getPrintService().createPrintJob();
doc = new SimpleDoc(bytesinputStream, flavor, new HashDocAttributeSet());
job.print(doc, pras);
I'm hoping that someone has experienced this issue before and can help me with this..
Thank you....