4D Write PRO tables across pages

Product :4D Write PRO v17

I would like to generate a table programatically.

I have noticed that a table that becomes longer than the page, will not continue onto the next page. It seems like 4D Write PRO tries to put the table on 1 page.

How to:

  1. detect the end of the page
  2. duplicate the table’s headers and start a new table on the next page?

Thanks in advance for any suggestions.

Rudy Mortier.

you need to use 17R2.


in v17, you could try embedded (not page) mode, where there is no concept of page on screen,
and take advantage of the “variable frame” printing feature (not WP PRINT),
but you will see that each column is like a scrollable area or text input,
evaluated from left to right.
in other words, the table is not rendered as a single object,
but rather, as a collection of columns.

as a consequence

if the left column is shorter than the right column,
the right column will be truncated.

if the left column is longer than the right column,
and the distance is longer than the height of page,
printing will enter an infinite loop.

Hello Rudy,

First of all, you have to know that 4D Write Pro handles table pagination since V17R2. That means tables are not truncated anymore in page mode! They are automatically splitted in as many tables as needed without any loss.

There are also new possibilities to add columns and page breaks to split a table in two or more parts.

In both cases, the table will keep it’s unique ID.

But i understand in your case that’s not enough if you want insert a header on each page, so you need to detect the page breaks when they occur, right ?

As long as there is no way (yet) to manage rows (insert / delete / etc.) the most simple way to that is to make a copy of your document before you insert a row. Once this is done, insert your row and check the page number. If it has changed, rollback, add a header and go on…

We know this is a bit ugly, but consider this is a temporary situation and just a work around until dedicated commands comes out to manage rows (and cells…) in tables.

Note that if you want to use the same principe for paragraphs, it’s much more simple.
No need to memorise the full document! Just memorise the range before insertion, insert the text, check the page number. If it has changed, go back to the memorised range, insert (force) a page break, then go to the end of your document (after the last text has just been inserted) and go on !

Hope this helps.


Hi Roland,

Thanks for the suggestions. I already tried a similar trick, but different.

I have built a template with a table in it, and the table contains 2 rows and 5 columns.
The first row contains the headers for the columns in the table, and the 2nd row contains the expressions, which are fields names. Depending of the amount of records in the current selection, this table can possibly flow over to the next page.

So I use this command to add rows in the table:

$oNewRow:=WP Table append row(…

after the first one, I check every time before appending a row to the table:

	$wpRange:=WP Create range($oNewRow;wk end text;wk end text)
	$rangePosition:=WP Get position($wpRange)
	If ($rangePosition.page>$pagecount)
             -> append table header row
            End if

So I insert a copy of the table header row to the table as soon as the page number changes.

There is only 1 minor problem: If the content of the last added row is too big, so the table row is doubled in height automatically, then it will put the table header on the previous page. This is because the table header is half the height of the last appended row, and this will still fit on the previous page.

So I try to make sure that the row content will not exceed the cell limits.



Forgot to mention that this was done in v17R2