Add Page Break Condition on the Advanced PDF/HTML Template for Checks

<#assign counter = 0> <!--  how many rows are already displayed on the table -->
<div style="position: relative;font-family: Helvetica,sans-serif;height: 250pt;width: 612pt; page-break-before: avoid;font-size: 8pt;">
<table class="itemtable" style="position:absolute;overflow: hidden;top: 10pt ; font-size: 8pt; width: 580">
      <#list check.apply as apply>
        <#if apply?index == 22> <!-- checks for until what row number do you want to display on the first page. Note that the first row starts at index 0 -->
        	<#assign counter = 22>  <!-- 22 was assigned to indicate that there are already 22 rows printed on the 1st page -->
		<#break> <!-- The break tag is responsible for stopping the list to display the remaining rows -->
         <#else>
            <tr valign="top">
              <td style="padding-right: 10px">${apply.refnum}</td>
              <td style="padding-right: 10px">${apply.total}</td>
              <td style="padding-right: 30px">${apply.disc}</td>
            </tr>
         </#if>
      </#list>
</table>
</div>

<#if counter = 22> <!-- This condition means that it will only display the 2nd page once the 1st page has displayed 22 rows -->
<div style="position: relative;font-family: Helvetica,sans-serif;height: 250pt;width: 612pt;page-break-before: always;font-size: 9pt;"> <!-- The page-break-before style is responsible for the page break -->
  <table class="itemtable" style="position:absolute;overflow: hidden;top: 200pt ; font-size: 8pt; width: 580">
      <#list check.apply as apply>
        <#if apply?index > 21> <!-- This if condition checks on which row number do you want start to display on the second page. The index needs to be lower than the one on the first if condition -->
            <tr valign="top">
              <td style="padding-right: 10px">${apply.refnum}</td>
              <td style="padding-right: 10px">${apply.total}</td>
              <td style="padding-right: 30px">${apply.disc}</td>
            </tr>
          </#if>
      </#list>
  </table>
</div>
</#if>

Leave a comment

Your email address will not be published. Required fields are marked *