0

我用 Java 编写了一个小型应用程序,用于原始打印、条形码等。P-touch Editor 在我的 Brother QL-800 中打印得非常好,但是……在我的 java 应用程序中没有,没有任何反应;打印机不打印。没有警告,没有错误。这里的java代码:

PrintService printService = PrinterOutputStream.getPrintServiceByName("Brother QL-800");
DocPrintJob job = printService.createPrintJob();  
String data = 
"\\x1B" + "\\x69" + "\\x61" + "\\x00" + "\\x1B" + "\\x40\r\n" // set printer to ESC/P mode and clear memory buffer
+ "\\x1B" + "\\x69" + "\\x4C" + "\\x01\r\n"  // set landscape mode
+ "\\x1B" + "\\x55" + "\\x02" + "\\x1B" + "\\x33" + "\\x0F\r\n" // set margin (02) and line feed (0F) values
+ "\\x1B" + "\\x6B" + "\\x0B" + "\\x1B" + "\\x58" + "\\x00" + "\\x3A" + "\\x00\r\n" // set font and font size 
+ "Printed by \r\n" // "Printed by "
+ "QZ-Tray\r\n" // "QZ-Tray"
+ "\\x0A" + "\\x0A\r\n"// line feed 2 times
+ "\\x1B" + "\\x69" + "\\x74" + "\\x30\r\n" // set to code39 barcode
+ "\\x72" + "\\x31\r\n" // characters below barcode
+ "\\x65" + "\\x30" + "\\x68" + "\\x65" + "\\x00" + "\\x77" +"\\x34" + "\\x7A" + "\\x32\r\n" // parentheses y/n, height, width of barcode, 2:1 ratio wide to narrow bars
"\\x42" + "1234567890" + "\\x5C\r\n" // begin barcode data, data, end barcode data
+ "\\x0A" + "\\x0A\r\n" // line feed 2x
+ "\\x0C"; // <--- Tells the printer to print 
// flavor is BYTE_ARRAY
Doc doc;
    try {
        doc = new SimpleDoc(data.getBytes("UTF-8"), flavor, null);
        job.print(doc, null);
        } catch (UnsupportedEncodingException | PrintException e1) {
            Logger.getLogger(GenerarBC.class.getName()).log(Level.SEVERE, null, e1);
        }

我的十六进制转储是: 我打印的十六进制转储

怎么了?我需要打开 USB 端口吗?我坚持这个......任何建议将不胜感激TIA!

4

0 回答 0