Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table property NOT to split across pages #234

Closed
Sgkhour opened this issue Sep 25, 2020 · 7 comments
Closed

Table property NOT to split across pages #234

Sgkhour opened this issue Sep 25, 2020 · 7 comments
Labels

Comments

@Sgkhour
Copy link
Contributor

Sgkhour commented Sep 25, 2020

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

@philprime
Copy link
Member

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?

@Sgkhour
Copy link
Contributor Author

Sgkhour commented Oct 13, 2020

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

@philprime
Copy link
Member

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

@Sgkhour
Copy link
Contributor Author

Sgkhour commented Apr 23, 2021

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

@philprime
Copy link
Member

Can this be solved with PR #281 ?

@gauravs-at
Copy link

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.

@philprime
Copy link
Member

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants