您当前的位置: 首页 > 

寒冰屋

暂无认证

  • 0浏览

    0关注

    2286博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Web使用热敏打印小票(IE环境)

寒冰屋 发布时间:2021-09-23 15:16:55 ,浏览量:0

概述

在html页下使用Epson P60II 热敏纸下打印小票,使用的打印方案为调用window.print()。

代码实现

1、定义窗体,设置宽度和高度

2、使用ActiveXObject,创建   Scripting.FileSystemObject​​​​​​​

function print_onclick() {
  var objfs = new ActiveXObject("Scripting.FileSystemObject");
  var objprinter=objfs.CreateTextFile("LPT1:",true);
  objprinter.Write(String.fromCharCode(0x1B) + "@");
  objprinter.Write(String.fromCharCode(0x1B) + String.fromCharCode(0x69));
  objprinter.Close();
}

3、设置隐藏模式打印

 .Noprint { DISPLAY: none }

4、填充数据​​​​​​​

 private void ListBind()
    {
        try
        {
            string strVoucherID = Request.QueryString["voucherid"];
            if (strVoucherID != null && strVoucherID != string.Empty)
            {
                this.Label_proname.Text = this.DataBase.GetShopVoucherDetail(strVoucherID);
                this.DataBase.VoucherPrintUpdate(strVoucherID, this.DataBase.Areaid);
            }

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }

    }
完整代码​​​​​​​






    

    好牛网移动优惠卷
    .Noprint { DISPLAY: none }
 

function print_onclick() {
  var objfs = new ActiveXObject("Scripting.FileSystemObject");
  var objprinter=objfs.CreateTextFile("LPT1:",true);
  objprinter.Write(String.fromCharCode(0x1B) + "@");
  objprinter.Write(String.fromCharCode(0x1B) + String.fromCharCode(0x69));
  objprinter.Close();
}
  

             function PrintCutrefresh()
{
                print_onclick();
                  
             }
             setTimeout('PrintCutrefresh()',7000); //指定7秒后切纸



    
  
    

关注
打赏
1665926880
查看更多评论
立即登录/注册

微信扫码登录

0.0926s