公司之前有个用js写的专门用于打印银行存折的程序。document.write("<object ID='WebBrowser' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object> ");
document.write("<OBJECT id='MSComm1' CLASSID='clsid:648A5600-2C6E-101B-82B6-000000000014' codebase='MSCOMM32.OCX' type='application/x-oleobject' style='LEFT: 54px; TOP: 14px' style='display:none' > ");
document.write("<PARAM NAME='_ExtentX' VALUE='1005'> ");
document.write("<PARAM NAME='_ExtentY' VALUE='1005'> ");
document.write("<PARAM NAME='_Version' VALUE='393216'> ");
document.write("<PARAM NAME='CommPort' VALUE='1'> ");
document.write("<PARAM NAME='DTREnable' VALUE='-1'> ");
document.write("<PARAM NAME='Handshaking' VALUE='0'> ");
document.write("<PARAM NAME='InBufferSize' VALUE='1024'> ");
document.write("<PARAM NAME='InputLen' VALUE='0'> ");
document.write("<PARAM NAME='NullDiscard' VALUE='0'> ");
document.write("<PARAM NAME='OutBufferSize' VALUE='512'> ");
document.write("<PARAM NAME='ParityReplace' VALUE='63'> ");
document.write("<PARAM NAME='RThreshold' VALUE='1'> ");
document.write("<PARAM NAME='RTSEnable' VALUE='0'> ");
document.write("<PARAM NAME='BaudRate' VALUE='9600'> ");
document.write("<PARAM NAME='ParitySetting' VALUE='0'> ");
document.write("<PARAM NAME='DataBits' VALUE='7'> ");
document.write("<PARAM NAME='StopBits' VALUE='0'> ");
document.write("<PARAM NAME='SThreshold' VALUE='0'> ");
document.write("<PARAM NAME='EOFEnable' VALUE='0'> ");
document.write("<PARAM NAME='Settings' VALUE='9600,N,8,1'> ");
document.write("<PARAM NAME='InputMode' VALUE='0'></OBJECT> ");var fileName = ""; //记录文件名
var sendfile_flag = "0"; //控制上传文件是否上传
//打印 参数为需要打印的字符串
function print4(printstr){
/*由于Olivetti仿真对打印机的状态要求比较严格,所以直接发数据是不会打印的,需要加入如下指令:全部用16进制表示 1b 6c 即代表 0x16 0x6c1b 6c 清除错误状态
1b 6e 选择Olivetti对话进程
1b 51 n1 n2 n3 设置页长
1b 4c n1 n2 n3 绝对垂直定位附件是olivetti仿真的说明和测试文件, 注意$代表打印机的分隔符,没有什么特殊含义,比如ESC$ )其实就是指esc )测试文件发送后可以直接给olivetti仿真的pr3打印,可以在pc上用sscom等串口发送工具发送
*/
try{
alert("请放入打印纸!!!"); var cmdESC = ""
var cmd0 = "\033%C"; //open port C
var cmd99 = "\033&A"; // open port A
var cmd00 = "\033l";
var cmd01 = "\033n";
var cmd02 = "\033Q254\033Z";
var cmd03 = "\033L000";
var cmd11 = "\033O"; MSComm1.CommPort = 1;
try{
MSComm1.PortOpen = true;
}catch(x){}
MSComm1.Output = cmd0;
MSComm1.Output = cmd99;
MSComm1.Output = cmd00;
MSComm1.Output = cmd01;
MSComm1.Output = cmd02;
MSComm1.Output = cmd03;
var max_len = 500;
var i ;
var p;
var max;
for (i = 0;i<printstr.length;i+=max_len )
{
if ( i + max_len >= printstr.length )
{
max = printstr.length;
p = printstr.substring(i,max-2);
}
else
{
max = i + max_len;
p = printstr.substring(i,max);
} MSComm1.Output = p;
}
MSComm1.Output = cmd11;
}catch(e){
alert(e.message);
try{MSComm1.PortOpen = false;}catch(ee){}
}finally{
//MSComm1.Output = cmd99;
MSComm1.Output = cmd0;
MSComm1.PortOpen = false;//关闭端口
}
}
打印机为HCC PR-2E系列的,Olivetti授权。这些我在前台只要调用方法print(content)就可以实现打印。问题:
现在我的打印机换成ESPON LQ-1600KIII,就是24针的那种,打印纸是两边带孔而且是连续进纸。想请高人帮忙像上述程序一样用JS实现这种打印机的连打。
document.write("<OBJECT id='MSComm1' CLASSID='clsid:648A5600-2C6E-101B-82B6-000000000014' codebase='MSCOMM32.OCX' type='application/x-oleobject' style='LEFT: 54px; TOP: 14px' style='display:none' > ");
document.write("<PARAM NAME='_ExtentX' VALUE='1005'> ");
document.write("<PARAM NAME='_ExtentY' VALUE='1005'> ");
document.write("<PARAM NAME='_Version' VALUE='393216'> ");
document.write("<PARAM NAME='CommPort' VALUE='1'> ");
document.write("<PARAM NAME='DTREnable' VALUE='-1'> ");
document.write("<PARAM NAME='Handshaking' VALUE='0'> ");
document.write("<PARAM NAME='InBufferSize' VALUE='1024'> ");
document.write("<PARAM NAME='InputLen' VALUE='0'> ");
document.write("<PARAM NAME='NullDiscard' VALUE='0'> ");
document.write("<PARAM NAME='OutBufferSize' VALUE='512'> ");
document.write("<PARAM NAME='ParityReplace' VALUE='63'> ");
document.write("<PARAM NAME='RThreshold' VALUE='1'> ");
document.write("<PARAM NAME='RTSEnable' VALUE='0'> ");
document.write("<PARAM NAME='BaudRate' VALUE='9600'> ");
document.write("<PARAM NAME='ParitySetting' VALUE='0'> ");
document.write("<PARAM NAME='DataBits' VALUE='7'> ");
document.write("<PARAM NAME='StopBits' VALUE='0'> ");
document.write("<PARAM NAME='SThreshold' VALUE='0'> ");
document.write("<PARAM NAME='EOFEnable' VALUE='0'> ");
document.write("<PARAM NAME='Settings' VALUE='9600,N,8,1'> ");
document.write("<PARAM NAME='InputMode' VALUE='0'></OBJECT> ");var fileName = ""; //记录文件名
var sendfile_flag = "0"; //控制上传文件是否上传
//打印 参数为需要打印的字符串
function print4(printstr){
/*由于Olivetti仿真对打印机的状态要求比较严格,所以直接发数据是不会打印的,需要加入如下指令:全部用16进制表示 1b 6c 即代表 0x16 0x6c1b 6c 清除错误状态
1b 6e 选择Olivetti对话进程
1b 51 n1 n2 n3 设置页长
1b 4c n1 n2 n3 绝对垂直定位附件是olivetti仿真的说明和测试文件, 注意$代表打印机的分隔符,没有什么特殊含义,比如ESC$ )其实就是指esc )测试文件发送后可以直接给olivetti仿真的pr3打印,可以在pc上用sscom等串口发送工具发送
*/
try{
alert("请放入打印纸!!!"); var cmdESC = ""
var cmd0 = "\033%C"; //open port C
var cmd99 = "\033&A"; // open port A
var cmd00 = "\033l";
var cmd01 = "\033n";
var cmd02 = "\033Q254\033Z";
var cmd03 = "\033L000";
var cmd11 = "\033O"; MSComm1.CommPort = 1;
try{
MSComm1.PortOpen = true;
}catch(x){}
MSComm1.Output = cmd0;
MSComm1.Output = cmd99;
MSComm1.Output = cmd00;
MSComm1.Output = cmd01;
MSComm1.Output = cmd02;
MSComm1.Output = cmd03;
var max_len = 500;
var i ;
var p;
var max;
for (i = 0;i<printstr.length;i+=max_len )
{
if ( i + max_len >= printstr.length )
{
max = printstr.length;
p = printstr.substring(i,max-2);
}
else
{
max = i + max_len;
p = printstr.substring(i,max);
} MSComm1.Output = p;
}
MSComm1.Output = cmd11;
}catch(e){
alert(e.message);
try{MSComm1.PortOpen = false;}catch(ee){}
}finally{
//MSComm1.Output = cmd99;
MSComm1.Output = cmd0;
MSComm1.PortOpen = false;//关闭端口
}
}
打印机为HCC PR-2E系列的,Olivetti授权。这些我在前台只要调用方法print(content)就可以实现打印。问题:
现在我的打印机换成ESPON LQ-1600KIII,就是24针的那种,打印纸是两边带孔而且是连续进纸。想请高人帮忙像上述程序一样用JS实现这种打印机的连打。
还是谢谢,结贴的时候会给你加分的