jsp页面实现打印动态页面的分页

<html>
<head>
<title>打印页</title>
<META   NAME= "Generator "   CONTENT= "EditPlus ">
<META   NAME= "Author "   CONTENT= "YC ">
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WB width=0 VIEWASTEXT></OBJECT>
<script language=javascript>   
function doPageSet(){     
WB.ExecWB(8,1)}
function doPreview(){
    WB.ExecWB(7,1)} 
</script>
<style type='text/css'>
@media print {
.Noprint{display:none;}//不想打印出来(如打印按钮)
.PageNext{page-break-after:always;}//分页
</style>
</head>
<body>

<input name="Submit4" type="button" class="Noprint" onClick="javascript:window.print()" value="直接打印">
<input name="Submit4" type="button" class="Noprint" onClick="doPreview()" value="打印预览">
<input name="Submit4" type="button" class="Noprint" onClick="doPageSet()" value="页面设置">
<table>
<logic:iterate id="list" indexId="index" name="Form"
property="list">
<%
if((Integer.parseInt(index.toString()) + 1) == 30 || (Integer.parseInt(index.toString()) + 1 - 30) % 34 == 0) {
%>        
              <tr class = "PageNext">
                <td align="center"><%=Integer.parseInt(index.toString()) + 1%><!--或 ${index+1}--></td> 
                <td >内容1</td>
                <td >内容2</td>
                <td >内容3</td>              
                        </tr>
              <%
              } else {
               %>
             <tr>
                <td align="center"><%=Integer.parseInt(index.toString()) + 1%><!--或 ${index+1}--></td> 
                <td >内容1</td>
                <td >内容2</td>
                <td >内容3</td>             
                       </tr>
              <%
              }
               %>
              </logic:iterate>
<input type="button" class="Noprint" name="print" value="打印" onclick="window.print()">
            <input type="button" class="Noprint" value="关闭" onClick="window.close()"/>
</table>
本段代码实现第一页打印30条数据强制分页,之后每页打印34条,条数根据自己的情况进行调整

你可能感兴趣的:(jsp)