通用LODOP,记录下

/**打印*/
            onPrint:function(){
                var LODOP =_methods.getLodop();
                if(LODOP){
                  LODOP.PRINT_INIT("常州市困难群众临时生活救助申请审批表");
                  LODOP.SET_PRINT_PAGESIZE(1,0,0,"A4");
                  LODOP.SET_PRINT_STYLEA(1,"Horient",2);
                }
                $.post(_ctx + "/print/printpage" + _suffix,null,function(html){    
                    LODOP.ADD_PRINT_HTM(15,0,"100%","100%",html);
                    LODOP.SET_PREVIEW_WINDOW(1,1,0,0,0,"打印申请表");
                    LODOP.PREVIEW();                
                },"html")
            },
            getLodop :function() {
                var _lodop = $("object[data-id=lodop]");
                if (_lodop[0])
                    return _lodop[0];
                var isIE = (navigator.userAgent.indexOf('MSIE') >= 0) || (navigator.userAgent.indexOf('Trident') >= 0);
                var is64IE = isIE && (navigator.userAgent.indexOf('x64') >= 0);
                _lodop = $("<object></object>").attr("data-id","lodop");
                _lodop.width(20).height(0).attr("style", "position:absolute;left:0px;top:-100px;width:0px;height:0px;");
                if (isIE){
                    _lodop.attr("classid", "clsid:2105C259-1E0C-4534-8141-A753534CB4CA");
                }else{
                    _lodop.attr("type", "application/x-print-lodop");
                }
                _lodop.prependTo("body");
                var LODOP = _lodop[0];
                var exe = is64IE ? "install_lodop64.exe" : "install_lodop32.exe";
                var href = _ctx + "/js/lib/lodop/6.1.9.0/" + exe;
                var alertstr = "<font color='#FF00FF'>点击这里<a href='" + href + "' target='_self'>执行安装</a>,安装后请刷新页面或重新进入。</font>";
                if ((LODOP == null) || (typeof (LODOP.VERSION) == "undefined")) {
                    $.messager.alert('提醒', "打印组件未安装<br/>" + alertstr, 'warning');
                    return;
                } else if (LODOP.VERSION < "6.1.9.0") {
                    $.messager.alert('提醒', "打印控件需要升级<br/>" + alertstr, 'info');
                }
                return LODOP;
            }


你可能感兴趣的:(通用LODOP,记录下)