Skip to content

Commit e81fa5f

Browse files
Add warning logging for attempts of select field acroforms creation
DEVSIX-984 Autoported commit. Original commit hash: [6a3781f3c7]
1 parent b889e6f commit e81fa5f

File tree

16 files changed

+205
-18
lines changed

16 files changed

+205
-18
lines changed

itext.tests/itext.html2pdf.tests/itext/html2pdf/element/FormTest.cs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,31 @@ public virtual void Radiobox2Test() {
207207
RunTest("radiobox2");
208208
}
209209

210+
/// <exception cref="System.IO.IOException"/>
211+
/// <exception cref="System.Exception"/>
212+
[NUnit.Framework.Test]
213+
[LogMessage(iText.Html2pdf.LogMessageConstant.ACROFORM_NOT_SUPPORTED_FOR_SELECT, Count = 2)]
214+
public virtual void SelectTest01() {
215+
RunTest("select01", false);
216+
}
217+
218+
/// <exception cref="System.IO.IOException"/>
219+
/// <exception cref="System.Exception"/>
220+
[NUnit.Framework.Test]
221+
[LogMessage(iText.Html2pdf.LogMessageConstant.ACROFORM_NOT_SUPPORTED_FOR_SELECT, Count = 3)]
222+
public virtual void SelectTest02() {
223+
RunTest("select02", false);
224+
}
225+
210226
/// <exception cref="System.IO.IOException"/>
211227
/// <exception cref="System.Exception"/>
212228
private void RunTest(String name) {
229+
RunTest(name, true);
230+
}
231+
232+
/// <exception cref="System.IO.IOException"/>
233+
/// <exception cref="System.Exception"/>
234+
private void RunTest(String name, bool flattenPdfAcroFormFields) {
213235
String htmlPath = sourceFolder + name + ".html";
214236
String outPdfPath = destinationFolder + name + ".pdf";
215237
String outAcroPdfPath = destinationFolder + name + "_acro.pdf";
@@ -221,17 +243,21 @@ private void RunTest(String name) {
221243
HtmlConverter.ConvertToPdf(new FileInfo(htmlPath), new FileInfo(outPdfPath));
222244
HtmlConverter.ConvertToPdf(new FileInfo(htmlPath), new FileInfo(outAcroPdfPath), new ConverterProperties()
223245
.SetCreateAcroForm(true));
224-
PdfDocument document = new PdfDocument(new PdfReader(outAcroPdfPath), new PdfWriter(outAcroFlattenPdfPath)
225-
);
226-
PdfAcroForm acroForm = PdfAcroForm.GetAcroForm(document, false);
227-
acroForm.FlattenFields();
228-
document.Close();
246+
if (flattenPdfAcroFormFields) {
247+
PdfDocument document = new PdfDocument(new PdfReader(outAcroPdfPath), new PdfWriter(outAcroFlattenPdfPath)
248+
);
249+
PdfAcroForm acroForm = PdfAcroForm.GetAcroForm(document, false);
250+
acroForm.FlattenFields();
251+
document.Close();
252+
}
229253
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdfPath, cmpPdfPath, destinationFolder
230254
, diff));
231255
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outAcroPdfPath, cmpAcroPdfPath, destinationFolder
232256
, diff));
233-
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outAcroFlattenPdfPath, cmpAcroFlattenPdfPath
234-
, destinationFolder, diff));
257+
if (flattenPdfAcroFormFields) {
258+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outAcroFlattenPdfPath, cmpAcroFlattenPdfPath
259+
, destinationFolder, diff));
260+
}
235261
}
236262
}
237263
}

itext.tests/itext.html2pdf.tests/itext/html2pdf/element/TaggedPdfFormTest.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,31 @@ public virtual void SimpleCheckboxTagged() {
5757
/// <exception cref="System.IO.IOException"/>
5858
/// <exception cref="System.Exception"/>
5959
[NUnit.Framework.Test]
60-
[NUnit.Framework.Ignore("DefaultHtmlProcessor ERROR No worker found for tag select")]
60+
[NUnit.Framework.Ignore("DEVSIX-1901")]
6161
public virtual void SimpleSelectTagged() {
6262
RunTest("simpleSelectTagged");
6363
}
6464

6565
/// <exception cref="System.IO.IOException"/>
6666
/// <exception cref="System.Exception"/>
6767
[NUnit.Framework.Test]
68+
[NUnit.Framework.Ignore("DEVSIX-1901")]
69+
public virtual void ListBoxSelectTagged() {
70+
RunTest("listBoxSelectTagged");
71+
}
72+
73+
/// <exception cref="System.IO.IOException"/>
74+
/// <exception cref="System.Exception"/>
75+
[NUnit.Framework.Test]
76+
[NUnit.Framework.Ignore("DEVSIX-1901")]
77+
public virtual void ListBoxOptGroupSelectTagged() {
78+
RunTest("listBoxOptGroupSelectTagged");
79+
}
80+
81+
/// <exception cref="System.IO.IOException"/>
82+
/// <exception cref="System.Exception"/>
83+
[NUnit.Framework.Test]
84+
[NUnit.Framework.Ignore("DEVSIX-1901")]
6885
public virtual void SimpleRadioFormTagged() {
6986
RunTest("simpleRadioFormTagged");
7087
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
</head>
5+
<body>
6+
7+
<select name="options" style="background-color: rgb(30, 144, 255); font-size: 30pt; color: white">
8+
<option value="value1" style="font-size: 30pt;">Value 1</option>
9+
<option value="value2" style="font-size: 30pt;">Value 2</option>
10+
<option value="value3">Value 3</option>
11+
</select>
12+
13+
<select name="options" size="3" style="background-color: rgb(30, 144, 255); font-size: 30pt; color: white"">
14+
<option value="value1" selected="selected">Value 1</option>
15+
<option value="value2" selected="selected">Value 2</option>
16+
<option value="value3">Value 3</option>
17+
</select>
18+
19+
</body>
20+
</html>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
</head>
5+
<body>
6+
7+
<select name="options" size="2" multiple="" style="padding: 20px; height: 60px; overflow: hidden;">
8+
<option value="value1">Value 1</option>
9+
<option value="value2">Value 2</option>
10+
<option value="value3" selected="">Value 3</option>
11+
<option value="value3">Value 4</option>
12+
<option value="value3">Value 5</option>
13+
</select>
14+
</select>
15+
16+
<select name="options" size="2" multiple="" style="padding: 20px; height: 60px; overflow: hidden;">
17+
<option value="value1">Value 1</option>
18+
<option value="value2">Value 2</option>
19+
<option value="value3">Value 3</option>
20+
<option value="value3">Value 4</option>
21+
<option value="value3">Value 5</option>
22+
</select>
23+
24+
<select name="options" size="2" multiple="" style="padding: 20px; height: 60px; overflow: hidden;">
25+
<option value="value1">Value 1</option>
26+
<option value="value2">Value 2</option>
27+
<option value="value3">Value 3</option>
28+
<option value="value3">Value 4</option>
29+
<option value="value3" selected="">Value 5</option>
30+
</select>
31+
32+
</body>
33+
</html>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
select{
6+
padding: 5px;
7+
color: green;
8+
}
9+
select option { color: black; }
10+
select option:first-child{
11+
color: red;
12+
}
13+
html {
14+
font-family:Helvetica, sans-serif;
15+
}
16+
17+
</style>
18+
</head>
19+
<body>
20+
<select size="4">
21+
<option value="Value1">Value1 outside</option>
22+
<optgroup label="Group 1">
23+
<option value="Value2">Value2 outside</option>
24+
</optgroup>
25+
<option value="Value3">Value3 outside</option>
26+
</select>
27+
<form>
28+
<select multiple="">
29+
<option value="Value1.1">Item1 inside</option>
30+
<optgroup label="Group 1">
31+
<option value="Value1.2">Item2 inside</option>
32+
</optgroup>
33+
<option value="Value1.3">Item3 inside</option>
34+
</select>
35+
</form>
36+
</body>
37+
</html>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
select{
6+
padding: 5px;
7+
color: green;
8+
}
9+
select option { color: black; }
10+
select option:first-child{
11+
color: red;
12+
}
13+
html {
14+
font-family:Helvetica, sans-serif;
15+
}
16+
17+
</style>
18+
</head>
19+
<body>
20+
<select size="4">
21+
<option value="Value1">Value1 outside</option>
22+
<option value="Value2">Value2 outside</option>
23+
<option value="Value3">Value3 outside</option>
24+
</select>
25+
<form>
26+
<select multiple="">
27+
<option value="Value1.1">Item1 inside</option>
28+
<option value="Value1.2">Item2 inside</option>
29+
<option value="Value1.3">Item3 inside</option>
30+
</select>
31+
</form>
32+
</body>
33+
</html>

0 commit comments

Comments
 (0)