Page Break after each table in body

时间:2015-04-26 09:41:53

标签: javascript c# jquery html asp.net

I have 2 tables in my body in html. When I press print button, I want to print each table in different page with "page break" in asp.net c#. I want it to work in chrome.
There is any solution using

我的html代码:

<table align="center">
    <tr>
        <td colspan = 2 style="font-weight:bold;font-size:16px;padding:3px;text-align: center;">
          <br/> 
          SCHEDULE TWO - LIFE BENEFITS
          policy No.
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td></td>
    </tr>
    <tr>
        <td style="font-weight:bold;font-size:16px;padding:3px; text-align:center;">
          signed on behalf of : 
          <br/>
          <asp:Label ID="lblCompanyName" runat="server" Font-Size="Large"></asp:Label>
       </td>
       <td style="font-weight:bold;font-size:16px;padding:3px;text-align:center;">
          signed on behalf of : 
          Company 
        </td>
     </tr>
</table>
</div>
<table align="center">
    <tr>
        <td style="padding:3px;font-size:16px;font-weight:bold;" class="style2"></td>
        <td style="font-weight:bold;font-size:16px;padding:3px;text-align:center;" class="style1">
          <br/> 
          <br/> 
          <br/>                       
          <br /> Policy No: &nbsp;<asp:Label ID="Label1" runat="server" Font-Size="Large"></asp:Label>                      
        </td>
        <td style="font-weight:bold;font-size:16px;padding:3px; text-align:right;"></td>
    </tr>
    <tr>
        <td style="padding:3px;font-size:16px;font-weight:bold;">
          FIRST PARTY:
        </td>
        <td> &nbsp;</td>
        <td></td>
    </tr>
    <tr>
        <td colspan = 3 style="text-align:center;font-size:16px;font-weight:bold; height:59px;">
          <br/> 
          <br/> 
          Company
        </td>
    </tr>
    <tr>
        <td colspan = 3 style="text-align: center;padding:3px;font-size:16px;font-weight:bold;">                
          Hereinafter referred to as the First Party or Company (Insurer).
        </td>
    </tr>
    <tr>
        <td style="padding:3px;font-size:16px;font-weight:bold;" class="style2">
          SECOND PARTY:</td>
        <td>&nbsp;</td>
        <td></td>
    </tr>
    <tr>
        <td colspan = 3>
          <asp:Label ID="Label2" runat="server" Font-Size="Large"></asp:Label>
          <br/>
        </td>
    </tr>
    <tr>
        <td>
          Hereinafter 
          <br/> 
          <br/> 
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td style="font-weight:bold; text-align: center;"></td>
    </tr>
</table>

打印的JavaScript:

<script type="text/javascript">
    function print() {
        var printFriendly = document.getElementById("print");
        var printWin = window.open("about:blank", "Voucher", "menubar=no;status=no;toolbar=no;");
        printWin.document.write("<html><head><title>Report</title><style type='text/css' media='print'> @page {size: auto;margin:0 20px 0 20px; } 
       body{background-color:#FFFFFF;background-image:none; margin:0 20px 0 
       20px; }</style><style type='text/css'>body{background-
       image:none;background:#fff;margin:0 20px 0 20px; }</style></head>
         <body>" + printFriendly.innerHTML + "</body></html>");  
        printWin.document.close();
        printWin.print();
        printWin.close();
    }

0 个答案:

没有答案