Skip to content

Commit 268a8d4

Browse files
committed
Process incomplete rows in header and footer. Add a test.
DEVSIX-1597
1 parent 796144d commit 268a8d4

File tree

4 files changed

+53
-6
lines changed

4 files changed

+53
-6
lines changed

src/main/java/com/itextpdf/html2pdf/attach/wrapelement/TableWrapper.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,22 @@ public Table toTable(WaitingColgroupsHelper colgroupsHelper) {
197197
//Workaround to remove default width:100%
198198
table.deleteOwnProperty(Property.WIDTH);
199199
if (headerRows != null) {
200-
for (List<CellWrapper> headerRow : headerRows) {
201-
for (CellWrapper headerCell : headerRow) {
202-
table.addHeaderCell(headerCell.cell);
200+
for (int i = 0; i < headerRows.size(); i++) {
201+
for (int j = 0; j < headerRows.get(i).size(); j++) {
202+
table.addHeaderCell(headerRows.get(i).get(j).cell);
203+
}
204+
if (i != headerRows.size() - 1) {
205+
table.getHeader().startNewRow();
203206
}
204207
}
205208
}
206209
if (footerRows != null) {
207-
for (List<CellWrapper> footerRow : footerRows) {
208-
for (CellWrapper footerCell : footerRow) {
209-
table.addFooterCell(footerCell.cell);
210+
for (int i = 0; i < footerRows.size(); i++) {
211+
for (int j = 0; j < footerRows.get(i).size(); j++) {
212+
table.addFooterCell(footerRows.get(i).get(j).cell);
213+
}
214+
if (i != footerRows.size() - 1) {
215+
table.getFooter().startNewRow();
210216
}
211217
}
212218
}

src/test/java/com/itextpdf/html2pdf/element/TableTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ public void tableMaxHeightTest02() throws IOException, InterruptedException {
321321
runTest("tableMaxHeight02");
322322
}
323323

324+
@Test
325+
public void multipleRowsInHeade01() throws IOException, InterruptedException {
326+
runTest("multipleRowsInHeader01");
327+
}
328+
324329
@Test
325330
@Ignore("DEVSIX-994")
326331
public void tableCollapseColCellBoxSizingWidthDifference() throws IOException, InterruptedException {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<html>
2+
<body>
3+
<table border="1">
4+
<thead>
5+
<tr>
6+
<td>Header Row 1 Col 1</td>
7+
</tr>
8+
<tr>
9+
<td>Header Row 2 Col 1</td>
10+
<td>Header Row 2 Col 2</td>
11+
<td>Header Row 2 Col 3</td>
12+
</tr>
13+
</thead>
14+
<tbody>
15+
<tr>
16+
<td>Body Row 1 Col 1</td>
17+
</tr>
18+
<tr>
19+
<td>Body Row 2 Col 1</td>
20+
<td>Body Row 2 Col 2</td>
21+
<td>Body Row 2 Col 3</td>
22+
</tr>
23+
</tbody>
24+
<tfoot>
25+
<tr>
26+
<td>Footer Row 1 Col 1</td>
27+
</tr>
28+
<tr>
29+
<td>Footer Row 2 Col 1</td>
30+
<td>Footer Row 2 Col 2</td>
31+
<td>Footer Row 2 Col 3</td>
32+
</tr>
33+
</tfoot>
34+
</table>
35+
</body>
36+
</html>

0 commit comments

Comments
 (0)