问题描述
现象:运行后,打印机任务已经产生了,显示正在打印,只是打印机一直不动,最后打印任务消失。没有把pdf文件打印出来。求解决。publicstaticvoidmain(String[]args){DocFlavorflavor=DocFlavor.INPUT_STREAM.AUTOSENSE;PrintRequestAttributeSetaset=newHashPrintRequestAttributeSet();PrintService[]pservices=PrintServiceLookup.lookupPrintServices(flavor,aset);PrintServicedefaultService=PrintServiceLookup.lookupDefaultPrintService();PrintServiceservice=ServiceUI.printDialog(null,200,200,pservices,defaultService,flavor,aset);if(service!=null){try{DocPrintJobpj=service.createPrintJob();FileInputStreamfis=newFileInputStream("D:"+File.separator//用AUTOSENSE打印pdf和rtf文件都是正在打印,但是打印机不动+"qindq.pdf");DocAttributeSetdas=newHashDocAttributeSet();Docdoc=newSimpleDoc(fis,flavor,das);pj.print(doc,aset);}catch(FileNotFoundExceptionfe){fe.printStackTrace();}catch(PrintExceptione){e.printStackTrace();}}else{System.out.println("打印失败");}}