Skip to content

Commit 8850edc

Browse files
committed
Improve table auto layout in case empty cells with fixed table width
DEVSIX-1195 Autoported commit. Original commit hash: [010d71ac1]
1 parent d7c5230 commit 8850edc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

itext/itext.layout/itext/layout/renderer/TableWidths.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ internal float[] AutoLayout() {
442442
else {
443443
float totalFixed = 0;
444444
float totalFlexible = 0;
445+
float flexibleCount = 0;
445446
for (int i = 0; i < numberOfColumns; i++) {
446447
if (widths[i].isFixed) {
447448
widths[i].finalWidth = widths[i].width;
@@ -450,13 +451,15 @@ internal float[] AutoLayout() {
450451
else {
451452
if (!widths[i].isPercent) {
452453
totalFlexible += widths[i].width;
454+
flexibleCount++;
453455
}
454456
}
455457
}
458+
System.Diagnostics.Debug.Assert(totalFlexible > 0 || flexibleCount > 0);
456459
extraWidth = tableWidth - totalPercent - totalFixed;
457460
for (int i = 0; i < numberOfColumns; i++) {
458461
if (!widths[i].isPercent && !widths[i].isFixed) {
459-
widths[i].finalWidth = widths[i].width * extraWidth / totalFlexible;
462+
widths[i].finalWidth = totalFlexible > 0 ? widths[i].width * extraWidth / totalFlexible : extraWidth / flexibleCount;
460463
}
461464
}
462465
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
36b7b2ab1debbcf4abb399de672d2ee2c03eea4d
1+
010d71ac111f8f411aa0a603cc5b8ecd5970ae79

0 commit comments

Comments
 (0)