Hi all,
I've been trying to print files to an EPSON Dot Matrix printer. I'm sending raw data to the printer. When I print one file, the routine works fine. But when I tried printing multiple files, that is by calling the .print() method, nothing gets printed at all.. Can anybody explain why this happens? And how can I try to print multiple files? I've tried getting it on an array but still it doesn't work. By the way, here is my code:
public void printTheFile(String file){
PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
try {
if (ps!=null){
PrintRequestAttributeSet aset= new HashPrintRequestAttributeSet();
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
aset.add(new MediaPrintableArea (9,21,200,139,Size2DSyntax.MM));
Doc pj = ps.createPrintJob();
try {
InputStream b = new BufferedInputStream(new FileInputStream(file));
Doc doc = new SimpleDoc(b, flavor, null);
pj.print(doc, aset);
}catch (PrintException e){
e.printStackTrace();
}catch(Exception e) {
e.printStackTrace();
}//catch
}
}catch (Exception e){
e.printStackTrace();
}//catch
}