要从页面调用条码打印机打印条码,打印机型号是,东芝B-452-HS不知道这个有没有关系我还是贴上来。还有从从怎么扫描枪获得扫描的数据!!

解决方案 »

  1.   

    以前做斑马打印机的时候用过ZPL指令通过并口发送的方式控制打印机(C++的),
    扫描枪就比较简单了,你可以把它直接看成键盘,扫描的过程就是输入的过程
      

  2.   


    这位仁兄说的对,
    扫描枪很简单,光标在哪里,扫描的内容就出入到哪里。
    对于java打印,本人用过下面三种方式:
    1.利用FileOutputStream直接输出到端口
     
     FileOutputStream os = new FileOutputStream("LPT1");
     os.write(yourData);
     os.flush();2.利用java print service,(应该要安装驱动,系统中看得见该打印机)PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
                PrintService printService = null;
                if (services != null && services.length > 0) {
                    String printerName = "zebra";// something like this
                    for (PrintService service : services) {
                        if (service.getAttribute(PrinterName.class).getValue().equals(printerName)) {
                            printService = service;
                            break;
                        }
                    }
                }
                if (printService == null) {
                    //do what you want
                }
                DocPrintJob job = printService.createPrintJob();
                DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
                Doc doc = new SimpleDoc(new ByteArrayInputStream(yourData), flavor, null);
                try {
                    job.print(doc, null);
                } catch (PrintException e) {
                    //handle exception
                }3. 利用第三方包,比如RXTX                CommPortIdentifier port = CommPortIdentifier.getPortIdentifier(outputDest);
                    ParallelPort parallelPort = (ParallelPort) port.open("some owner", 50);
                    OutputStream outputStream = parallelPort.getOutputStream();
                    outputStream.write(uccLabelData);
                    outputStream.flush();