List of utility methods to do Printer Usage
double | convertPageFormatUnit(int oldUnit, int newUnit, double value) convert Page Format Unit return new MediaSize(0, (float) value, oldUnit).getY(newUnit); |
PrintRequestAttributeSet | createPrintRequestAttributeSet(int width, int height) create Print Request Attribute Set final PrintRequestAttributeSet result = new HashPrintRequestAttributeSet(); result.add(MediaSizeName.ISO_A4); result.add(OrientationRequested.PORTRAIT); result.add(new MediaPrintableArea(0, 0, width, height, MediaPrintableArea.MM)); return result; |
PrintService | findPrintService(String printerName) find Print Service 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 | get_print_service(String printerName, HashPrintRequestAttributeSet aset) geprinservice PrintService[] pservices = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, aset); if (pservices == null) return null; for (int i = 0; i < pservices.length; i++) { if (pservices[i] != null && pservices[i].toString() != null && pservices[i].getName().trim().equals(printerName.trim())) return pservices[i]; ... |
String[] | getArrayOfPrinterNames() get Array Of Printer Names PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null); String printers[] = new String[services.length]; for (int i = 0; i < services.length; i++) { printers[i] = services[i].getName(); return printers; |
T | getAttribute(PrintService ps, Class get Attribute if (ps == null || !isGoodPrinterName(ps.getName())) return null; return ps.getAttribute(category); |
PrintService[] | getAvailablePrinters() get Available Printers final PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet(); printRequestAttributeSet.add(new Copies(1)); return PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.PNG, printRequestAttributeSet); |
String | getDefaultPrinterName() get Default Printer Name if (bWaitForPrinterServer) return defaultPrinterName; bWaitForPrinterServer = true; if (defaultPrinterName == null) { long t = System.currentTimeMillis() / 1000; if ((t - lastQueryTime) < 120) { bWaitForPrinterServer = false; return defaultPrinterName; ... |
String | getDefaultPrinterName() get Default Printer Name if (PrintServiceLookup.lookupDefaultPrintService() != null) { return PrintServiceLookup.lookupDefaultPrintService().getName(); return ""; |
PrintRequestAttributeSet | getDefaultPrintRequestAttributes() Return Default Print Request Attributes return s_prats;
|