Java Printer Usage getAttribute( PrintService ps, Class category)

Here you can find the source of getAttribute( PrintService ps, Class category)

Description

get Attribute

License

GNU General Public License

Declaration

public static <T extends PrintServiceAttribute> T getAttribute(
            PrintService ps, Class<T> category) 

Method Source Code

//package com.java2s;
/*/*from w ww .  j  a va2s.com*/
 * Copyright (C) 2015  University of Oregon
 *
 * You may distribute under the terms of either the GNU General Public
 * License or the Apache License, as specified in the LICENSE file.
 *
 * For more information, see the LICENSE file.
 */

import javax.print.*;

import javax.print.attribute.*;

public class Main {
    public static <T extends PrintServiceAttribute> T getAttribute(
            PrintService ps, Class<T> category) {
        if (ps == null || !isGoodPrinterName(ps.getName()))
            return null;
        return ps.getAttribute(category);
    }

    public static boolean isGoodPrinterName(String name) {
        if (name == null)
            return false;
        if (name.equals("jeff_pl") || name.equals("jeff_pr"))
            return false;
        if (name.equals("steve_pl") || name.equals("steve_pr"))
            return false;

        return true;
    }
}

Related

  1. convertPageFormatUnit(int oldUnit, int newUnit, double value)
  2. createPrintRequestAttributeSet(int width, int height)
  3. findPrintService(String printerName)
  4. get_print_service(String printerName, HashPrintRequestAttributeSet aset)
  5. getArrayOfPrinterNames()
  6. getAvailablePrinters()
  7. getDefaultPrinterName()
  8. getDefaultPrinterName()
  9. getDefaultPrintRequestAttributes()