Skip to content

Commit 8e00c5f

Browse files
committed
Process incomplete rows in header and footer. Add a test.
DEVSIX-1597
1 parent 675a7c4 commit 8e00c5f

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
@@ -195,16 +195,22 @@ public Table toTable(WaitingColgroupsHelper colgroupsHelper) {
195195
table = new Table(1);
196196
}
197197
if (headerRows != null) {
198-
for (List<CellWrapper> headerRow : headerRows) {
199-
for (CellWrapper headerCell : headerRow) {
200-
table.addHeaderCell(headerCell.cell);
198+
for (int i = 0; i < headerRows.size(); i++) {
199+
for (int j = 0; j < headerRows.get(i).size(); j++) {
200+
table.addHeaderCell(headerRows.get(i).get(j).cell);
201+
}
202+
if (i != headerRows.size() - 1) {
203+
table.getHeader().startNewRow();
201204
}
202205
}
203206
}
204207
if (footerRows != null) {
205-
for (List<CellWrapper> footerRow : footerRows) {
206-
for (CellWrapper footerCell : footerRow) {
207-
table.addFooterCell(footerCell.cell);
208+
for (int i = 0; i < footerRows.size(); i++) {
209+
for (int j = 0; j < footerRows.get(i).size(); j++) {
210+
table.addFooterCell(footerRows.get(i).get(j).cell);
211+
}
212+
if (i != footerRows.size() - 1) {
213+
table.getFooter().startNewRow();
208214
}
209215
}
210216
}

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 {
Binary file not shown.
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)