日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2023/12/4 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Web使用热敏打印小票(IE环境) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

概述

在html頁下使用Epson P60II 熱敏紙下打印小票,使用的打印方案為調用window.print()。

代碼實現

1、定義窗體,設置寬度和高度

<body onload="window.external.Print(0,0);" style="margin-top:0px;" ><form id="form1" runat="server" ><div align="center" valign="top" id ="PrintDoc" ><table style="width:4.8cm; height:9.9cm; border-width:1px; border-color:Red; border-style:dashed" ><tr align="center" valign="top"><td><asp:Label id="Label_proname" runat="server" ></asp:Label></td></tr></table></div></form> </body>

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、設置隱藏模式打印

<style media="print">.Noprint { DISPLAY: none }</style>

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);}}

完整代碼

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Print.aspx.cs" Inherits="Print" enableEventValidation="false" validateRequest="false" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title>好牛網移動優惠卷</title><style media="print">.Noprint { DISPLAY: none }</style> <script type='text/javascript'> 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(); } </script> <script language="javascript">function PrintCutrefresh() {print_onclick();}setTimeout('PrintCutrefresh()',7000); //指定7秒后切紙 </script> </head> <body onload="window.external.Print(0,0);" style="margin-top:0px;" ><form id="form1" runat="server" ><div align="center" valign="top" id ="PrintDoc" ><table style="width:4.8cm; height:9.9cm; border-width:1px; border-color:Red; border-style:dashed" ><tr align="center" valign="top"><td><asp:Label id="Label_proname" runat="server" ></asp:Label></td></tr></table></div></form> </body> </html>

總結

以上是生活随笔為你收集整理的Web使用热敏打印小票(IE环境)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。