Last active
July 4, 2022 12:03
-
-
Save rodrigocananea/e4de0d01077ea248b2d743b7df6f0027 to your computer and use it in GitHub Desktop.
Abrir gaveta de dinheiro usando Epson ou Bematech por comando de impressão - Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void abrirGaveta() { | |
javax.print.DocPrintJob dpj = PrinterService.getImpressoraPadrao().createPrintJob(); | |
javax.print.DocFlavor flavor = javax.print.DocFlavor.BYTE_ARRAY.AUTOSENSE; | |
//byte[] bematech = new byte[]{(byte) 29, (byte) 249, (byte) 32, (byte) 0, (byte) 27, (byte) 118, (byte) 140}; | |
byte[] epson = new byte[]{(byte) 27, (byte) 112, (byte) 0, (byte) 10, (byte) 100}; | |
javax.print.Doc doc = new javax.print.SimpleDoc(epson, flavor, null); | |
try { | |
dpj.print(doc, null); | |
//JOptionPane.showMessageDialog(null, "Gaveta aberta!", "Atenção", JOptionPane.INFORMATION_MESSAGE); | |
} catch (Exception e) { | |
logger.error("Erro ao abrir gaveta, motivo:"); | |
logger.error(e.getMessage()); | |
JOptionPane.showMessageDialog(null, "Erro ao abrir gaveta!\n" + e.getMessage(), | |
"Erro", JOptionPane.ERROR_MESSAGE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Me ajudou aqui @rodrigocananea.
Obrigado por compartilhar!