2005-1-2 12:43
黄新
票据打印http://bbs.ywsy.net/archiver/?tid-47631.html
票据打印
主要由三部分构成:页面内容及布置,设置页面(页面css的控制和打印参数的保存),打印
一、页面内容及布置
用div控制把需要打印的内容用相对位置固定下来,可用扫描仪把需要打印的票据扫描进去然后确定需要打印内容的相对位置.
二、 设置页面(页面css的控制)
这里主要是字体的大小
fontSize_i = font + fonti(i是一个变值,以此来控制各个部分的字体大小)
left_i = top + topi (i是一个变值,以此来控制各个部分的相对左边距)
top_i = left + lefti (i是一个变值,以此来控制各个部分的相对上边距)在这个阶段主要确定fonti,topi,lefti
在最外面可用一个
top (用于保存整体的上边距)
left (用于保存整体的左边距)
font (用于保存页面的基本字体大小) 这三个可保存于cookie或数据库中,如果使用的打印机不一样不推荐使用数据库,不同的打印机和不同的驱动对打印结果影响很大。
三、打印网上非常的打印方法。需要解决的问题:去页眉页脚、上边距和左边距控制、打印输出
网上有非常多的web打印方法,像web打印代码大全一摞一摞的如:FileSystem组件、98系统以上自带的也有别人开发的打印控件等等。
FileSystem组件直接把数据流传到打印机上,可以实现真正的打印边距为零。但是打印的格式不好控制,pass。
如果不使用ActiveX空间的话比较笨的办法就是在regedit里边删除页眉页脚和把上边距左边距设 为零,但是有一点是这需要IE的安全级别比较低。
最后还是用菠萝找的控件控制页眉页脚再用控制打印
[ Last edited by GShadow on 2005-1-3 at 18:00 ]
票据打印
主要由三部分构成:页面内容及布置,设置页面(页面css的控制和打印参数的保存),打印
一、页面内容及布置
用div控制把需要打印的内容用相对位置固定下来,可用扫描仪把需要打印的票据扫描进去然后确定需要打印内容的相对位置.
二、 设置页面(页面css的控制)
这里主要是字体的大小
fontSize_i = font + fonti(i是一个变值,以此来控制各个部分的字体大小)
left_i = top + topi (i是一个变值,以此来控制各个部分的相对左边距)
top_i = left + lefti (i是一个变值,以此来控制各个部分的相对上边距)在这个阶段主要确定fonti,topi,lefti
在最外面可用一个
top (用于保存整体的上边距)
left (用于保存整体的左边距)
font (用于保存页面的基本字体大小) 这三个可保存于cookie或数据库中,如果使用的打印机不一样不推荐使用数据库,不同的打印机和不同的驱动对打印结果影响很大。
三、打印网上非常的打印方法。需要解决的问题:去页眉页脚、上边距和左边距控制、打印输出
网上有非常多的web打印方法,像web打印代码大全一摞一摞的如:FileSystem组件、98系统以上自带的也有别人开发的打印控件等等。
FileSystem组件直接把数据流传到打印机上,可以实现真正的打印边距为零。但是打印的格式不好控制,pass。
如果不使用ActiveX空间的话比较笨的办法就是在regedit里边删除页眉页脚和把上边距左边距设 为零,但是有一点是这需要IE的安全级别比较低。
最后还是用菠萝找的控件控制页眉页脚再用控制打印
[ Last edited by GShadow on 2005-1-3 at 18:00 ]
2005-1-2 12:50
黄新
票据打印
如果用cookie控制打印三数,可设成自定义的用以下
<link href="../cust_css/hxy_god.css" type="text/css" rel="stylesheet">
<script language="JavaScript">
function bodyKeyDown()
{
//if (event.keyCode==13) event.keyCode=9;
if (event.keyCode==118) {
//F7
event.keyCode=0;
setProp();
return true;
}
if(event.keyCode==120){
//F9
event.keyCode = 0;
window.close();
}
if(event.keyCode==121){
//F10
event.keyCode=0;
window.form1.reset();
return true;
}
}
</script>
<script id="clientEventHandlersJS" language="javascript">
</script>
<script language="javascript">
function isNum(str){//判断是否 为数字
var isnum = true;
for(var i=0;i<str.length;i++){<br> var lls=str.substring(i,i+1);
if(!(lls>='0'&&lls<='9')){
return isnum =false;
break;
}
}
return isnum;
}
function setProp()
{
var left = document.form1.leftDist.value;
if(!isNum(left)||left=='')
{
alert('左边距必须为数字,请从新填写');
form1.leftDist.focus();
form1.leftDist.select();
return;
}
var top = document.form1.topDist.value;
if(!isNum(top)||top=='')
{
alert('上边距必须为数字,请从新填写');
form1.topDist.focus();
form1.topDist.select();
return;
}
var fontSize = document.form1.fontSize.value;
if(!isNum(fontSize)||fontSize=='')
{
alert('上边距必须为数字,请从新填写');
form1.fontSize.focus();
form1.fontSize.select();
return;
}
window.opener.form1.leftDist.value = left;
window.opener.form1.topDist.value = top;
window.opener.form1.fontSize.value= fontSize;
window.returnValue=true;
window.opener.test();
window.close();
}
</script>
如果用cookie控制打印三数,可设成自定义的用以下
<link href="../cust_css/hxy_god.css" type="text/css" rel="stylesheet">
<script language="JavaScript">
function bodyKeyDown()
{
//if (event.keyCode==13) event.keyCode=9;
if (event.keyCode==118) {
//F7
event.keyCode=0;
setProp();
return true;
}
if(event.keyCode==120){
//F9
event.keyCode = 0;
window.close();
}
if(event.keyCode==121){
//F10
event.keyCode=0;
window.form1.reset();
return true;
}
}
</script>
<script id="clientEventHandlersJS" language="javascript">
</script>
<script language="javascript">
function isNum(str){//判断是否 为数字
var isnum = true;
for(var i=0;i<str.length;i++){<br> var lls=str.substring(i,i+1);
if(!(lls>='0'&&lls<='9')){
return isnum =false;
break;
}
}
return isnum;
}
function setProp()
{
var left = document.form1.leftDist.value;
if(!isNum(left)||left=='')
{
alert('左边距必须为数字,请从新填写');
form1.leftDist.focus();
form1.leftDist.select();
return;
}
var top = document.form1.topDist.value;
if(!isNum(top)||top=='')
{
alert('上边距必须为数字,请从新填写');
form1.topDist.focus();
form1.topDist.select();
return;
}
var fontSize = document.form1.fontSize.value;
if(!isNum(fontSize)||fontSize=='')
{
alert('上边距必须为数字,请从新填写');
form1.fontSize.focus();
form1.fontSize.select();
return;
}
window.opener.form1.leftDist.value = left;
window.opener.form1.topDist.value = top;
window.opener.form1.fontSize.value= fontSize;
window.returnValue=true;
window.opener.test();
window.close();
}
</script>
左边距 | |
上边距: | |
字体大小: | |
2005-1-2 12:51
黄新
票据打印-打印页面(修改注册表)
<script language="javascript">
function Format(num,dotLen) {
//将num按小数位为dotLen来进行格式化 如无小数位参数则为2位小数
var dot=0
var num1=0
if (typeof dotLen=="undefined" || dotLen==null )
dot=2
else
dot=dotLen
if (isNaN(parseFloat(num)))
return 0
else
num1=parseFloat(num)
var n1=Math.pow(10,dot)
if (n1==0)
var iValue= Math.round(num1)
else
var iValue= Math.round(num1*n1)/n1
var sValue = iValue.toString();
if (sValue.indexOf(".") == -1)
{
sValue = sValue + ".00";
}
else
{
if (sValue.indexOf(".") == sValue.length - 1)
{
sValue = sValue + "00";
}
else if (sValue.indexOf(".") == sValue.length - 2)
{
sValue = sValue + "0";
}
}
return sValue
}
//修改注册表属性
//修改了 开始打印的位置
//去掉 顶部的空白区
function changeIEPrintINRegedit(){
try{
var margin_top,margin_bottom,margin_left,margin_right,footer,header
var regedit = new ActiveXObject("WScript.Shell");
margin_top=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_top");
margin_bottom=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_bottom");
margin_left=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_left");
margin_right=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_right");
//footer=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\footer");
//header=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\header");
var print_top =0;
var print_bottom=0;
var print_left=0;
var print_right=0;
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_top",print_top);
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_bottom",print_bottom);
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_left",print_left);
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_right",print_right);
//设置网页打印的页眉页脚为空
print_footer = "";
print_header = "";
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\footer",print_footer);
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\header",print_header);
return true;
}
catch(Exception ){
return false;
}
}
</script>
<script language="JavaScript">
//执行打印输出;
function doPrint()
{
aa.style.display='none';
try{
document.all.WebBrowser1.ExecWB(6,1);
}catch(Exception){
alert("打印失败,请重试!!");
}
aa.style.display ='';
form1.btnCloseWin.disabled='';
}
</script>
<script language="Javascript" src="cookie.js"></script>
<script language="Javascript">
//cookieInfo 的格式: left:top:fontSize
function makeCookie(str){
var today = new Date();
var expires = new Date(today.getTime() + Cookie.year);
setCookie('Cust_VehSFprintInfo',str, expires);
}
function test(){
if(!changeIEPrintINRegedit()){
alert("您IE当前的级别太高,请调低IE级别后重试!!");
}
else
getInfo(document.form1);
}
function showCookie(){
var myCookie = getCookie('Cust_VehSFprintInfo');
if(myCookie ==null)
{
alert('请重新设置打印格式');
//从弹出窗口取得打印页面的属性
reSetCookie();
}
else{
makeCookie(myCookie);
splitCookieInfo(myCookie);
}
}
function getInfo(frmObj)//从表单中获取信息并加入cookie中
{
var regeditTop; //如果注册表未被修改则为-1 被修改晚了为0
var left = frmObj.leftDist.value;
var top = frmObj.topDist.value;
var fontSize = frmObj.fontSize.value;
makeCookie(left+':'+top+':'+fontSize);
window.setCookie1.innerHTML =' ';
showCookie();
}
function splitCookieInfo(str)
{
var strArray = str.split(':');
var left_num = parseInt(strArray[0]) ;
var top_num = parseInt(strArray[1]) ;
var fontSize_num = parseInt(strArray[2]) ;
makePrintContent(left_num,top_num,fontSize_num);
//执行打印输出
doPrint();
}
</script>
<script language="javascript">
<%
String sfdy = ConverCode.solveCh(request.getParameter("sfdy")) ;
String sfmx_print = ConverCode.solveCh(request.getParameter("sfmx_print"));
//String sfdy = "|||"+year+"|||"+month+"|||"+day+"|||"+jkdw+"|||"+jkr+"|||"+bz+"|||"+jbr+"|||"+hj+"|||"+rmbdx+"|||";
%>
function check(obj){
if(obj=="null"){
return '';
}
return obj;
}
function makePrintContent(numLeft,numTop,numSize)
{
var str = '<%=sfdy%>';
var sfmx_print = '<%=sfmx_print%>';
var arrayStr = str.split("|||");
var arraysfmx_print = sfmx_print.split("::");
//项目数
var projectAmount = 8;
//初始字体大小为3
var fontSize = numSize;
// if(numSize<10)
// fontSize=12;
//初试left 初试值即默认值为130 ||60
var left = 60;
left = numLeft;
//添加时间及系列号 初是高度50
var top2 = 50;
top2 = numTop;
str='
';
str+='
window.printLayer.innerHTML=str;
}
</script>
<script language="javascript">
function PrintOut()
{
contentStr = '';
showCookie();
}
function bodyKeyDown()
{
//if (event.keyCode==13) event.keyCode=9;
if (event.keyCode==118) {
//F7
event.keyCode=0;
PrintOut();
return true;
}
if (event.keyCode==119) {
//F8
event.keyCode=0;
reSetCookie();
return true;
}
if(event.keyCode==120){
//F9
event.keyCode = 0;
if(form1.btnCloseWin.disabled==true){
alert("请先打印票据再行关闭窗口");
}
else
window.close();
}
if(event.keyCode==121){
//F10
event.keyCode=0;
window.location.reload();
return true;
}
}
</script>
<script language="javascript">
function reSetCookie(){
var iniCookie = getCookie('Cust_VehSFprintInfo');
var leftDist = 60;
var topDist = 50;
var fontSize = 10;
if(iniCookie ==null){
leftDist = 60;
topDist = 50;
fontSize = 10;
}
else {
var strArray = iniCookie.split(':');
leftDist = parseInt(strArray[0]) ;
topDist = parseInt(strArray[1]) ;
fontSize = parseInt(strArray[2]) ;
}
// deleteCookie('Cust_VehSFprintInfo');//删除cookie
var p =
window.open('getPageProp.jsp?leftDist='+leftDist+'&topDist='+topDist+'&fontSize='+fontSize+'',
'','height=220, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
return;
}
</script>
<script language="javascript">
//初始化页面设置
function iniPage(){
var iniCookie = getCookie('Cust_VehSFprintInfo');
if(iniCookie ==null) {
makePrintContent(60,50,10);
}
else {
var strArray = iniCookie.split(':');
var left_num = parseInt(strArray[0]) ;
var top_num = parseInt(strArray[1]) ;
var fontSize_num = parseInt(strArray[2]) ;
makePrintContent(left_num,top_num,fontSize_num);
}
}
</script>
<script language="javascript">
iniPage();
form1.btnCloseWin.disabled="disabled";
</script>
[ Last edited by 黄新 on 2005-1-2 at 12:53 ]
<script language="javascript">
function Format(num,dotLen) {
//将num按小数位为dotLen来进行格式化 如无小数位参数则为2位小数
var dot=0
var num1=0
if (typeof dotLen=="undefined" || dotLen==null )
dot=2
else
dot=dotLen
if (isNaN(parseFloat(num)))
return 0
else
num1=parseFloat(num)
var n1=Math.pow(10,dot)
if (n1==0)
var iValue= Math.round(num1)
else
var iValue= Math.round(num1*n1)/n1
var sValue = iValue.toString();
if (sValue.indexOf(".") == -1)
{
sValue = sValue + ".00";
}
else
{
if (sValue.indexOf(".") == sValue.length - 1)
{
sValue = sValue + "00";
}
else if (sValue.indexOf(".") == sValue.length - 2)
{
sValue = sValue + "0";
}
}
return sValue
}
//修改注册表属性
//修改了 开始打印的位置
//去掉 顶部的空白区
function changeIEPrintINRegedit(){
try{
var margin_top,margin_bottom,margin_left,margin_right,footer,header
var regedit = new ActiveXObject("WScript.Shell");
margin_top=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_top");
margin_bottom=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_bottom");
margin_left=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_left");
margin_right=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_right");
//footer=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\footer");
//header=regedit.RegRead ("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\header");
var print_top =0;
var print_bottom=0;
var print_left=0;
var print_right=0;
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_top",print_top);
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_bottom",print_bottom);
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_left",print_left);
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\margin_right",print_right);
//设置网页打印的页眉页脚为空
print_footer = "";
print_header = "";
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\footer",print_footer);
regedit.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\header",print_header);
return true;
}
catch(Exception ){
return false;
}
}
</script>
<script language="JavaScript">
//执行打印输出;
function doPrint()
{
aa.style.display='none';
try{
document.all.WebBrowser1.ExecWB(6,1);
}catch(Exception){
alert("打印失败,请重试!!");
}
aa.style.display ='';
form1.btnCloseWin.disabled='';
}
</script>
<script language="Javascript" src="cookie.js"></script>
<script language="Javascript">
//cookieInfo 的格式: left:top:fontSize
function makeCookie(str){
var today = new Date();
var expires = new Date(today.getTime() + Cookie.year);
setCookie('Cust_VehSFprintInfo',str, expires);
}
function test(){
if(!changeIEPrintINRegedit()){
alert("您IE当前的级别太高,请调低IE级别后重试!!");
}
else
getInfo(document.form1);
}
function showCookie(){
var myCookie = getCookie('Cust_VehSFprintInfo');
if(myCookie ==null)
{
alert('请重新设置打印格式');
//从弹出窗口取得打印页面的属性
reSetCookie();
}
else{
makeCookie(myCookie);
splitCookieInfo(myCookie);
}
}
function getInfo(frmObj)//从表单中获取信息并加入cookie中
{
var regeditTop; //如果注册表未被修改则为-1 被修改晚了为0
var left = frmObj.leftDist.value;
var top = frmObj.topDist.value;
var fontSize = frmObj.fontSize.value;
makeCookie(left+':'+top+':'+fontSize);
window.setCookie1.innerHTML =' ';
showCookie();
}
function splitCookieInfo(str)
{
var strArray = str.split(':');
var left_num = parseInt(strArray[0]) ;
var top_num = parseInt(strArray[1]) ;
var fontSize_num = parseInt(strArray[2]) ;
makePrintContent(left_num,top_num,fontSize_num);
//执行打印输出
doPrint();
}
</script>
<script language="javascript">
<%
String sfdy = ConverCode.solveCh(request.getParameter("sfdy")) ;
String sfmx_print = ConverCode.solveCh(request.getParameter("sfmx_print"));
//String sfdy = "|||"+year+"|||"+month+"|||"+day+"|||"+jkdw+"|||"+jkr+"|||"+bz+"|||"+jbr+"|||"+hj+"|||"+rmbdx+"|||";
%>
function check(obj){
if(obj=="null"){
return '';
}
return obj;
}
function makePrintContent(numLeft,numTop,numSize)
{
var str = '<%=sfdy%>';
var sfmx_print = '<%=sfmx_print%>';
var arrayStr = str.split("|||");
var arraysfmx_print = sfmx_print.split("::");
//项目数
var projectAmount = 8;
//初始字体大小为3
var fontSize = numSize;
// if(numSize<10)
// fontSize=12;
//初试left 初试值即默认值为130 ||60
var left = 60;
left = numLeft;
//添加时间及系列号 初是高度50
var top2 = 50;
top2 = numTop;
str='
';
str+='
';
var left_I= 0 ;
left_I = left + 115;
str+='
left_I = left + 190;
str+='
left_I = left + 240;
str+='
left_I = left + 390;
str+='
//添加姓名及单位
top2+=35;
left_I = left + 76;
str+='
left_I = left + 397;
str+='
//添加项目 信息栏
TOP = top2+45;
var top = TOP;
var TOP1 = TOP;
var sub_arraysfmx_print;
for(var j=0;j<arraysfmx_print.length;j++)<br> {
sub_arraysfmx_print = arraysfmx_print[j].split("|||");
left_I = left;
str+='
left_I +=72+2;
str+='
left_I +=58+2;
str+='
left_I +=47+2;
str+='
left_I +=47+2;
str+='
left_I +=47+10;
str+='
top = top + 25;
}
//根据 projectAmount来生成输出的项目
//添加合计部分
TOP1 += 8*25-1;
left_I = left +66;
str +='
TOP1 += 25;
left_I = left + 66;
str +='
//添加备注及经办人
left_I = left + 395;
str +='
var i =TOP+124;
left_I = left + 395;
str +='
str+='
';
var left_I= 0 ;
left_I = left + 115;
str+='
'+check(arrayStr[1])+'
';
left_I = left + 190;
str+='
'+check(arrayStr[2])+'
';
left_I = left + 240;
str+='
'+check(arrayStr[3])+'
';
left_I = left + 390;
str+='
'+''+'
';
//添加姓名及单位
top2+=35;
left_I = left + 76;
str+='
'+check(arrayStr[4])+'
';
left_I = left + 397;
str+='
'+check(arrayStr[5])+'
';
//添加项目 信息栏
TOP = top2+45;
var top = TOP;
var TOP1 = TOP;
var sub_arraysfmx_print;
for(var j=0;j<arraysfmx_print.length;j++)<br> {
sub_arraysfmx_print = arraysfmx_print[j].split("|||");
left_I = left;
str+='
'+sub_arraysfmx_print[0]+'
';
left_I +=72+2;
str+='
'+sub_arraysfmx_print[1]+'
';
left_I +=58+2;
str+='
'+sub_arraysfmx_print[2]+'
';
left_I +=47+2;
str+='
'+sub_arraysfmx_print[3]+'
';
left_I +=47+2;
str+='
'+Format(sub_arraysfmx_print[4])+'
';
left_I +=47+10;
str+='
'+Format(sub_arraysfmx_print[5])+'
';
top = top + 25;
}
//根据 projectAmount来生成输出的项目
//添加合计部分
TOP1 += 8*25-1;
left_I = left +66;
str +='
'+check(arrayStr[8])+'
';
TOP1 += 25;
left_I = left + 66;
str +='
'+check(arrayStr[9])+'
';
//添加备注及经办人
left_I = left + 395;
str +='
'+check(arrayStr[6])+'
';
var i =TOP+124;
left_I = left + 395;
str +='
'+check(arrayStr[7])+'
';
str+='
window.printLayer.innerHTML=str;
}
</script>
<script language="javascript">
function PrintOut()
{
contentStr = '';
showCookie();
}
function bodyKeyDown()
{
//if (event.keyCode==13) event.keyCode=9;
if (event.keyCode==118) {
//F7
event.keyCode=0;
PrintOut();
return true;
}
if (event.keyCode==119) {
//F8
event.keyCode=0;
reSetCookie();
return true;
}
if(event.keyCode==120){
//F9
event.keyCode = 0;
if(form1.btnCloseWin.disabled==true){
alert("请先打印票据再行关闭窗口");
}
else
window.close();
}
if(event.keyCode==121){
//F10
event.keyCode=0;
window.location.reload();
return true;
}
}
</script>
<script language="javascript">
function reSetCookie(){
var iniCookie = getCookie('Cust_VehSFprintInfo');
var leftDist = 60;
var topDist = 50;
var fontSize = 10;
if(iniCookie ==null){
leftDist = 60;
topDist = 50;
fontSize = 10;
}
else {
var strArray = iniCookie.split(':');
leftDist = parseInt(strArray[0]) ;
topDist = parseInt(strArray[1]) ;
fontSize = parseInt(strArray[2]) ;
}
// deleteCookie('Cust_VehSFprintInfo');//删除cookie
var p =
window.open('getPageProp.jsp?leftDist='+leftDist+'&topDist='+topDist+'&fontSize='+fontSize+'',
'','height=220, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
return;
}
</script>
<script language="javascript">
//初始化页面设置
function iniPage(){
var iniCookie = getCookie('Cust_VehSFprintInfo');
if(iniCookie ==null) {
makePrintContent(60,50,10);
}
else {
var strArray = iniCookie.split(':');
var left_num = parseInt(strArray[0]) ;
var top_num = parseInt(strArray[1]) ;
var fontSize_num = parseInt(strArray[2]) ;
makePrintContent(left_num,top_num,fontSize_num);
}
}
</script>
<script language="javascript">
iniPage();
form1.btnCloseWin.disabled="disabled";
</script>
[ Last edited by 黄新 on 2005-1-2 at 12:53 ]
2005-1-2 12:56
黄新
票据打印-打印页面(数据库保存参数)
<link href="../cust_css/hxy_god.css" type="text/css" rel="stylesheet">
<script language="javascript">
function Format(num,dotLen) {
//将num按小数位为dotLen来进行格式化 如无小数位参数则为2位小数
var dot=0
var num1=0
if (typeof dotLen=="undefined" || dotLen==null )
dot=2
else
dot=dotLen
if (isNaN(parseFloat(num)))
return 0
else
num1=parseFloat(num)
var n1=Math.pow(10,dot)
if (n1==0)
var iValue= Math.round(num1)
else
var iValue= Math.round(num1*n1)/n1
var sValue = iValue.toString();
if (sValue.indexOf(".") == -1)
{
sValue = sValue + ".00";
}
else
{
if (sValue.indexOf(".") == sValue.length - 1)
{
sValue = sValue + "00";
}
else if (sValue.indexOf(".") == sValue.length - 2)
{
sValue = sValue + "0";
}
}
return sValue
}
</script>
<script defer="">
function SetPrintSettings() {
factory.printing.header = "";
factory.printing.footer = "";
factory.printing.leftMargin = 0.0;
factory.printing.topMargin = 0.0 ;
}
</script>
<script language="JavaScript">
function doPrint()
{
aa.style.display='none';
try{
SetPrintSettings();
document.all.WebBrowser1.ExecWB(6,1);
}catch(Exception){
alert("打印失败,请重试!!");
}
aa.style.display ='';
form1.btnCloseWin.disabled='';
}
</script>
<script language="javascript">
<%
String sfdy = ConverCode.solveCh(request.getParameter("sfdy")) ;
String sfmx_print = ConverCode.solveCh(request.getParameter("sfmx_print"));
//String sfdy = "|||"+year+"|||"+month+"|||"+day+"|||"+jkdw+"|||"+jkr+"|||"+bz+"|||"+jbr+"|||"+hj+"|||"+rmbdx+"|||";
%>
function check(obj){
if(obj=="null"){
return '';
}
return obj;
}
function makePrintContent(numLeft,numTop,numSize)
{
var str = '<%=sfdy%>';
var sfmx_print = '<%=sfmx_print%>';
var arrayStr = str.split("|||");
var arraysfmx_print = sfmx_print.split("::");
//项目数
var projectAmount = 8;
var fontSize = numSize;
var left = 60;
left = numLeft;
var top2 = 50;
top2 = numTop;
str='
';
str+='
window.printLayer.innerHTML=str;
}
</script>
<script language="javascript">
function bodyKeyDown()
{
//if (event.keyCode==13) event.keyCode=9;
if (event.keyCode==118) {
//F7
event.keyCode=0;
doPrint();
return true;
}
if(event.keyCode==120){
//F9
event.keyCode = 0;
if(form1.btnCloseWin.disabled==true){
alert("请先打印票据再行关闭窗口");
}
else
window.close();
}
if(event.keyCode==121){
//F10
event.keyCode=0;
window.location.reload();
return true;
}
}
</script>
<script language="javascript">
function iniPage(){
form1.btnCloseWin.disabled = "disabled";
makePrintContent(<%=left%>,<%=top%>,<%=size%>);// (numLeft,numTop,numSize)
}
iniPage();
</script>
<link href="../cust_css/hxy_god.css" type="text/css" rel="stylesheet">
<script language="javascript">
function Format(num,dotLen) {
//将num按小数位为dotLen来进行格式化 如无小数位参数则为2位小数
var dot=0
var num1=0
if (typeof dotLen=="undefined" || dotLen==null )
dot=2
else
dot=dotLen
if (isNaN(parseFloat(num)))
return 0
else
num1=parseFloat(num)
var n1=Math.pow(10,dot)
if (n1==0)
var iValue= Math.round(num1)
else
var iValue= Math.round(num1*n1)/n1
var sValue = iValue.toString();
if (sValue.indexOf(".") == -1)
{
sValue = sValue + ".00";
}
else
{
if (sValue.indexOf(".") == sValue.length - 1)
{
sValue = sValue + "00";
}
else if (sValue.indexOf(".") == sValue.length - 2)
{
sValue = sValue + "0";
}
}
return sValue
}
</script>
<script defer="">
function SetPrintSettings() {
factory.printing.header = "";
factory.printing.footer = "";
factory.printing.leftMargin = 0.0;
factory.printing.topMargin = 0.0 ;
}
</script>
<script language="JavaScript">
function doPrint()
{
aa.style.display='none';
try{
SetPrintSettings();
document.all.WebBrowser1.ExecWB(6,1);
}catch(Exception){
alert("打印失败,请重试!!");
}
aa.style.display ='';
form1.btnCloseWin.disabled='';
}
</script>
<script language="javascript">
<%
String sfdy = ConverCode.solveCh(request.getParameter("sfdy")) ;
String sfmx_print = ConverCode.solveCh(request.getParameter("sfmx_print"));
//String sfdy = "|||"+year+"|||"+month+"|||"+day+"|||"+jkdw+"|||"+jkr+"|||"+bz+"|||"+jbr+"|||"+hj+"|||"+rmbdx+"|||";
%>
function check(obj){
if(obj=="null"){
return '';
}
return obj;
}
function makePrintContent(numLeft,numTop,numSize)
{
var str = '<%=sfdy%>';
var sfmx_print = '<%=sfmx_print%>';
var arrayStr = str.split("|||");
var arraysfmx_print = sfmx_print.split("::");
//项目数
var projectAmount = 8;
var fontSize = numSize;
var left = 60;
left = numLeft;
var top2 = 50;
top2 = numTop;
str='
';
str+='
';
var left_I= 0 ;
left_I = left + 115;
str+='
left_I = left + 190;
str+='
left_I = left + 240;
str+='
left_I = left + 390;
str+='
top2+=35;
left_I = left + 76;
str+='
left_I = left + 397;
str+='
TOP = top2+45;
var top = TOP;
var TOP1 = TOP;
var sub_arraysfmx_print;
for(var j=0;j<arraysfmx_print.length;j++)<br> {
sub_arraysfmx_print = arraysfmx_print[j].split("|||");
left_I = left;
str+='
left_I +=72+2;
str+='
left_I +=58+2;
str+='
left_I +=47+2;
str+='
left_I +=47+2;
str+='
left_I +=47+10;
str+='
top = top + 25;
}
TOP1 += 8*25-1;
left_I = left +66;
str +='
TOP1 += 25;
left_I = left + 66;
str +='
left_I = left + 395;
str +='
var i =TOP+124;
left_I = left + 395;
str +='
str+='
';
var left_I= 0 ;
left_I = left + 115;
str+='
'+check(arrayStr[1])+'
';
left_I = left + 190;
str+='
'+check(arrayStr[2])+'
';
left_I = left + 240;
str+='
'+check(arrayStr[3])+'
';
left_I = left + 390;
str+='
'+''+'
';
top2+=35;
left_I = left + 76;
str+='
'+check(arrayStr[4])+'
';
left_I = left + 397;
str+='
'+check(arrayStr[5])+'
';
TOP = top2+45;
var top = TOP;
var TOP1 = TOP;
var sub_arraysfmx_print;
for(var j=0;j<arraysfmx_print.length;j++)<br> {
sub_arraysfmx_print = arraysfmx_print[j].split("|||");
left_I = left;
str+='
'+sub_arraysfmx_print[0]+'
';
left_I +=72+2;
str+='
'+sub_arraysfmx_print[1]+'
';
left_I +=58+2;
str+='
'+sub_arraysfmx_print[2]+'
';
left_I +=47+2;
str+='
'+sub_arraysfmx_print[3]+'
';
left_I +=47+2;
str+='
'+Format(sub_arraysfmx_print[4])+'
';
left_I +=47+10;
str+='
'+Format(sub_arraysfmx_print[5])+'
';
top = top + 25;
}
TOP1 += 8*25-1;
left_I = left +66;
str +='
'+check(arrayStr[8])+'
';
TOP1 += 25;
left_I = left + 66;
str +='
'+check(arrayStr[9])+'
';
left_I = left + 395;
str +='
'+check(arrayStr[6])+'
';
var i =TOP+124;
left_I = left + 395;
str +='
'+check(arrayStr[7])+'
';
str+='
window.printLayer.innerHTML=str;
}
</script>
<script language="javascript">
function bodyKeyDown()
{
//if (event.keyCode==13) event.keyCode=9;
if (event.keyCode==118) {
//F7
event.keyCode=0;
doPrint();
return true;
}
if(event.keyCode==120){
//F9
event.keyCode = 0;
if(form1.btnCloseWin.disabled==true){
alert("请先打印票据再行关闭窗口");
}
else
window.close();
}
if(event.keyCode==121){
//F10
event.keyCode=0;
window.location.reload();
return true;
}
}
</script>
<script language="javascript">
function iniPage(){
form1.btnCloseWin.disabled = "disabled";
makePrintContent(<%=left%>,<%=top%>,<%=size%>);// (numLeft,numTop,numSize)
}
iniPage();
</script>