e707. determining print job capabilities supported by a print service.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 21 行

TXT
21
字号
The capabilities of a print job are called print job attributes. Examples of print job attributes include - Copies, OrientationRequested, and Destination. This example demonstrates how to retrieve the supported print job attributes of a print service. 
    // Get all print job attributes of a print service
    Class[] cats = service.getSupportedAttributeCategories();
    for (int j=0; j<cats.length; j++) {
        Attribute attr = (Attribute)service.getDefaultAttributeValue(cats[j]);
    
        if (attr != null) {
            // Get attribute name and values
            String attrName = attr.getName();
            String attrValue = attr.toString();
    
            Object o = service.getSupportedAttributeValues(attr.getCategory(), null, null);
            if (o.getClass().isArray()) {
                for (int k=0; k<Array.getLength(o); k++) {
                    Object o2 = Array.get(o, k);
                }
            }
        }
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?