网站设计的思路,中国十大网络销售公司,一站式网站建设哪家专业,金华公司做网站概述在html页下使用Epson P60II 热敏纸下打印小票#xff0c;使用的打印方案为调用window.print()。代码实现1、定义窗体#xff0c;设置宽度和高度body onloadwindow.external.Print(0,0); stylemargin-top:0px; form idform1使用的打印方案为调用window.print()。代码实现1、定义窗体设置宽度和高度body onloadwindow.external.Print(0,0); stylemargin-top:0px; form idform1 runatserver div aligncenter valigntop id PrintDoc table stylewidth:4.8cm; height:9.9cm; border-width:1px; border-color:Red; border-style:dashed tr aligncenter valigntoptdasp:Label idLabel_proname runatserver /asp:Label/td/tr/table/div/form
/body2、使用ActiveXObject创建 Scripting.FileSystemObjectfunction print_onclick() {var objfs new ActiveXObject(Scripting.FileSystemObject);var objprinterobjfs.CreateTextFile(LPT1:,true);objprinter.Write(String.fromCharCode(0x1B) );objprinter.Write(String.fromCharCode(0x1B) String.fromCharCode(0x69));objprinter.Close();
}3、设置隐藏模式打印style mediaprint.Noprint { DISPLAY: none }/style4、填充数据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);}}完整代码% Page LanguageC# AutoEventWireuptrue CodeFilePrint.aspx.cs InheritsPrint enableEventValidationfalse validateRequestfalse %!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdhtml xmlnshttp://www.w3.org/1999/xhtml head runatservertitle好牛网移动优惠卷/titlestyle mediaprint.Noprint { DISPLAY: none }/style
script typetext/javascript function print_onclick() {var objfs new ActiveXObject(Scripting.FileSystemObject);var objprinterobjfs.CreateTextFile(LPT1:,true);objprinter.Write(String.fromCharCode(0x1B) );objprinter.Write(String.fromCharCode(0x1B) String.fromCharCode(0x69));objprinter.Close();
}
/script
script languagejavascriptfunction PrintCutrefresh()
{print_onclick();}setTimeout(PrintCutrefresh(),7000); //指定7秒后切纸
/script
/head
body onloadwindow.external.Print(0,0); stylemargin-top:0px; form idform1 runatserver div aligncenter valigntop id PrintDoc table stylewidth:4.8cm; height:9.9cm; border-width:1px; border-color:Red; border-style:dashed tr aligncenter valigntoptdasp:Label idLabel_proname runatserver /asp:Label/td/tr/table/div/form
/body
/html