lodop怎么实现循环打印页面?

guofeng3840 2013-08-09 09:22:24
现在我有一个页面,我想在js中实现循环打印出这个页面,最少打印两次,求问怎么能实现
...全文
403 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
零七九三 2015-08-03
  • 打赏
  • 举报
回复
循环执行lodop的打印事件可实现连打
ThanksGodThanksGod 2013-08-09
  • 打赏
  • 举报
回复
这是我写的代码,带分页的,这个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;
}

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧