Print a file to a printer --------------------------------------------------------------- fis = new FileInputStream(file); DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; // FILE IS .txt TYPE PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); //pras.add(MediaSizeName.ISO_A4); //pras.add(new Copies(1)); PrintService printService[] =PrintServiceLookup.lookupPrintServices(flavor, pras); System.out.println("Print Service:"+printService); PrintService defaultService =PrintServiceLookup.lookupDefaultPrintService(); System.out.println("Default Service:"+defaultService); PrintService service = ServiceUI.printDialog(null, 200, 200,printService, defaultService, flavor, pras); if (service != null) { System.out.println("Selected Service"+service); DocPrintJob job = service.createPrintJob(); job.addPrintJobListener(new MyPrintJobListener()); System.out.println("JOB:"+job); DocAttributeSet das = new HashDocAttributeSet(); Doc doc = new SimpleDoc(fis, flavor, das); System.out.println("Start of Print"); job.print(doc, pras); System.out.println("End of Print"); i=1; } else { i=0; } ---------------------------------------------------------------- |