Lodop打印控件中眉脚项关联各自表格,添加新眉脚项,注意关联序号
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
一个任务中有多个表格,根据每个表格设置自己的页眉页脚,这种时候可以使用眉脚项关联表格。 <script language="javascript" src="LodopFuncs.js"></script> </head> <body> <div id="div1"> <table border=1 cellSpacing=0 cellPadding=1 width="100%" style="border-collapse:collapse;background-color:#ffcccc;text-align:center;"> <tr> <td colspan="2">表格的内容</td> </tr> <tr> <td>单元格1</td> <td>单元格2</td> </tr> <tr> <td>单元格3</td> <td>单元格4</td> </tr> <tr> <td>单元格5</td> <td>单元格6</td> </tr> <tr> <td>单元格7</td> <td>单元格8</td> </tr> </table> </div> <div id="div2"> <table border=1 cellSpacing=0 cellPadding=1 width="100%" style="border-collapse:collapse;background-color:#ccffff;text-align:center;"> <tr> <td colspan="2">表格的内容</td> </tr> <tr> <td>单元格1</td> <td>单元格2</td> </tr> <tr> <td>单元格3</td> <td>单元格4</td> </tr> <tr> <td>单元格5</td> <td>单元格6</td> </tr> <tr> <td>单元格7</td> <td>单元格8</td> </tr> </table> </div> <p><a href="javascript:prn1_preview()">自动分页,两个表格带各自的页眉页脚</a></p> <p><a href="javascript:prn2_preview()">自动分页,添加一个各自的条码眉脚打印项</a></p> <script language="javascript" type="text/javascript"> var LODOP; //声明为全局变量 function prn1_preview() {//根据超文本打印项高度47自动分页 LODOP=getLodop(); LODOP.PRINT_INIT(""); LODOP.ADD_PRINT_TABLE(57,9,300,69,document.getElementById("div1").innerHTML); LODOP.ADD_PRINT_TEXT(16,62,197,20,"表格1的页头"); LODOP.SET_PRINT_STYLEA(0,"FontColor","#008000"); LODOP.SET_PRINT_STYLEA(0,"ItemType",1); LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1); LODOP.NewPageA(); LODOP.ADD_PRINT_TABLE(57,9,300,69,document.getElementById("div2").innerHTML); LODOP.ADD_PRINT_TEXT(16,62,197,20,"表格2的页头"); LODOP.SET_PRINT_STYLEA(0,"FontColor","#0000A0"); LODOP.SET_PRINT_STYLEA(0,"ItemType",1); LODOP.SET_PRINT_STYLEA(0,"LinkedItem",3); LODOP.PRINT_DESIGN(); }; function prn2_preview() {//没有根据打印项高度47自动分页 LODOP=getLodop(); LODOP.PRINT_INIT(""); LODOP.ADD_PRINT_TABLE(57,9,300,69,document.getElementById("div1").innerHTML); LODOP.ADD_PRINT_TEXT(16,62,197,20,"表格1的页头"); LODOP.SET_PRINT_STYLEA(0,"ItemType",1); LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1); LODOP.ADD_PRINT_BARCODE(14,273,110,35,"Code39","123456789");//增加新的页眉页脚项 LODOP.SET_PRINT_STYLEA(0,"ItemType",1); LODOP.SET_PRINT_STYLEA(0,"LinkedItem",1); LODOP.NewPageA(); LODOP.ADD_PRINT_TABLE(57,9,300,69,document.getElementById("div2").innerHTML); LODOP.ADD_PRINT_TEXT(16,62,197,20,"表格2的页头"); LODOP.SET_PRINT_STYLEA(0,"ItemType",1); LODOP.SET_PRINT_STYLEA(0,"LinkedItem",4); //每个表格新加打印项后,后面表格关联的序号增加了 LODOP.ADD_PRINT_BARCODE(14,273,110,35,"Code39","987654321");//增加新的页眉页脚项 LODOP.SET_PRINT_STYLEA(0,"ItemType",1); LODOP.SET_PRINT_STYLEA(0,"LinkedItem",4); //每个表格新加打印项后,后面表格关联的序号增加了 LODOP.PRINT_DESIGN(); }; </script> </body> 图示: 该文章在 2023/9/27 23:41:10 编辑过 |
关键字查询
相关文章
正在查询... |