读书人

使用eb打印控件smsx.cab如何判断是否有

发布时间: 2012-10-16 09:57:37 作者: rapoo

使用eb打印控件smsx.cab怎么判断是否有默认打印机
使用eb打印控件smsx.cab怎么判断是否有默认打印机

如果没有安装或者设置默认打印机,给个提示让用户安装打印机或者设置默认打印机

这个如何实现?

另:打印预览的时候不能取消页面页脚,但是调出打印窗口后返回再打印预览又可以取消页面页脚了,不知道是哪里出问题了,请大家帮忙看看。谢谢。

JScript code
<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(0, 0);      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 = "";//显示按钮}</SCRIPT><OBJECT id="factory" codeBase="include/smsx.cab#Version=6,3,434,26" height="0" width="0" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext></OBJECT><div id="button"><table height="15" cellSpacing="1" cellPadding="4" width="100%" border="0">    <tr>      <td align="center">        <input type="button" class="button" value="立即打印" onClick="printTure()">        <input id="idPrint2" type="button" class="button" value="页面设置" onClick="factory.printing.PageSetup()">        <input id="idPrint3" type="button" class="button" value="打印预览" onclick="document.all('button').style.display = 'none';factory.printing.Preview();document.all('button').style.display = '';" />        <input type="button" class="button" value="关闭页面" onclick="window.Close();" /></td>    </tr></table></div>



[解决办法]
判断是否有打印机,好象scriptX高级功能里面有,一直都用免费的,没试过。

打印预览的时候不能取消页面页脚
这个不单要在程序中控制,还要在IE浏览器中设置一下。就是点一下浏览器上面的打印机右边的箭头,选择页面设置,在弹出窗口中你就可以设置页眉页脚了,把它们都设为空即可。

读书人网 >ASP

热点推荐