现在我有一个页面,我想在js中实现循环打印出这个页面,最少打印两次,求问怎么能实现 JavaScriptlodop

解决方案 »

  1.   

    这是我写的代码,带分页的,这个gridview或者表格外边必须套一个div然后按照注释给参数就行,给力吧!var LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));function prn1_preview(Title, Lists, div2, biaoti,PageNumber) {//Lists 是gridview,Title是查询条件表的id,div2是gridvi外边套的div,biaot是报表的标题
        LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
        var PrintActionCode = "";
        var tableStyleCode = "<style>table{border-collapse:collapse;border:solid 1px blue;}";
        tableStyleCode += "table tr td{border:solid 1px blue;white-space:nowrap;word-break:normal;}";
        tableStyleCode += "table tr th{border:solid 1px blue;white-space:nowrap;word-break:normal;} </style>";    LODOP.ADD_PRINT_TABLE(40, 210, 700, 1100, tableStyleCode + "<table width='100%'  style=\"white-space:nowrap;word-break:normal; font-size='15';height:13%;\">" + $("#" + Title + "").children().html() + "</table>");
        var j = 1;
        LODOP.ADD_PRINT_TEXT(11, "40%", 417, 67, ""+biaoti+"");
    //    LODOP.ADD_PRINT_TEXT(100, 500, 417, 67, "第" + j + "页")
        LODOP.SET_PRINT_STYLEA(0, "FontSize", 20);
        PrintActionCode += "LODOP.ADD_PRINT_TABLE(\"95%\", \"90%\", 100, 100, \"<table><tr><td>第" + j + "页</td></tr></table>\");";
        PrintActionCode += "LODOP.ADD_PRINT_TABLE(\"25%\", 40, 1050, 1200, \"" + tableStyleCode + "\"+\"<table width='100%'>\" +$(\"#" + Lists + " tr:eq(0)\").html() + pageAction(\"" + div2 + "\",0,20) + \"</table>\");";
        for (var i =  20 ; i < $("#" + Lists + " tr").length; i +=  25) {
            PrintActionCode += "LODOP.NEWPAGE();";
            j++;
            PrintActionCode += "LODOP.ADD_PRINT_TABLE(\"95%\", \"90%\", 100, 100, \"<table><tr><td >第" + j + "页</td></tr></table>\");";
            PrintActionCode += "LODOP.ADD_PRINT_TABLE(\"10%\", 40, 1050, 1200, \"" + tableStyleCode + "\"+\"<table width='100%'>\" + $(\"#" + Lists + " tr:eq(0)\").html()+ pageAction(\"" + div2 + "\"," + i + "," + (i + 25 ) + ") + \"</table>\");";
            
        }    PrintActionCode += "LODOP.PREVIEW();";
        eval(PrintActionCode);
        
    };function pageAction(div2, begin, end) {//封装的方法,js分页用,div2是gridview外边div的id
        LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
        var html = "";    $("#" + div2 + " tr:lt(" + end + "):gt(" + begin + ")").each(function(i) {        html += "<tr>" + $(this).html() + "</tr>";    });    return html;
    }