Skip to content

Commit f440df3

Browse files
ars18wrwpavel-alay
authored andcommitted
Process incomplete rows in header and footer. Add a test.
DEVSIX-1597 Autoported commit. Original commit hash: [8e00c5ff]
1 parent b4c562e commit f440df3

File tree

5 files changed

+56
-7
lines changed

5 files changed

+56
-7
lines changed

itext.tests/itext.html2pdf.tests/itext/html2pdf/element/TableTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,13 @@ public virtual void TableMaxHeightTest02() {
410410
RunTest("tableMaxHeight02");
411411
}
412412

413+
/// <exception cref="System.IO.IOException"/>
414+
/// <exception cref="System.Exception"/>
415+
[NUnit.Framework.Test]
416+
public virtual void MultipleRowsInHeade01() {
417+
RunTest("multipleRowsInHeader01");
418+
}
419+
413420
/// <exception cref="System.IO.IOException"/>
414421
/// <exception cref="System.Exception"/>
415422
[NUnit.Framework.Test]
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>

itext/itext.html2pdf/itext/html2pdf/attach/wrapelement/TableWrapper.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,22 @@ public virtual Table ToTable(WaitingColgroupsHelper colgroupsHelper) {
173173
table = new Table(1);
174174
}
175175
if (headerRows != null) {
176-
foreach (IList<TableWrapper.CellWrapper> headerRow in headerRows) {
177-
foreach (TableWrapper.CellWrapper headerCell in headerRow) {
178-
table.AddHeaderCell(headerCell.cell);
176+
for (int i = 0; i < headerRows.Count; i++) {
177+
for (int j = 0; j < headerRows[i].Count; j++) {
178+
table.AddHeaderCell(headerRows[i][j].cell);
179+
}
180+
if (i != headerRows.Count - 1) {
181+
table.GetHeader().StartNewRow();
179182
}
180183
}
181184
}
182185
if (footerRows != null) {
183-
foreach (IList<TableWrapper.CellWrapper> footerRow in footerRows) {
184-
foreach (TableWrapper.CellWrapper footerCell in footerRow) {
185-
table.AddFooterCell(footerCell.cell);
186+
for (int i = 0; i < footerRows.Count; i++) {
187+
for (int j = 0; j < footerRows[i].Count; j++) {
188+
table.AddFooterCell(footerRows[i][j].cell);
189+
}
190+
if (i != footerRows.Count - 1) {
191+
table.GetFooter().StartNewRow();
186192
}
187193
}
188194
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
675a7c49c18ea91b941ce88da3f971266ca615c4
1+
8e00c5ff051d0ba35eb920a636fda6dffc4c2b10

0 commit comments

Comments
 (0)