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 header repeats in new page. #327

Open
vivek350 opened this issue Apr 11, 2023 · 0 comments
Open

Table header repeats in new page. #327

vivek350 opened this issue Apr 11, 2023 · 0 comments

Comments

@vivek350
Copy link

vivek350 commented Apr 11, 2023

I am building a pdf with dynamic data. I have multiple tables. The problem I'm having is when the document has only space for one row, which is the header, the header repeats twice in first page and second page again. This happens because I used testTable.showHeadersOnEveryPage = true.

I want the headers repeating in every page. All I want is to find a way to check if the first 2 rows of the table fit in the remaining space of the page, if not I can move the table to the next page.

What did you do?

testArray.insert(["Eaglewoods buzzy accurate eardrop", "Number of absent bleachers", "Accurate Source"], at: 0)
let testTable = PDFTable(rows: testArray.count, columns: 3)
testTable.padding = 10
testTable.widths = [0.3, 0.2, 0.5]
let lineStyle = PDFLineStyle(type: .full, color: UIColor.black, width: 1)
let borders = PDFTableCellBorders(left: lineStyle, top: lineStyle, right: lineStyle, bottom: lineStyle)
let font = UIFont.systemFont(ofSize: 10)
testTable.style = PDFTableStyle(columnHeaderCount: 1, footerCount: testArray.count - 1, outline: PDFLineStyle(type: .full, color: UIColor.black, width: 1), columnHeaderStyle: PDFTableCellStyle(borders: borders, font: UIFont.boldSystemFont(ofSize: 12)), footerStyle: PDFTableCellStyle(borders: borders, font: font))
testTable.content = testArray
testTable.rows.allRowsAlignment = [.center, .center, .center]
testTable.showHeadersOnEveryPage = true

What did you expect to happen?

ℹ I have a table beginning almost at the end of the page. I have no way of knowing the position since it would always be dynamic. The problem occurs only when there's space for header in the page. The header repeats in the new page. If I can calculate the space left in the page, I can move the table to next page.

What happened instead?

Image 4-11-23 at 11 26 AM

TPPDF Environment

TPPDF version: ℹ 2.4.1
Xcode version: ℹ 14.1
Swift version: ℹ 5

Demo Code / Project

I cannot provide the whole document since it's not my personal project. If the data provided is not enough I can create a sample app and provide the link here. Thanks

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

No branches or pull requests

1 participant