How to determine if a Migradoc table will be split into two pages?

I use Migradoc to create some PDF files. I have code to create a table of text for each element in an array, and I print pages with these tables.

However, the requirements that are given to me are that if I have 2 tables and the second table will not fit on the page due to the length of the first table, I need a second table to start the next page. Then I need to repeat this for each table that I am adding to my document.

How can I do it?

+4
source share
1 answer

If all the tables are small enough to fit on one page, then there is a simple solution: set the KeepWith property of the first row to count minus one to save the entire table on one page.

If tables are not always suitable for one page: you can try to hack, for example. setting KeepWith to 6 or 8 or 10 (depends on the height of the rows in the table). If the value is close to what is suitable for one page (without transition), the tables will start on a new page automatically.
Obviously, this will be very good if the rows of the table are of constant height; if the rows of the rows have different heights, this will not work reliably, but it will still prevent tables that will have only one or two rows on the first page (is this not your requirement, but maybe this requirement can be discussed?).

A clean (but complicated) way to fulfill your requirements: access the GetRenderInfoFromPage internal method. You will need to start the incremental process:
1) give the document;
2) if you find a partition table, insert a page break before this table and repeat from 1.
See also here:
http://forum.pdfsharp.net/viewtopic.php?p=1960#p1960

+5
source

Source: https://habr.com/ru/post/1439900/


All Articles