打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
ScriptX打印控件的使用

介绍ScriptX控件

对于B/S架构的项目中,Web打印最是让程序员头痛的技术,在这次项目中运用了第三方控件ScriptX解决了此技术包括各种汇总表,详细清单等等,但最大弊端就是打印的格式是死的,你要打印出怎样的格式必须自己来做,还有就是打印分页,它是按你设置的纸张大小来分的,所以必须人为控制,ScriptX控件所需文件ScriptX.cab。(ScriptX下载地址http://www.meadroid.com/scriptx/freedep.asp
打印功能使用:
⑴ 用户在客户端单击“打印”按钮,第一次使用打印会弹出如下对话框
⑵ 单击“是”按钮,此时会把控件ScriptX下载到本机
⑶ 在打印窗口中有大标题、打印条件、打印列表,单击“打印”按钮进入打印浏览界面。
⑷ 单击“Print”按钮,听打印机声音响起。
二、    一个简单的ScriptX控件使用实例

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT>

                
    
var    hkey_root,hkey_path,hkey_key   
        hkey_root
="HKEY_CURRENT_USER"   
        hkey_path
="\\Software\\Microsoft\\Internet   Explorer\\PageSetup\\"   
  
//设置网页打印的页眉页脚为空   
  function   pagesetup_null()   
  
{   
      
try
{   
          
var   RegWsh   =   new   ActiveXObject("WScript.Shell")   
          hkey_key
="header"           
          RegWsh.RegWrite(hkey_root
+hkey_path+hkey_key,"")   
          hkey_key
="footer"   
          RegWsh.RegWrite(hkey_root
+hkey_path+hkey_key,"")   
      }
catch(e)
{}   
  }
   

//用于设置打印参数
function printBase() 
{
factory.printing.header  
= ""   //页眉
factory.printing.footer = ""   //页脚
factory.printing.portrait = true   //true为纵向打印,false为横向打印
factory.printing.leftMargin   =   0.5  
factory.printing.topMargin   
=   1.5   
factory.printing.rightMargin   
=   0.5  
factory.printing.bottomMargin   
=   1.5   
}


//用于调用设置打印参数的方法和显示预览界面
function printReport()
{
        printBase();
        pagesetup_null();
        document.all(
"button").style.display = "none";//隐藏按钮
        factory.printing.Preview();
}


//使界面最大化
maxWin();
function maxWin()
{
      
var aw = screen.availWidth;
      
var ah = screen.availHeight;
      window.moveTo(
00);
      window.resizeTo(aw, ah);
}


function printTure()
{
     printBase();
     document.all(
"button").style.display = "none";//隐藏按钮
      //factory.printing.Preview();
     factory.printing.Print(false);
     document.all(
"button").style.display = "block";//显示按钮
}


</SCRIPT>
</HEAD>
<BODY>
    
<OBJECT id="factory" codeBase="ScriptX.cab#Version=6,3,434,26"
            height
="0" width="0" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext>
        
</OBJECT>

    
<div id="button" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; WIDTH: 98%; PADDING-TOP: 0px">
                            
<table height="15" cellSpacing="1" cellPadding="4" width="100%" bgColor="#ddf3ff" border="0">
                                
<tr>
                                    
<td align="center" bgColor="#ddf3ff">
                                        
<input class="bginput" onclick="printTure()" type="button" value="打印">
                                         
<input   id="idPrint2"   type="button"   value="页面设置" onclick="factory.printing.PageSetup()">   
                                         
<input   id="idPrint3"   type="button"   value="打印预览"   
                                         onclick
="factory.printing.Preview()">   
                                    
</td>
                                
</tr>
                            
</table>
                        
</div>
</BODY>
</HTML>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
javascript打印两例
WEB打印的几种方案
WEB打印设置解决方案二(利用ScriptX.cab控件改变IE打印设置)
javascript小技巧
IE选项对应的注册表
C# OCX控件之部署
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服