@@ -28,8 +28,8 @@ public void threeRowSpanTest() {
28
28
float heightRow2 = table .getRows ().get (1 ).getMaxHeights ();
29
29
float heightRow3 = table .getRows ().get (2 ).getMaxHeights ();
30
30
document .close ();
31
- Assertions .assertEquals (0 , heightRow1 - heightRow2 );
32
- Assertions .assertEquals (0 , heightRow3 - heightRow2 );
31
+ Assertions .assertEquals (heightRow1 , heightRow2 , 0.01 );
32
+ Assertions .assertEquals (heightRow3 , heightRow2 , 0.01 );
33
33
}
34
34
35
35
@ Test
@@ -52,8 +52,40 @@ public void threeWithOneUnevenTest() {
52
52
float heightRow2 = table .getRows ().get (1 ).getMaxHeights ();
53
53
float heightRow3 = table .getRows ().get (2 ).getMaxHeights ();
54
54
document .close ();
55
- Assertions .assertEquals (0 , heightRow2 - heightRow3 );
56
- Assertions .assertNotEquals (0 , heightRow1 - heightRow2 );
55
+ Assertions .assertEquals (heightRow2 , heightRow3 , 0.01 );
56
+ Assertions .assertNotEquals (heightRow1 , heightRow2 , 0.01 );
57
+ }
58
+
59
+ @ Test
60
+ public void threeWithLargeRowspanCellHugeTableTest () {
61
+ Document document = new Document (PageSize .A4 );
62
+ ByteArrayOutputStream pdfOut = new ByteArrayOutputStream ();
63
+ PdfWriter .getInstance (document , pdfOut );
64
+ PdfPTable table = new PdfPTable (2 );
65
+
66
+ int rows = 9_000 ;
67
+
68
+ for (int i = 0 ; i < rows ; i += 3 ) {
69
+ PdfPCell cell = new PdfPCell ();
70
+ cell .setRowspan (3 );
71
+ cell .addElement (new Chunk ("rowspan1\n rowspan2\n rowspan3\n rowspan4\n rowspan5\n rowspan6\n rowspan7" ));
72
+ table .addCell (cell );
73
+
74
+ table .addCell ("row1" );
75
+ table .addCell ("row2" );
76
+ table .addCell ("row3" );
77
+ }
78
+
79
+ document .open ();
80
+ document .add (table );
81
+ for (int i = 0 ; i < rows ; i += 3 ) {
82
+ float heightRow1 = table .getRows ().get (i ).getMaxHeights ();
83
+ float heightRow2 = table .getRows ().get (i + 1 ).getMaxHeights ();
84
+ float heightRow3 = table .getRows ().get (i + 2 ).getMaxHeights ();
85
+ Assertions .assertEquals (heightRow2 , heightRow3 , 0.01 );
86
+ Assertions .assertEquals (heightRow1 , heightRow2 , 0.01 );
87
+ }
88
+ document .close ();
57
89
}
58
90
59
91
@ Test
@@ -76,8 +108,9 @@ public void threeWithLargeRowspanCellTest() {
76
108
float heightRow2 = table .getRows ().get (1 ).getMaxHeights ();
77
109
float heightRow3 = table .getRows ().get (2 ).getMaxHeights ();
78
110
document .close ();
79
- Assertions .assertEquals (0 , heightRow2 - heightRow3 );
80
- Assertions .assertEquals (0 , heightRow1 - heightRow2 );
111
+ Assertions .assertEquals (heightRow2 , heightRow3 , 0.01 );
112
+ Assertions .assertEquals (heightRow1 , heightRow2 , 0.01 );
113
+
81
114
}
82
115
83
116
@ Test
@@ -100,8 +133,8 @@ public void threeWithLargeRowspanCellTestUnevenDistribution() {
100
133
float heightRow2 = table .getRows ().get (1 ).getMaxHeights ();
101
134
float heightRow3 = table .getRows ().get (2 ).getMaxHeights ();
102
135
document .close ();
103
- Assertions .assertEquals (0 , heightRow2 - heightRow3 );
104
- Assertions .assertNotEquals (0 , heightRow1 - heightRow2 );
136
+ Assertions .assertEquals (heightRow2 , heightRow3 , 0.01 );
137
+ Assertions .assertNotEquals (heightRow1 , heightRow2 , 0.01 );
105
138
Assertions .assertTrue (heightRow1 > heightRow2 );
106
139
}
107
140
}
0 commit comments