TPPDF icon indicating copy to clipboard operation
TPPDF copied to clipboard

Table property NOT to split across pages

Open Sgkhour opened this issue 4 years ago • 6 comments

similar to issue #72 , i would see value in a flag attached to a table that if the table doesn't fit on the page, to put it in a new page (with an error if it doesn't fit on a full page). i am putting together a document that has multiple tables and their placeholder on the page isn't fixed (table#1 is dynamic in size... 2 rows or 30) so it pushes the others. i just don't want to break table 2 or 3 across pages

Sami

Sgkhour avatar Sep 25 '20 21:09 Sgkhour

Hi, I believe this is a duplicate of #205, or at least it is in the same content. Please correct me if I am wrong

About the page breaking, have you tried adding a Page Break after the first table?

philprime avatar Oct 12 '20 18:10 philprime

i think #205 and #202 are related and i think they have something to do with the calculation of the offset at the top of the page etc... #234 is more about a table property that prevents a table from splitting across pages and is similar to #72. for now, and based on trial and error, i know how many rows in table 1 will let table 2 fit on the same page, i test for that or else force a document.createNewPage() . the challenge is table 1 could span anywhere from a dozen rows to over 50 (less than a page to possibly 3-4 pages) so i have 1 test for page 1 and a different test for page 2..n . ideally, in pseudocode

document.add(table: table1)
document.add(space: 36.0)
if spaceLeftOnPage < table2.height {
  document.createNewPage()
}
document.add(table: table2)

i hope that helps

Sgkhour avatar Oct 13 '20 00:10 Sgkhour

Hi, is this issue still relevant for the latest version on master or develop branches?

philprime avatar Apr 09 '21 07:04 philprime

Hi (and sorry for the time it took me to get back to you). i think the shouldSplitCellsOnPageBreak for tables is ok . where i am still having an issue is with this function

    func add(_ container: PDFGroupContainer = PDFGroupContainer.left, imagesInRow: [PDFImage], spacing: CGFloat = 5.0) {
        objects += [(container, PDFImageRowObject(images: imagesInRow, spacing: spacing))]
    }

when calling for example

document.add(imagesInRow: tempCharts, spacing: 10)

i don't know of a way to make sure if the PDFImage doesn't fit (height wise) then createNewPage. i believe #234 can be closed

Sgkhour avatar Apr 23 '21 00:04 Sgkhour

Can this be solved with PR #281 ?

philprime avatar Dec 07 '21 08:12 philprime

Hi, Is there any way to achieve this, I would like to Put the table on new page if doesn't fit the page, we have multiple tables which we add one by one. Table height is not fixed, so if table doesn't fit in the remaining content move the entire table to new page.

gauravs-at avatar May 26 '22 19:05 gauravs-at

I am closing this issue as #281 has been merged and the issue has been inactive.

@gauravs-at please open up a new issue with a full bug report filled out :)

philprime avatar Dec 03 '22 15:12 philprime