Skip to content

Commit 840dda7

Browse files
committed
Fix issue with column cell height calculation.
1 parent 5a6f4c3 commit 840dda7

File tree

1 file changed

+10
-1
lines changed
  • pdftable/src/main/java/com/leshchenko/pdftable

1 file changed

+10
-1
lines changed

pdftable/src/main/java/com/leshchenko/pdftable/Column.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,16 @@ class Column(
3232

3333
fun setColumnHeight(height: Float) {
3434
this.height = height
35-
cells.forEach { it.cellHeight = height / cells.size }
35+
var availableHeight = height / cells.size
36+
cells.forEachIndexed { index, cell ->
37+
val estimatedHeight = cell.getEstimatedHeight()
38+
if (estimatedHeight > availableHeight) {
39+
cell.cellHeight = estimatedHeight
40+
availableHeight = (height - estimatedHeight) / (cells.size - (index + 1))
41+
} else {
42+
cell.cellHeight = availableHeight
43+
}
44+
}
3645
}
3746

3847
fun isDrawn() = cells.all { it.isDrawn }

0 commit comments

Comments
 (0)