Changing line height based on condition

I have an issue where I have a table with 3 rows and 1 column. On the third row I have a field that is getting data until the page break. The problem I have is that the data is sometimes overflowing and looks like this.

So I checked on the datamapper settings to have the page break on 66 lines which would be the length of the page. But then the issue i have is that I have a condition to only print the pages that have “RUN” on the top left. So this extra data was just being cut off and lost.

I came up with a potential solution but I was wondering if there is a better approach because my solution changes the line height of the bottom cell based on the amount of
tags in the field using this script I set up:

var result;
var string;
result = '<p style="line-height: 100%;">';
string = result + record.fields['Field3'];

// Function to count occurrences of a substring in a string
function countOccurrences(string, subString) {
    return string.split(subString).length - 1;

// Get the content of Field3
var field3Content = record.fields['Field3'];

// Count the occurrences of <br />
var brCount = countOccurrences(field3Content, "<br />");

//If <br /> counts are greater than or equal to 54, apply line height reducing html string
if (brCount >= 54) {
    string = result + record.fields['Field3'] 
else {
    string = record.fields['Field3']; 
//Load results

This inputs the html formatting text in front of the field to change the line height based on the count of br tags as stated above, but then I don’t know if the amount of data has a max limit because it could still overflow after applying this script if it were long enough. I could put another condition to decrease the line height even further after even more br tags, but it would be ideal to just be able to set it so it automatically adjusts to fit in the page. I looked into copyfitting, but it only works for div containers or boxes and it also just changes the font size, which in my case messes up the formatting.

If anyone has an idea better than mine please let me know.

We have this template in an older pp7 file and this is the talk code we used to handle this:

rmoveto(stringwidth(’ ‘),0)
rmoveto(neg(stringwidth(’ ')),0)
if(not(gt(pos(‘YEAR’,@(&z_,1,2000)),0)) and not(gt(pos(‘ISSUES’,@(&z_,1,2000)),0)))

Couple of questions springs to mind while looking at this.

  • Does your input data look like the current output you’ve shown us? Because what you are displaying really doesn look like some data from a mainframe that used to print on old line printers.
    • If so wouldn’t it be better to extract each column into its own field and then let eh overlfow be done by Connect? Remember, PP7 and Connect, although having similar GUI, don’t work the same.

Know this, overflow inside a same field cannot wqork in Connect. It can only overflow on row, not inside a row.

Yea, the field is just taking everything in the document and putting it onto the page. The white space setting is set to pre I believe.

You would be better off having a detail table with 1 field which would be the entire row.
Then the overflow of Connect would take care of the rest.

I have this formatting for the template, would I be able to do that while keeping this format? This way the rows are changing based on the fields content.

You mean that the field gets center aligned when conditon for field1 and 3 are met and right aligned when conditon for field 2 is met?