Skip to content

Instantly share code, notes, and snippets.

@HashRaygoza
Last active March 16, 2018 06:15
Show Gist options
  • Save HashRaygoza/a5e8a4f79851546b65aefa3c30ae09fa to your computer and use it in GitHub Desktop.
Save HashRaygoza/a5e8a4f79851546b65aefa3c30ae09fa to your computer and use it in GitHub Desktop.
Encuentra el objeto PrintService que representa la impresora que deseamos usar
/**
* Nos regresa el PrintService que representa la impresora con el nombre que
* le indiquemos
* @param printerName nombre de la impresora que deseamos usar
* @return PrintService que representa la impresora que deseamos usar
*/
private PrintService findPrintService(String printerName) {
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
for (PrintService printService: printServices) {
System.out.println(printService.getName());
if (printService.getName().trim().equals(printerName)) {
return printService;
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment