Javascript zebra直接热敏打印机中的条形码打印不正确

Javascript zebra直接热敏打印机中的条形码打印不正确,javascript,printing,zebra-printers,zpl,barcode-printing,Javascript,Printing,Zebra Printers,Zpl,Barcode Printing,我有一个条形码打印的网页,这是我用javascript库创建的。它在普通的A4打印机中可以正常打印,但当我试图在zebra GD420(直接热敏)条形码打印机中打开它的打印空白页时,在zebra用户指南中,他们指示发送zpl命令,如“^XA^FO50,50^B3N,N,100,Y,N^FD123456^FS^XZ”,但没有得到它,如何在我的代码中使用它? 还有人认为我的客户正在远程测试它(在条形码打印机中打印条形码)。 那么这需要什么配置设置呢 请查找附加的屏幕截图我的条形码打印预览 我已经编

我有一个条形码打印的网页,这是我用javascript库创建的。它在普通的A4打印机中可以正常打印,但当我试图在zebra GD420(直接热敏)条形码打印机中打开它的打印空白页时,在zebra用户指南中,他们指示发送zpl命令,如“^XA^FO50,50^B3N,N,100,Y,N^FD123456^FS^XZ”,但没有得到它,如何在我的代码中使用它? 还有人认为我的客户正在远程测试它(在条形码打印机中打印条形码)。 那么这需要什么配置设置呢

请查找附加的屏幕截图我的条形码打印预览

我已经编写了一个用于打印的javascript函数

<script type="text/javascript">
  function printprocess(numid) {


    for(var i=0;i<numid;i++){
      $("#barcodeTarget").html("");
      var productbarcode=document.getElementById("productbarcode"+i).value;
      var productbarcodevariant=document.getElementById("productbarcodevariant"+i).value;
      var productvariantvalue=document.getElementById("productvariantvalue"+i).value;
      var productprice=document.getElementById("productprice"+i).value;
      var productquantity=document.getElementById("productquantity"+i).value;

      var alstuf=productbarcode+"---"+productbarcodevariant+"------"+productvariantvalue+"---"+productprice+"------"+productquantity;

      if(productquantity!="0"){
    var par1=productbarcodevariant;
    var par2=productvariantvalue;
    var par3=productprice;
    var timu= productquantity;
    var value =productbarcode;
    var renderer ="bmp";
    var btype = "code128";
    var quietZone = false;
    var settings = {
      output:renderer,
      bgColor: "#FFFFFF",
      color: "#000000",
      barWidth: "1",
      barHeight: "40",
      moduleSize: "1",
      posX: "1",
      posY: "1",
      addQuietZone: "1"
    };
    $("#barcodeTarget").html("").show().barcode(value, btype, settings);
    for(var x=0;x<productquantity;x++){
      var Mybarcode = document.getElementById('barcodeTarget').innerHTML;
      console.log(Mybarcode);
      var adtext='<div  style="background-color: #FFFFFF;width: 250px;font-size:10px;font-weight:normal;margin: 200px 0px 200px -70px; -webkit-transform: rotate(90deg);-moz-transform: rotate(90deg);-o-transform: rotate(90deg);-ms-transform: rotate(90deg);transform: rotate(90deg);">     '+par1+': '+par2+'<br/>Price : '+par3+' '+Mybarcode+'   </div>';
      $("#barcodelist").append(adtext);
    }
      }
    }
    var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
    disp_setting+="scrollbars=yes,width=200, height=600, left=100, top=25"; 
    var content_vlue = document.getElementById("barcodelist").innerHTML; 
    var docprint=window.open("","",disp_setting); 
    docprint.document.open();
    docprint.document.write('<!DOCTYPE HTML><html xmlns="http://www.w3.org/1999/xhtml">');
    docprint.document.write('<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css"> @media (max-width: 4in) {    @page {      size: A4;    }  }</style></head>');
    docprint.document.write('<body onLoad="self.print()">');
    docprint.document.write(content_vlue);          
    docprint.document.write('</html>'); 
    docprint.document.close(); 
    docprint.focus(); 
    docprint.print(); 
    $("#barcodeTarget").hide()
    return false;
  }

</script>

函数printprocess(numid){

对于(var i=0;i您必须使用zebra编程语言在条形码打印机上发送数据,如@douglas所述,您必须生成类似^XA^FO50,50^B3N,N,100,Y,N^FD123456^FS^XZ的zpl字符串

要转换指令,请选中此项,查看是否在zpl中写入代码。使用zebra编程语言创建条形码打印机类的对象。如

BarCodeField barcode = new BarCodeField("barcode",
                                         10, // X Position in dots 
                                         10, // Y Position in dots 
                                         Printer.ALIGN_BOTTOM_LEFT, // Alignment
                                         Printer.DIR_LEFT_TO_RIGHT,// Direction
                                         BarCodeField.TYPE_EAN_13,// barcode type
                                         56, //barcode height
                                         1, // wideRatio
                                         3, // narrowRatio
                                         1,//Magnification
                                        "3442648507010"); // barcode expression

您需要使用ZPL样式的编码创建一个字符串,然后直接在打印机上打印。看起来您正在向设备发送html。@DouglasAnderson如何将上述代码转换为ZPL样式的编码?只需创建一个大字符串,看起来像:^XA^FO50,50^B3N,N,100,Y,N^FD123456^FS^XZ,然后直接将其传递到打印机>