PrintService (Java SE 15 & JDK 15) (original) (raw)

All Known Subinterfaces:

[MultiDocPrintService](MultiDocPrintService.html "interface in javax.print")

All Known Implementing Classes:

[StreamPrintService](StreamPrintService.html "class in javax.print")


public interface PrintService

Interface PrintService is the factory for a DocPrintJob. APrintService describes the capabilities of a printer and can be queried regarding a printer's supported attributes.

Example:


   DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
   PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
   aset.add(MediaSizeName.ISO_A4);
   PrintService[] pservices =
                 PrintServiceLookup.lookupPrintServices(flavor, aset);
   if (pservices.length > 0) {
       DocPrintJob pj = pservices[0].createPrintJob();
       try {
           FileInputStream fis = new FileInputStream("test.ps");
           Doc doc = new SimpleDoc(fis, flavor, null);
           pj.print(doc, aset);
        } catch (FileNotFoundException fe) {
        } catch (PrintException e) {
        }
   }
   
Modifier and Type Method Description
void addPrintServiceAttributeListener​(PrintServiceAttributeListener listener) Registers a listener for events on this PrintService.
DocPrintJob createPrintJob() Creates and returns a PrintJob capable of handling data from any of the supported document flavors.
boolean equals​(Object obj) Determines if two services are referring to the same underlying service.
<T extends PrintServiceAttribute>T getAttribute​(Class category) Gets the value of the single specified service attribute.
PrintServiceAttributeSet getAttributes() Obtains this print service's set of printer description attributes giving this Print Service's status.
Object getDefaultAttributeValue​(Class<? extends Attribute> category) Determines this print service's default printing attribute value in the given category.
String getName() Returns a string name for this print service which may be used by applications to request a particular print service.
ServiceUIFactory getServiceUIFactory() Returns a factory for UI components which allow users to interact with the service in various roles.
Class<?>[] getSupportedAttributeCategories() Determines the printing attribute categories a client can specify when setting up a job for this print service.
Object getSupportedAttributeValues​(Class<? extends Attribute> category,DocFlavor flavor,AttributeSet attributes) Determines the printing attribute values a client can specify in the given category when setting up a job for this print service.
DocFlavor[] getSupportedDocFlavors() Determines the print data formats a client can specify when setting up a job for this PrintService.
AttributeSet getUnsupportedAttributes​(DocFlavor flavor,AttributeSet attributes) Identifies the attributes that are unsupported for a print request in the context of a particular DocFlavor.
int hashCode() This method should be implemented consistently withequals(Object).
boolean isAttributeCategorySupported​(Class<? extends Attribute> category) Determines whether a client can specify the given printing attribute category when setting up a job for this print service.
boolean isAttributeValueSupported​(Attribute attrval,DocFlavor flavor,AttributeSet attributes) Determines whether a client can specify the given printing attribute value when setting up a job for this Print Service.
boolean isDocFlavorSupported​(DocFlavor flavor) Determines if this print service supports a specific DocFlavor.
void removePrintServiceAttributeListener​(PrintServiceAttributeListener listener) Removes the print-service listener from this print service.