자바 인쇄 서비스에 문제가 있습니다. 기본 프린터에 간단한 텍스트 문서를 인쇄해야합니다. HP Deskjet을 Windows 컴퓨터의 프린터로 사용합니다. 모든 드라이버가 설치되어 있습니다. 이것은 내가 사용하는 소스 코드입니다 :인쇄 작업이 프린터로 전송되었지만 아무것도 인쇄하지 못했습니다. Java
import java.io.*;
import javax.print.*;
public class PrintTest {
public static void main(String[] args) throws IOException {
File file = new File("print.txt");
InputStream is = new BufferedInputStream(new FileInputStream(file));
//Discover the default print service.
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
//Doc flavor specifies the output format of the file.
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
// Create the print job
DocPrintJob job = service.createPrintJob();
//Create the Doc
Doc doc = new SimpleDoc(is, flavor, null);
//Order to print
try {
job.print(doc, null);
} catch (PrintException e) {
e.printStackTrace();
}
is.close();
System.out.println("Printing done....");
}
}
프린터 대기열에서 인쇄 작업을 몇 밀리 초 전에 볼 수 있습니다. 그러나 아무 것도 인쇄되지 않습니다. 나는 JDK 1.6의 자바 인쇄 서비스가 여전히 버그가 있기 때문에 그것이라고 들었습니다. 그러나 나는 완전히 확신하지 못한다. 어떤 아이디어?
는 내가 같은 문제에 직면하고있어, 당신이 어떤 해결책을 발견하는 경우 알려 주시기 바랍니다. 당신의 응답을 제공 [여기] (http://stackoverflow.com/questions/15810865/print-current-html-page-on-printer-from-java-bean-in-jsf) –