2

Estoy tratando de comenzar a trabajar con comandos ESC / P con una impresora de etiquetas Brother QL-800. He probado el software de la impresora, P-touch Editor 5.0, y si puedo imprimir las etiquetas que yo quiera, la impresora funciona bien, pero, cuando se trata de hacer mis propias etiquetas de código Java, la impresora no funciona en Todo, no responde. ¿Qué puedo probar ahora?

Este es el código que utilizo. ¿Que estoy haciendo mal?

public class PrintESC_P {   
    public static void main(String[] args) {
        PrintService printService = null;
        String printerName = "Brother QL-800";
        HashAttributeSet attributeSet = new HashAttributeSet();
        attributeSet.add(new PrinterName(printerName, null));
        PrintService[] services = PrintServiceLookup.lookupPrintServices(null, attributeSet);
        if (services.length == 0) {
            throw new IllegalArgumentException("Printer not found.");
        } else if (services.length > 1) {
            System.out.println("Found more than one printer. Only the first printer will be used.");
        }
        printService = services[0];
        System.out.println("Printer found: "+printService.getName());
        try {
            DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;          
            String _ESC_P_Code = "ESC i a 00h\r\n"  +
                    "ESC @\r\n" +
                    "ESC i L 01h\r\n" +
                    "ESC ( C 02h 00h FCh 02h\r\n" +
                    "ESC $ 2Bh 00h\r\n" +
                    "ESC ( V 02h 00h 6Dh 01h\r\n" +
                    "ESC k 0bh\r\n" +
                    "ESC X 00h 64h 00h\r\n" +
                    "PRINTER TEST\r\n" +
                    "ESC i C\r\n" +
                    "FF\r\n";
            SimpleDoc doc = new SimpleDoc(_ESC_P_Code.getBytes(), flavor, null);
            DocPrintJob job = printService.createPrintJob();
            job.print(doc, null);
        } catch (Exception e) {
        e.printStackTrace();
        }
    }
}

0

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.