Example usage for javax.print StreamPrintService getAttributes

List of usage examples for javax.print StreamPrintService getAttributes

Introduction

In this page you can find the example usage for javax.print StreamPrintService getAttributes.

Prototype

public PrintServiceAttributeSet getAttributes();

Source Link

Document

Obtains this print service's set of printer description attributes giving this Print Service's status.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    OutputStream fos = new BufferedOutputStream(new FileOutputStream("filename.ps"));
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor,
            DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());

    StreamPrintService service = factories[0].getPrintService(fos);
    Attribute[] attrs = service.getAttributes().toArray();
    for (int j = 0; j < attrs.length; j++) {
        String attrName = attrs[j].getName();
        String attrValue = attrs[j].toString();
        System.out.println(attrName);
        System.out.println(attrValue);
    }//from w ww . j  a v a 2  s . co m
}