Java印刷サービスに問題があります。私は、単純なテキスト文書をデフォルトのプリンタに印刷する必要があります。私はWindowsマシン上のプリンタとしてHP Deskjetを使用します。すべてのドライバはインストールされています。これは私が使用したソースコードである:印刷ジョブはプリンタに送信されましたが、何も印刷されませんでした。 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....");
}
}
私はそのなくなって前にいくつかのmilisecond用プリンタキューに印刷ジョブを見ることができます。しかし何も印刷されません。 JDK 1.6のJava Print Serviceはまだバグが多いと聞いています。しかし、私は完全にはわかりません。なぜどんなアイデア?
解決策が見つかった場合は教えてください。私は同じ問題に直面しています。あなたの応答をここに与える(http://stackoverflow.com/questions/15810865/print-current-html-page-on-printer-from-java-bean-in-jsf) –