Hi Team, I’m showing one pdf suitelet but middle p...
# suitescript
n
Hi Team, I’m showing one pdf suitelet but middle page is coming blank and the table is showing on last page instead of second last page!! second last page is blank and whole table is jumping on last page! It should break down some rows on 2nd last page and remaining rows on last page!! code:
Copy code
Header and Footer:

       var xml = '<?xml version=\"1.0\"?>\n<!DOCTYPE pdf PUBLIC \"-//big.faceless.org//report\" \"report-1.1.dtd\">\n';
       xml += '<pdf>';
       xml += "<head>";
       xml += "<macrolist>";
       xml += "<macro id=\"myheader\">";
       xml += "<p align=\"left\" style='top:-35px' >";
       xml += "<b>WASH MEMO</b>";
       xml += "</p>"
       xml += "<p align=\"right\" style='top:-70px'>";
       xml += "Page <pagenumber/> of <totalpages/>";
       xml += "</p>";
       xml += "<p align='center' style='top:-102px;'><b>Order Number:</b>"+or_num+"</p>";
       xml += "<table width='53%' style='top:-95px' >";
       xml += "   <tr>";
       xml += "      <td><b>Sales Order</b>: " + xmll.escape({
           xmlText: so_num
       }) + "</td>";
       xml += "   </tr>";
       xml += "   <tr>";
       xml += "      <td><b>Date</b>: " + xmll.escape({
           xmlText: so_date
       }) + "</td>";
       //xml +="<td>Dry cleaning Serivers Ltd<p style='font-size:10pt;'>t :(+230)14528796<br/>f :(+230)7845266<br/>e :abc@gmail.com<br/>a :abcvdhsgf<br/>v :VTA 14528796<br/>b :cgs12345</p></td>";
       xml += "   </tr>";
       xml += "   <tr>";
       xml += "      <td><b>Client</b>: " + xmll.escape({
           xmlText: cust_name
       }) + "</td>";
       xml += "   </tr>";
       xml += "   <tr>";
       xml += "   </tr>";
       xml += "   <tr>";
       xml += "      <td style='height: 10px;'> </td>";
       xml += "   </tr>";
       xml += "   <tr>";
       xml += "      <td ><b>Remarks</b>: </td>";
       xml += "   </tr>";
       xml += "   <tr>";
       xml += "   </tr>";
       xml += "   <tr>";
       xml += "   </tr>";
       xml += "</table>";
       xml += "</macro>";

       xml += "<macro id=\"myfooter\">";
       xml += "<table  width='100%' style='border-spacing:20px'>";
       xml += "   <tr >";
       xml += "      <td colspan='2' >CARRE:</td>";
       xml += "      <td colspan='4' style='border-bottom:1px solid Silver;border-right:1px solid black;padding-left:5px;'>&nbsp;</td>";
       xml += "      <td colspan='4' style='border-bottom:1px solid Silver;padding-right:5px;'>&nbsp;</td>";
       xml += "      <td colspan='2'>:HANGERS</td>";
       xml += "      <td style='padding-left:5px;'>Delivery Date: _____/_____/________</td>";
       xml += "   </tr>";
       xml += "   <tr >";
       xml += "      <td colspan='2'>CRATE:</td>";
       xml += "      <td colspan='4' style='border-bottom:1px solid Silver;border-right:1px solid black;padding-left:5px;'>&nbsp;</td>";
       xml += "      <td colspan='4' style='border-bottom:1px solid Silver;padding-right:5px;'>&nbsp;</td>";
       xml += "      <td colspan='2'>:TROLLEY BLUE</td>";
       xml += "      <td style='padding:5px;'>Prepared by: ______________________</td>";
       xml += "   </tr>";
       xml += "   <tr >";
       xml += "      <td colspan='2'>PLASTIC:</td>";
       xml += "      <td colspan='4' style='border-bottom:1px solid Silver;border-right:1px solid black;padding-left:5px;'>&nbsp;</td>";
       xml += "      <td colspan='4' style='border-bottom:1px solid Silver;padding-right:5px;'>&nbsp;</td>";
       xml += "      <td colspan='2'>:ROLLS</td>";
       xml += "      <td style='padding-left:5px;'>DS/PS: Approved by: _________________</td>";
       xml += "   </tr>";
       xml += "   <tr >";
       xml += "      <td colspan='2'><b>TOTAL</b>:</td>";
       xml += "      <td colspan='4' style='border-bottom:1px solid Silver;border-right:1px solid black;padding-left:5px;'>&nbsp;</td>";
       xml += "      <td colspan='4' style='border-bottom:1px solid Silver;padding-right:5px;'>&nbsp;</td>";
       xml += "      <td colspan='2'>:OTHERS</td>";
       xml += "   </tr>";

       xml += "</table>";
       xml += "   <p align='center' >";
       xml += "      <b>This is not an official document</b>";
       xml += "   </p>";

       xml += "<p align=\"right\" style='top:-25px;'>";
       //xml += "Page <pagenumber/> of <totalpages/>";
       xml += "</p>";
       xml += "</macro>";
       xml += "</macrolist>";
       xml += "</head>";

       xml += '<body style="font-family: sans-serif" header="myheader" header-height="20%" footer="myfooter" footer-height="10%" padding="0.5in 0.5in 0.5in 0.5in" size="Letter">';
Table code:
Copy code
if(j==prodUnit_ar.length-1){

              xml += '<table page-break-after="avoid" style=" border: 0.3px solid black;margin-top: -50px;font-size: 10pt;  width: 100%;">'

            }
            else{
             xml += '<table page-break-after="always" style=" border: 0.3px solid black;margin-top: -50px;font-size: 10pt;  width: 100%;">'
         }
         
          //xml += '<table page-break-after="always" style=" border: 0.3px solid black;top: -60px;font-size: 10pt;  width: 100%;">'
           xml += '  <thead>'
           xml += '   <tr>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;border-right:0.3px solid;background-color: #E2EAF0; width:50%">TOTAL </td>'
           //xml += '    <td  style="border: 0.3px solid;font-weight:bold;border-right:0;border-bottom:0;background-color: #E2EAF0; width:20%"></td>'
           xml += '    <td   align="center" style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid; width:20%">' + totalQty + '</td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid; width:20%"></td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid; width:20%"></td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid; width:20%"></td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid; width:20%"></td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid; width:20%"></td>'
           // xml+='    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;;border-bottom:1">&nbsp;Remarks</td>'
           xml += '   </tr>'
           xml += '   <tr>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;border-right:0.3px solid;background-color: #E2EAF0;">ITEM       </td>'
          // xml += '    <td  style="border: 0.3px solid;font-weight:bold;border-right:0;border-bottom:1;background-color: #E2EAF0;">SALES DEP.</td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid;">ORDER       </td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid;">DEL.        </td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid;">&nbsp;RET.  </td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid;">&nbsp;QTY + </td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid;">&nbsp;QTY - </td>'
           xml += '    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;border-right:0.3px solid;">&nbsp;PACK - </td>'
           // xml+='    <td  style="border: 0.3px solid;font-weight:bold;background-color: #E2EAF0;;border-bottom:1">&nbsp;Remarks</td>'
           xml += '   </tr>'
           xml += '  </thead>'

           for (var i = 0; i < searchResultCount_pr; i++) {

               xml += '  <tr style ="border: 0.3px solid ; height:80; ">'
               xml += ' <td align="left" style ="border: 0.3px solid ;border-right:0.3px solid;">' + xmll.escape({
                   xmlText: item_ar[i]
               }) + '</td>'
               /*xml += ' <td align="left" style ="border: 0.3px solid ;">' + xmll.escape({
                   xmlText: itemSalesDep[i]
               }) + '</td>'*/
               xml += ' <td align="center" style ="border: 0.3px solid;border-right:0.3px solid;">' + qty_ar[i] + '</td>'
               xml += ' <td align="left" style ="border: 0.3px solid ;border-right:0.3px solid;"></td>'
               xml += ' <td align="left" style ="border: 0.3px solid ;border-right:0.3px solid;"></td>'
               xml += ' <td align="left" style ="border: 0.3px solid ;border-right:0.3px solid;"></td>'
               xml += ' <td align="left" style ="border: 0.3px solid ;border-right:0.3px solid;"></td>'
               xml += ' <td align="left" style ="border: 0.3px solid ;border-right:0.3px solid;"></td>'
               // xml+=' <td align="left" style ="border: 0.3px solid ;"></td>'
               //xml+=' <td align="left" style ="border: 0.3px solid ;">&nbsp;'+open_bal.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")+'</td>'
               xml += '  </tr>'

           }



           xml += '  </table><br/>'
b
you now get to learn why representing xml via code is garbage
i have no idea what your xml is supposed to be, so there really is no debugging this
N/render includes Freemarker as a template system
you dont need to manually mix in your own data like this
n
okay thanks @battk!! actually I resolved it but going forward I’ll use N/render only!! Its really hectic to use xml😅