Here you can find the source of getPrinterJobProperties(PrintService ps)
@SuppressWarnings("unchecked") public static Map<String, Object> getPrinterJobProperties(PrintService ps)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; import javax.print.PrintService; import javax.print.PrintServiceLookup; import javax.print.attribute.Attribute; public class Main { @SuppressWarnings("unchecked") public static Map<String, Object> getPrinterJobProperties(PrintService ps) { Map<String, Object> map = new HashMap<>(); if (ps != null) { Class<? extends Attribute>[] supportedAttributes = (Class<? extends Attribute>[]) ps .getSupportedAttributeCategories(); for (int i = 0, max = supportedAttributes.length; i < max; i++) { Class<? extends Attribute> attr = supportedAttributes[i]; map.put(supportedAttributes[i].getSimpleName(), ps.getDefaultAttributeValue(attr)); }//from w w w.j a v a 2 s . c o m } return map; } public static Map<String, Object> getPrinterJobProperties(String printerName) { PrintService ps = findPrintService(printerName); return getPrinterJobProperties(ps); } public static PrintService findPrintService(String printerName) { PrintService printService = null; if (printerName == null || printerName.isEmpty()) { printService = PrintServiceLookup.lookupDefaultPrintService(); } else { PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); for (PrintService service : services) { String prtName = service.getName(); if (prtName.contains(printerName)) { printService = service; break; } } } return printService; } }