I'm here to ask you a solution to this problem:
I have this code:
public void print(String ip, int port, String printService, byte[] message, String jobName) throws PrinterException{
PrintService service = getPrintService(printService);
try {
Doc doc = new SimpleDoc(message, DocFlavor.BYTE_ARRAY.AUTOSENSE, null);
DocPrintJob job = service.createPrintJob();
PrintRequestAttributeSet arset = new HashPrintRequestAttributeSet();
arset.add(convertMediaSize(mediaSize));
arset.add(Finishings.STAPLE);
arset.add(MultipleDocumentHandling.SEPARATE_DOCUMENTS_COLLATED_COPIES);
arset.add(convertPageSides(pageSides));
arset.add(new Copies(copies==0?1:copies));
job.print(doc, arset);
} catch (Exception e) {
throw new PrinterException(e);
}
}
the message is a byte array generated from a PDF.
When I execute this code printing on a Canon iR-ADV 400/500 PLC5e (setted as default printer) output is ok.
When I execute this code printing on a Canon iR-ADV c5235/5240 PCL5c, output is lots of pages full of strange chars:
strange chars
Both printers are network printers in the same network, if I try to print on both printers using word or Notepad or Acrobat Reader... output is ok.
I'm trying to print from Windows, not from Linux.
"message" is generated in this way (in my test)
File file = new File(inputFile);
byte[] b = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(b);
wp.print(null, 0, printService, b, null);
Any ideas? thanks