During execution, the below error is displayed when sending a string
to printer.
sun.print.PrintJobFlavorException: invalid flavor
at sun.print.Win32PrintJob.print(Unknown Source)
Complete code
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
PrintService printService = printServices[5];
System.out.println(printService.getName());
DocFlavor docFlavor = DocFlavor.STRING.TEXT_PLAIN;
StringBuilder value = new StringBuilder();
value.append("\n\n");
value.append("\n\tRelação dos Usuários:");
List<Usuario> usuarios = TapiocariaFacade.listarUsuario();
int y = 70;
for(Usuario usuario : usuarios) {
value.append("\n\tNome: " + usuario.getSenha());
value.append("\n\tEndereço: " + usuario.getId());
value.append("\n\tEmail: " + usuario.getEmail());
}
System.out.println(value.toString());
Doc doc = new SimpleDoc(value.toString(), docFlavor, null);
DocPrintJob docPrintJob = printService.createPrintJob();
try {
docPrintJob.print(doc, null);
} catch (PrintException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}