Java Printer Usage findPrintService(String printerName)

Here you can find the source of findPrintService(String printerName)

Description

find Print Service

License

Open Source License

Declaration

public static PrintService findPrintService(String printerName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.print.PrintService;
import javax.print.PrintServiceLookup;

public class Main {

    public static PrintService findPrintService(String printerName) {
        PrintService printService = null;
        if (printerName == null || printerName.isEmpty()) {
            printService = PrintServiceLookup.lookupDefaultPrintService();
        } else {//from   w  w  w .ja  v a2s . c o m
            PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
            for (PrintService service : services) {
                String prtName = service.getName();
                if (prtName.contains(printerName)) {
                    printService = service;
                    break;
                }
            }
        }
        return printService;
    }
}

Related

  1. convertPageFormatUnit(int oldUnit, int newUnit, double value)
  2. createPrintRequestAttributeSet(int width, int height)
  3. get_print_service(String printerName, HashPrintRequestAttributeSet aset)
  4. getArrayOfPrinterNames()
  5. getAttribute( PrintService ps, Class category)
  6. getAvailablePrinters()