1

I'm trying to modify an exist XML template for use with NetSuite's BFO PDF report generator implementation. The basic structure is a table with two rows and two columns, wherein the first row does a column merge. In the second row, one column is populated with data, the other with images. The images are small, and display fits within the first page. However, the data column has a varying amount of information provided, and some of the information provided it HTML formatted (for example an unordered list). The problem is that sometimes there is a lot of data and it runs off of the page without a page break. In some cases I'm able to restructure the data or perform some magic tricks to either reduce the size or break off a chunk add force a second page. In cases like an unordered list, though, I can't do anything with it.

I've tried forcing TBODY tags around TR tags, tried forcing the page-break-inside attribute. Nothing seems to work. For example, this is what I get with a long list:

enter image description here

You can see how the contents overlap the page footer. And this is what I have for the table row in question:

<tbody page-break-inside="auto">
    <tr style="border-top:4px solid; padding-bottom:10px;" page-break-inside="auto">

The content is also encapsulated within a DIV tag:

<div id="itemDetails" style="min-width: 0px; max-width:545px;">

With this particular example, there are two content fields on the sourced record containing unordered lists in HTML format, and neither have any kind of styling applied. Here's the smaller source chunk (which happens to be cut off the bottom of the displayed page):

<ul>
  <li>All the Advantages of Altivar 31 Drive</li>
  <li>Excellent Resistance to Harsh Environments (50° C)</li>
  <li>Coated Cards as Standard (IEC 60721-3-3 Classes 3c2 and 3s2)</li>
  <li>Excellent Resistance to Power Supply and Motor Interference</li>
  <li>0.25 HP to 20 HP</li>
  <li>Single-Phase 200 V to 240 V, Three-Phase 200 V to 240 V, Three-Phase 380 V to 500 V, Three-Phase 525 V to 600 V</li>
  <li>Integrated Class 2 Emc Filter for Radiated and Conducted Emissions</li>
  <li>Din Rail Mounting</li>
</ul>

Any suggestions on what may help to get this data to page break? I feel like there's an obvious solution I'm not thinking of.

Michael McCauley
  • 853
  • 1
  • 12
  • 37
  • Hard to know without seeing the rest of your xml, but one thing I wondered is: have you set the height of your footer? – Krypton Apr 23 '17 at 13:19
  • Yes, that has been set. In fact, I had to add a footer macro to the design as in the original version all that the creator did was to make it a DIV with a large margin on the top. – Michael McCauley Apr 24 '17 at 15:40
  • Michael, were you able to figure this out? I also run into this problem occasionally and have thus far been unable to come up with a good solution. – Jacob Shetler May 07 '18 at 19:57
  • I think the problem lies in nested elements. If what you need to page break won't, it's probably inside and element that should. For example, a table in a table. The inner table is what you're wanting to break, but it doesn't because it's inside another table. That seems to be what's happening, but I wasn't able to confirm. – Michael McCauley May 08 '18 at 21:22

2 Answers2

0

After trying for the past week to get the same issue resolved, I decided to do page breaks when listing information if the information in the list is longer than what will fit on a single page. OP's comment pointed me in this direction - you need to use/omit nested elements to pull it off.

I'm using a div with page-break-inside: avoid; if the length of the data I'm going to display is less than what fits on a single page. Otherwise I omit the div and just use the table - this allows the table rows to break onto multiple pages.

For the following example, my main data object is searchResults. It contains a property of valueArr, which is the array of hashes I need to display in the printout. I have styleObj.maxCoilsPerPage set to 30 for one type of this printout; you'll need to change this to the number of lines that can fit on a single page in your case.

CSS snippet:

.nopagebreak {
    page-break-inside: avoid;
}

HTML snippet:

<#list searchResults.valueArr as item>
    <#if (item.valueArr?size lte styleObj.maxCoilsPerPage?number)>
        <div class="nopagebreak">
    </#if>
        <table>
            <tr>
                <td width="70%">${item.itemName}</td>
                ...other table data...
        </table>
    <#if (item.valueArr?size lte styleObj.maxCoilsPerPage?number)>
        </div>
    </#if>
</#list>
Jacob Shetler
  • 151
  • 3
  • 6
0

I know this is an old post but I found an easy way to split long text fields in <td> and avoid the dreaded overlap into the footer or the page break from the table header, and I hope it helps future answer seekers!

Below is the code snippet from Netsuite's Help Center which uses the "?split" freemarker built-in. It splits a long string into a sequence (which is why you need to list).

I didn't have an item table so just used the below instead and it worked perfectly. Just make sure you start your list before the row where your long data will start.

<#list record.customfield?split("<br />") as paragraph>
 <tr>
  <td>${paragraph}</td>
 </tr>
</#list>

https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/bridgehead_4418819945.html#Adding-Page-Breaks-to-Tables

<!-- start of item table in transaction  -->
<#list record.item as item>
  <#if item_index==0>
    <!-- Header Definition -->
    <tr>
      <th>${item.field1@label}</th>
      <th>${item.long_text_field@label}</th>
      <th>${item.field2@label}</th>
      <!-- ... -->
    </tr>
  </#if>
  <#list item.long_text_field?split( "<br />") as paragraph>
    <#if paragraph_index==0>
      <tr>
        <td>${‌item.field1}</td>
        <td>${paragraph}</td>
        <td>${‌item.field2}</td>
        <!-- ... -->
      </tr>
      <#else>
        <tr>
          <td></td>
          <td>${paragraph}</td>
          <td></td>
          <!-- ... -->
        </tr>
    </#if>
  </#list>
</#list>
<!-- end of item table in transaction  -->
Emma
  • 1
  • 1