Skip to content

Commit 6b324ea

Browse files
ars18wrwiText-CI
authored andcommitted
Support a table's caption. Add some new tests.
DEVSIX-982 Autoported commit. Original commit hash: [c6b1169e]
1 parent 1ece79e commit 6b324ea

32 files changed

+2622
-17
lines changed

itext.tests/itext.html2pdf.tests/itext/html2pdf/css/FloatTest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,14 @@ public virtual void FloatingDivBottomBorderTest() {
632632
RunTest("floatingDivBottomBorderTest", "diff_BottomBorderTest_");
633633
}
634634

635+
/// <exception cref="System.IO.IOException"/>
636+
/// <exception cref="System.Exception"/>
637+
[NUnit.Framework.Test]
638+
[LogMessage(iText.IO.LogMessageConstant.RECTANGLE_HAS_NEGATIVE_OR_ZERO_SIZES, Count = 1)]
639+
public virtual void FloatCaption01Test() {
640+
RunTest("floatCaption01Test", "diff_floatCaption01Test_");
641+
}
642+
635643
/// <exception cref="System.IO.IOException"/>
636644
/// <exception cref="System.Exception"/>
637645
private void RunTest(String testName, String diff) {

itext.tests/itext.html2pdf.tests/itext/html2pdf/element/CaptionTest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ source product.
4545
using iText.Html2pdf;
4646
using iText.Kernel.Utils;
4747
using iText.Test;
48-
using iText.Test.Attributes;
4948

5049
namespace iText.Html2pdf.Element {
5150
public class CaptionTest : ExtendedITextTest {
@@ -63,7 +62,6 @@ public static void BeforeClass() {
6362
/// <exception cref="System.IO.IOException"/>
6463
/// <exception cref="System.Exception"/>
6564
[NUnit.Framework.Test]
66-
[LogMessage(iText.Html2pdf.LogMessageConstant.NO_WORKER_FOUND_FOR_TAG, Count = 1)]
6765
public virtual void Caption01Test() {
6866
HtmlConverter.ConvertToPdf(new FileInfo(sourceFolder + "captionTest01.html"), new FileInfo(destinationFolder
6967
+ "captionTest01.pdf"));

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,69 @@ public virtual void PlainTextTest() {
471471
RunConvertToElements("plainTextTest", false);
472472
}
473473

474+
/// <exception cref="System.IO.IOException"/>
475+
/// <exception cref="System.Exception"/>
476+
[NUnit.Framework.Test]
477+
public virtual void SeparatedTablesWithDifferentCaptionsTest01() {
478+
RunTest("separatedTableWithDifferentCaptionsTest01", false);
479+
}
480+
481+
/// <exception cref="System.IO.IOException"/>
482+
/// <exception cref="System.Exception"/>
483+
[NUnit.Framework.Test]
484+
public virtual void CollapsedTablesWithDifferentCaptionsTest01() {
485+
RunTest("collapsedTablesWithDifferentCaptionsTest01", false);
486+
}
487+
488+
/// <exception cref="System.IO.IOException"/>
489+
/// <exception cref="System.Exception"/>
490+
[NUnit.Framework.Test]
491+
public virtual void CaptionWithTextAlignTest01() {
492+
RunTest("captionWithTextAlignTest01", false);
493+
}
494+
495+
/// <exception cref="System.IO.IOException"/>
496+
/// <exception cref="System.Exception"/>
497+
[NUnit.Framework.Test]
498+
public virtual void WideCaptionTest01() {
499+
RunTest("wideCaptionTest01", false);
500+
}
501+
502+
/// <exception cref="System.IO.IOException"/>
503+
/// <exception cref="System.Exception"/>
504+
[NUnit.Framework.Test]
505+
public virtual void WideCaptionTest02() {
506+
RunTest("wideCaptionTest02", false);
507+
}
508+
509+
/// <exception cref="System.IO.IOException"/>
510+
/// <exception cref="System.Exception"/>
511+
[NUnit.Framework.Test]
512+
public virtual void WideTableWithCaptionTest01() {
513+
RunTest("wideTableWithCaptionTest01", false);
514+
}
515+
516+
/// <exception cref="System.IO.IOException"/>
517+
/// <exception cref="System.Exception"/>
518+
[NUnit.Framework.Test]
519+
public virtual void WideTableWithCaptionTest02() {
520+
RunTest("wideTableWithCaptionTest02", false);
521+
}
522+
523+
/// <exception cref="System.IO.IOException"/>
524+
/// <exception cref="System.Exception"/>
525+
[NUnit.Framework.Test]
526+
public virtual void CaptionSideTest01() {
527+
RunTest("captionSideTest01", false);
528+
}
529+
530+
/// <exception cref="System.IO.IOException"/>
531+
/// <exception cref="System.Exception"/>
532+
[NUnit.Framework.Test]
533+
public virtual void CaptionSideSetAsAlignTest01() {
534+
RunTest("captionSideSetAsAlignTest01", false);
535+
}
536+
474537
/// <exception cref="System.IO.IOException"/>
475538
/// <exception cref="System.Exception"/>
476539
[NUnit.Framework.Test]
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
th, td {
6+
border: 1px solid black;
7+
}
8+
9+
table {
10+
border: 30px solid green;
11+
background-color: blue;
12+
}
13+
14+
caption {
15+
background-color: gray;
16+
width: 500px;
17+
}
18+
19+
div.beforeOrAfter {
20+
border: 1px solid black;
21+
}
22+
23+
div.lastOnThePage {
24+
border: 1px solid black;
25+
page-break-after: always;
26+
}
27+
28+
</style>
29+
</head>
30+
<body>
31+
32+
<h1> The whole caption as a float</h1>
33+
34+
<div class="beforeOrAfter">A div before the table</div>
35+
<table>
36+
<caption style="float: left;">
37+
<div style="background-color: red;">I'm the caption of the table! <br> Yes, I <p style="background-color: green; width: 70px;">belong</p> to the table!</div>
38+
</caption>
39+
<thead>
40+
<tr>
41+
<td>Head</td>
42+
<td>Head</td>
43+
</tr>
44+
</thead>
45+
<tr>
46+
<td>Body</td>
47+
<td>Body</td>
48+
</tr>
49+
<tfoot>
50+
<tr>
51+
<td>Footer</td>
52+
<td>Footer</td>
53+
</tr>
54+
</tfoot>
55+
</table>
56+
<div class="beforeOrAfter">A div after the table</div>
57+
58+
<h1> A distinct div inside a caption as a float</h1>
59+
60+
<div class="beforeOrAfter">A div before the table</div>
61+
<table>
62+
<caption>
63+
<div style="float: left; background-color: red;">I'm the caption of the table! <br> Yes, I <p style="background-color: green; width: 70px;">belong</p> to the table!</div>
64+
</caption>
65+
<thead>
66+
<tr>
67+
<td>Head</td>
68+
<td>Head</td>
69+
</tr>
70+
</thead>
71+
<tr>
72+
<td>Body</td>
73+
<td>Body</td>
74+
</tr>
75+
<tfoot>
76+
<tr>
77+
<td>Footer</td>
78+
<td>Footer</td>
79+
</tr>
80+
</tfoot>
81+
</table>
82+
<div class="beforeOrAfter">A div after the table</div>
83+
84+
<h1> A paragraph inside a caption as a float</h1>
85+
86+
<div class="beforeOrAfter">A div before the table</div>
87+
<table>
88+
<caption>
89+
<div style="background-color: red;">I'm the caption of the table! <br> Yes, I <p style="float: left; background-color: green; width: 70px;">belong</p> to the table!</div>
90+
</caption>
91+
<thead>
92+
<tr>
93+
<td>Head</td>
94+
<td>Head</td>
95+
</tr>
96+
</thead>
97+
<tr>
98+
<td>Body</td>
99+
<td>Body</td>
100+
</tr>
101+
<tfoot>
102+
<tr>
103+
<td>Footer</td>
104+
<td>Footer</td>
105+
</tr>
106+
</tfoot>
107+
</table>
108+
<div class="beforeOrAfter">A div after the table</div>
109+
110+
111+
</body>
112+
</html>
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
th, td {
6+
border: 1px solid black;
7+
}
8+
9+
table {
10+
border: 30px solid green;
11+
background-color: blue;
12+
}
13+
14+
caption {
15+
background-color: gray;
16+
width: 100px;
17+
}
18+
19+
div.beforeOrAfter {
20+
border: 1px solid black;
21+
}
22+
23+
div.lastOnThePage {
24+
border: 1px solid black;
25+
page-break-after: always;
26+
}
27+
28+
</style>
29+
</head>
30+
<body>
31+
32+
<h1>A table with a default caption</h1>
33+
34+
<div class="beforeOrAfter">A div before the table</div>
35+
<table>
36+
<caption>
37+
<p style="background-color: red;">I'm the caption of the table!</p>
38+
</caption>
39+
<thead>
40+
<tr>
41+
<td>Body</td>
42+
<td>Body</td>
43+
</tr>
44+
</thead>
45+
<tr>
46+
<td>Body</td>
47+
<td>Body</td>
48+
</tr>
49+
<tfoot>
50+
<tr>
51+
<td>Footer</td>
52+
<td>Footer</td>
53+
</tr>
54+
</tfoot>
55+
</table>
56+
<div class="lastOnThePage">A div after the table</div>
57+
58+
<h1>A table with a top caption</h1>
59+
60+
<div class="beforeOrAfter">A div before the table</div>
61+
<table>
62+
<caption aling="top">
63+
<p style="background-color: red;">I'm the caption of the table!</p>
64+
</caption>
65+
<thead>
66+
<tr>
67+
<td>Body</td>
68+
<td>Body</td>
69+
</tr>
70+
</thead>
71+
<tr>
72+
<td>Body</td>
73+
<td>Body</td>
74+
</tr>
75+
<tfoot>
76+
<tr>
77+
<td>Footer</td>
78+
<td>Footer</td>
79+
</tr>
80+
</tfoot>
81+
</table>
82+
<div class="lastOnThePage">A div after the table</div>
83+
84+
<h1>A table with a right caption</h1>
85+
86+
<div class="beforeOrAfter">A div before the table</div>
87+
<table>
88+
<caption align="right">
89+
<p style="background-color: red;">I'm the caption of the table!</p>
90+
</caption>
91+
<thead>
92+
<tr>
93+
<td>Body</td>
94+
<td>Body</td>
95+
</tr>
96+
</thead>
97+
<tr>
98+
<td>Body</td>
99+
<td>Body</td>
100+
</tr>
101+
<tfoot>
102+
<tr>
103+
<td>Footer</td>
104+
<td>Footer</td>
105+
</tr>
106+
</tfoot>
107+
</table>
108+
<div class="lastOnThePage">A div after the table</div>
109+
110+
<h1>A table with a bottom caption</h1>
111+
112+
<div class="beforeOrAfter">A div before the table</div>
113+
<table>
114+
<caption align="bottom">
115+
<p style="background-color: red;">I'm the caption of the table!</p>
116+
</caption>
117+
<thead>
118+
<tr>
119+
<td>Body</td>
120+
<td>Body</td>
121+
</tr>
122+
</thead>
123+
<tr>
124+
<td>Body</td>
125+
<td>Body</td>
126+
</tr>
127+
<tfoot>
128+
<tr>
129+
<td>Footer</td>
130+
<td>Footer</td>
131+
</tr>
132+
</tfoot>
133+
</table>
134+
<div class="lastOnThePage">A div after the table</div>
135+
136+
<h1>A table with a left caption</h1>
137+
138+
<div class="beforeOrAfter">A div before the table</div>
139+
<table>
140+
<caption align="left">
141+
<p style="background-color: red;">I'm the caption of the table!</p>
142+
</caption>
143+
<thead>
144+
<tr>
145+
<td>Body</td>
146+
<td>Body</td>
147+
</tr>
148+
</thead>
149+
<tr>
150+
<td>Body</td>
151+
<td>Body</td>
152+
</tr>
153+
<tfoot>
154+
<tr>
155+
<td>Footer</td>
156+
<td>Footer</td>
157+
</tr>
158+
</tfoot>
159+
</table>
160+
<div class="lastOnThePage">A div after the table</div>
161+
162+
</body>
163+
</html>

0 commit comments

Comments
 (0)