0

I am trying to print my records arranging it using basic HTML table. I manage to arrange everything accordingly. I have also run a loop to insert some empty lines to fill the gap if the records are less. This will push the footer to the bottom of the page. The problem is when I click Print. It always gives me 2 sheets with sheet 2 being completely empty. I have tried to reduce the number of records and make sure it is only one page. But after hitting Print, it still shows 2 pages with page 2 being empty. Anyway to remove page 2, Please help

<html>
<body>
<center>
<%
    call pageHeader()

    dTotNet_Amt = 0

    do while not rstERSLS1.eof

        record = record + 1

        dNet_Amt = rstERSLS1("NET_AMT")

        dTotNet_Amt = dTotNet_Amt + dNet_Amt

        response.write "<tr>"
            response.write "<td align=left width=50><font face='Arial' size=2>" & record & "</td>"
            response.write "<td align=left width=600 ><font face='Arial' size=2>" & rstERSLS1("PART") & "</td>"
            response.write "<td align=left width=100 ><font face='Arial' size=2>" & rstERSLS1("SERIALNO") & "</td>"
            response.write "<td align=right width=100 ><font face='Arial' size=2>" & pFormatDec(dNet_Amt,2) & "</td>"
        response.write "</tr>"

        rstERSLS1.movenext      
       '=== recordPerPage = 30     
       if record >= recordPerPage and not rstERSLS1.eof then
            record = 0
            sPage = sPage + 1

            response.write"</table>"
            response.write "<br/>"
            response.write "<font face='Arial' size=1>"
            response.Write"Continue Next Page..."    
            response.Write"<p style='page-break-before: always'></p>" 

            call pageHeader()

        elseif rstERSLS1.eof then
            '==== Fill the empty space and drag the footer to the bottom
            do until record >= recordPerPage 
                record = record + 1
                    response.write "<td colspan=4 >&nbsp;&nbsp;</td>"
                response.write "</tr>"
            loop

        end if

    Loop
    pCloseTables(rstERSLS1) 

    %>

'==== Footer
<table width="850">
    <tr>
        <td colspan=3 align=left width=700><font face="Arial" size=2>RINGGIT MALAYSIA : <%= ConvertCurrencyToEnglish(pFormatDec(dTotNet_Amt,2))%></td>
    </tr>
    <tr>
        <td colspan="5">
            <hr color=black style="margin-top:0px;margin-bottom:0px" size=1>
        </td>
    </tr>
</table>
<table width="850">
    <tr>
        <td colspan="3" align=left width=600><font face="Arial" size=2></font>E & OE</td>
        <td align=left width=100><font face="Arial" size=2><b>Total (RM) : </b></font></td>
        <td align=right width=100><font face="Arial" size=2><b>RM <%=pFormatDec(dTotNet_Amt,2)%></b></></font></td>

    </tr>
    <tr>
        <td colspan="3" align=left width=600></td>
        <td colspan="2">
            <hr color=black style="margin-top:0px;margin-bottom:0px" size=2>
        </td>   
    </tr>
    <tr>
        <td colspan="3"width=600></td>
        <td colspan=2 align=left width=100><font face="Arial" size=1>Lorry Number : </font></td>
    </tr>
    <tr>
        <td align=left width=250>______________________________</td>
        <td align=left width=50></td>
        <td align=left width=250>______________________________</td>
        <td colspan=2 align=left width=100><font face="Arial" size=1>Driver Signature : </font></td>
    </tr>
    <tr>
        <td align=left width=250><font face="Arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;AUTHORISED SIGNATURE(S)</font></td>
        <td align=left width=50></td>
        <td align=left width=250><font face="Arial" size=2>&nbsp;&nbsp;&nbsp;&nbsp;RECIPIENT'S CHOP & SIGNATURE</font></td>
        <td colspan="2" align="left" width=100><font face="Arial" size=1>Store Keeper: </font></td>
    </tr>
</table>
<p style='page-break-after: always'></p> '=== This doesn't work
</center>
</body>
</html>

Always empty one extra page

Always Page 2

Hanz Cheah
  • 761
  • 5
  • 15
  • 44
  • Are you sure it's not the `page-break-after: always` that is causing the extra page? – johna Nov 14 '18 at 21:24
  • its I deleted the 'page-break-after: always' it is still the same. Where was the link that someone just posted earlier? – Hanz Cheah Nov 15 '18 at 04:53
  • this one? [how to avoid extra blank page at end while printing?](https://stackoverflow.com/questions/7846346/how-to-avoid-extra-blank-page-at-end-while-printing) – Flakes Nov 15 '18 at 05:10
  • I have follow this https://stackoverflow.com/questions/1763639/how-to-deal-with-page-breaks-when-printing-a-large-html-table?noredirect=1&lq=1 But still when the records is only 1 page, it will always give me an empty 2nd page but if the records is more than 1 page, everything is fine meaning I don't get an extra empty page? – Hanz Cheah Nov 15 '18 at 06:25

1 Answers1

0

Manage to fix it with following

<style type="text/css">

    html, body {
      margin: 0 !important; 
      padding: 0 !important;

    }
</style>
Hanz Cheah
  • 761
  • 5
  • 15
  • 44