TavernerPOS - Source Code

Clone: 

git clone http://www.librarysmith.co.uk/tavernerPOS

 

package com.floreantpos.util;

import javax.print.PrintService;
import javax.print.PrintServiceLookup;

public class PrintServiceUtil {
	/**
	 * Get {@link javax.print.PrintService} for specified printer name.
	 *
	 * @param printerName
	 * @return
	 */
	public static PrintService getPrintServiceForPrinter(final String printerName) {
		PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);

		for (int i = 0; i < printServices.length; i++) {
			PrintService printService = printServices[i];
			if (printService.getName().equals(printerName)) {
				return printService;
			}
		}

		return PrintServiceLookup.lookupDefaultPrintService();
	}
}

Add comment
These comments are moderated so so won't be published until reviewed.