Discovering Available Print Services : Print Service « 2D Graphics GUI « Java






Discovering Available Print Services

  

import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.AttributeSet;
import javax.print.attribute.HashAttributeSet;
import javax.print.attribute.standard.ColorSupported;
import javax.print.attribute.standard.PrinterName;

public class Main {
  public static void main(String[] argv) throws Exception {
    PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
    PrintService service = PrintServiceLookup.lookupDefaultPrintService();

    services = PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.GIF, null);

    AttributeSet aset = new HashAttributeSet();
    aset.add(new PrinterName("HP LaserJet", null));
    services = PrintServiceLookup.lookupPrintServices(null, aset);

    aset = new HashAttributeSet();
    aset.add(ColorSupported.SUPPORTED);
    services = PrintServiceLookup.lookupPrintServices(null, aset);

  }
}

   
    
  








Related examples in the same category

1.Determining the Capabilities of a Print Service
2.List Print Services
3.Using a Printing Service
4.Using a Streaming Printing Service
5.Discovering Available Streaming Print Services
6.Use a factory to create a print service
7.Print a GIF image to any of the print services that support the GIF document flavor