0
Printer-Apiは、Printer.getAllPrinters()
というシステムのすべてのプリンタを提供します。アクティブなプリンタをすべて手に入れよう
問題は、選択したプリンタがアクティブであることをユーザーが認識していないことです。
アクティブなプリンタのみを取得する機会はありますか?
PrinterAttributes
を助けることができますか?
Printer-Apiは、Printer.getAllPrinters()
というシステムのすべてのプリンタを提供します。アクティブなプリンタをすべて手に入れよう
問題は、選択したプリンタがアクティブであることをユーザーが認識していないことです。
アクティブなプリンタのみを取得する機会はありますか?
PrinterAttributes
を助けることができますか?
私はjavaFXについてはわかりませんが、Java Print APIのPrintServiceクラスを使用してこれを実現できます。
DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.ISO_A4);
PrintService[] pservices =
PrintServiceLookup.lookupPrintServices(flavor, aset);
今、あなたは、これらのサービスを反復処理し、印刷サービスはまだ例の場合
利用可能であるかどうかを識別するためにPrinterStateとPrinterStateReasonクラスを使用することができます。
PrinterState prnState = (PrinterState)service.getAttribute(
PrinterState.class);
if (prnState == PrinterState.STOPPED) {
PrinterStateReasons prnStateReasons =
(PrinterStateReasons)service.getAttribute(
PrinterStateReasons.class);
if ((prnStateReasons != null) &&
(prnStateReasons.containsKey(PrinterStateReason.SHUTDOWN)))
{
throw new PrinterException("PrintService is no longer available.");
}
}
が、これは
を役に立てば幸い