PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE; PrintService printService[] =  PrintServiceLookup.lookupPrintServices(flavor, pras); for(int i=0;i<printService.length;i++){ if(printer.trim().equalsIgnoreCase(printService[i].getName())){ printservice = printService[i]; } } }
{ PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE; PrintService printService[] =  PrintServiceLookup.lookupPrintServices(flavor, pras); int i = 0; while ( i<printService.length && !printer.trim().equalsIgnoreCase(printService[i].getName()) ) i++; printservice = i<printService.length ? printService[i] : null; } }
	public SVGTemplatePrinter(String templatefilename, String printer) throws Exception{		Properties data = new Properties();		data.load(new FileInputStream(USERDATAFILENAME));  								userdata = new UserDataVO("", data.getProperty("DN"),0,"", data.getProperty("EMAIL"), 				                                           0,0,0,0, (Date) null, (Date) null,0,0 ,null);				pins[0] = data.getProperty("PIN1");		pins[1] = data.getProperty("PIN2");						puks[0] = data.getProperty("PUK1");		puks[1] = data.getProperty("PUK2");				copyofhardtokensn = data.getProperty("COPYOFHARDTOKENSN");		hardtokensn = data.getProperty("HARDTOKENSN");				int validity = Integer.parseInt(data.getProperty("VALIDITY"));				String hardtokensnprefix = data.getProperty("HARDTOKENSNPREFIX");						// Read the tempate file.		 imagemanipulator = new SVGImageManipulator( new InputStreamReader(new FileInputStream(templatefilename), "UTF-8"), validity, hardtokensnprefix);				// Setup the printer.		 PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();		 DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;		 PrintService printService[] =  PrintServiceLookup.lookupPrintServices(flavor, pras);		 		 for(int i=0;i<printService.length;i++){		 		 	if(printer.trim().equalsIgnoreCase(printService[i].getName())){		 		printservice = printService[i];			 	}		 			 }		 			}			