Java Printer Usage getAvailablePrinters()

Here you can find the source of getAvailablePrinters()

Description

get Available Printers

License

Open Source License

Declaration

public static PrintService[] getAvailablePrinters() 

Method Source Code


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

import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.Copies;

public class Main {
    public static PrintService[] getAvailablePrinters() {
        final PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
        printRequestAttributeSet.add(new Copies(1));
        return PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.PNG, printRequestAttributeSet);
    }//from w  ww .  j a v  a  2s.c  o  m
}

Related

  1. createPrintRequestAttributeSet(int width, int height)
  2. findPrintService(String printerName)
  3. get_print_service(String printerName, HashPrintRequestAttributeSet aset)
  4. getArrayOfPrinterNames()
  5. getAttribute( PrintService ps, Class category)
  6. getDefaultPrinterName()
  7. getDefaultPrinterName()
  8. getDefaultPrintRequestAttributes()
  9. getEnumAttribute(String name, Object value)