@@ -27,19 +27,23 @@ This file is part of the iText (R) project.
27
27
import com .itextpdf .forms .logs .FormsLogMessageConstants ;
28
28
import com .itextpdf .html2pdf .ConverterProperties ;
29
29
import com .itextpdf .html2pdf .HtmlConverter ;
30
+ import com .itextpdf .html2pdf .logs .Html2PdfLogMessageConstant ;
30
31
import com .itextpdf .io .logs .IoLogMessageConstant ;
32
+ import com .itextpdf .io .source .ByteArrayOutputStream ;
31
33
import com .itextpdf .io .util .UrlUtil ;
32
34
import com .itextpdf .kernel .pdf .PdfDocument ;
33
35
import com .itextpdf .kernel .pdf .PdfReader ;
34
36
import com .itextpdf .kernel .pdf .PdfWriter ;
35
37
import com .itextpdf .kernel .utils .CompareTool ;
36
38
import com .itextpdf .layout .logs .LayoutLogMessageConstant ;
37
39
import com .itextpdf .test .ExtendedITextTest ;
40
+ import com .itextpdf .test .LogLevelConstants ;
38
41
import com .itextpdf .test .annotations .LogMessage ;
39
42
import com .itextpdf .test .annotations .LogMessages ;
40
43
import com .itextpdf .test .annotations .type .IntegrationTest ;
41
44
42
45
import java .io .File ;
46
+ import java .io .FileInputStream ;
43
47
import java .io .IOException ;
44
48
import org .junit .Assert ;
45
49
import org .junit .BeforeClass ;
@@ -67,6 +71,41 @@ public void textFieldWithPlaceholderTest() throws IOException, InterruptedExcept
67
71
runTest ("textFieldWithPlaceholder" );
68
72
}
69
73
74
+ @ Test
75
+ public void textFieldHeadersFootersTest () throws IOException , InterruptedException {
76
+ runTest ("textFieldHeadersFooters" );
77
+ }
78
+
79
+ @ Test
80
+ public void textFieldHeadersFootersWithValueTest () throws IOException , InterruptedException {
81
+ runTest ("textFieldHeadersFootersWithValue" );
82
+ }
83
+
84
+ @ Test
85
+ public void textAreaHeadersFootersWithValueTest () throws IOException , InterruptedException {
86
+ runTest ("textAreaHeadersFooters" );
87
+ }
88
+
89
+
90
+ @ Test
91
+ public void checkBoxHeadersFootersWithValueTest () throws IOException , InterruptedException {
92
+ //TODO DEVSIX-7760 Adding formfield elements to header generates strange results
93
+ runTest ("checkBoxHeadersFooters" );
94
+ }
95
+
96
+ @ Test
97
+ public void radioHeadersFootersWithValueTest () throws IOException , InterruptedException {
98
+ //TODO DEVSIX-7760 Adding formfield elements to header generates strange results
99
+ runTest ("radioHeadersFooters" );
100
+ }
101
+
102
+
103
+ @ Test
104
+ public void dropDownHeadersFootersWithValueTest () throws IOException , InterruptedException {
105
+ runTest ("dropDownHeadersFooters" );
106
+ }
107
+
108
+
70
109
@ Test
71
110
public void splitTextFieldTest () throws IOException , InterruptedException {
72
111
runTest ("splitTextField" );
@@ -185,6 +224,7 @@ public void radiobox1Test() throws IOException, InterruptedException {
185
224
public void radiobox2Test () throws IOException , InterruptedException {
186
225
runTest ("radiobox2" );
187
226
}
227
+
188
228
@ Test
189
229
@ LogMessages (messages = {
190
230
@ LogMessage (messageTemplate = IoLogMessageConstant .MULTIPLE_VALUES_ON_A_NON_MULTISELECT_FIELD )})
@@ -238,6 +278,57 @@ public void radioButtonNoPageCounterTest() throws IOException, InterruptedExcept
238
278
pdf , sourceFolder + "cmp_radioButtonNoPageCounter.pdf" , destinationFolder ));
239
279
}
240
280
281
+ @ Test
282
+ @ LogMessages (messages = {
283
+ @ LogMessage (messageTemplate = Html2PdfLogMessageConstant .IMMEDIATE_FLUSH_DISABLED , logLevel =
284
+ LogLevelConstants .INFO )})
285
+ public void checkLogInfo () throws IOException {
286
+ String html = sourceFolder + "radiobox1.html" ;
287
+ try (FileInputStream fileInputStream = new FileInputStream (html );
288
+ ByteArrayOutputStream baos = new ByteArrayOutputStream ()) {
289
+ HtmlConverter .convertToPdf (fileInputStream , baos ,
290
+ new ConverterProperties ().setCreateAcroForm (true ));
291
+ }
292
+ }
293
+
294
+ @ Test
295
+ @ LogMessages (messages = {
296
+ @ LogMessage (messageTemplate = Html2PdfLogMessageConstant .IMMEDIATE_FLUSH_DISABLED , logLevel =
297
+ LogLevelConstants .INFO , count = 0 )})
298
+ public void checkLogInfoNoAcroForm () throws IOException {
299
+ String html = sourceFolder + "radiobox1.html" ;
300
+ try (FileInputStream fileInputStream = new FileInputStream (html );
301
+ ByteArrayOutputStream baos = new ByteArrayOutputStream ()) {
302
+ HtmlConverter .convertToPdf (fileInputStream , baos ,
303
+ new ConverterProperties ().setCreateAcroForm (false ));
304
+ }
305
+ }
306
+
307
+ @ Test
308
+ @ LogMessages (messages = {
309
+ @ LogMessage (messageTemplate = Html2PdfLogMessageConstant .IMMEDIATE_FLUSH_DISABLED , logLevel =
310
+ LogLevelConstants .INFO , count = 0 )})
311
+ public void checkLogInfoAcroFormFlushDisabled () throws IOException {
312
+ String html = sourceFolder + "radiobox1.html" ;
313
+ try (FileInputStream fileInputStream = new FileInputStream (html );
314
+ ByteArrayOutputStream baos = new ByteArrayOutputStream ()) {
315
+ HtmlConverter .convertToPdf (fileInputStream , baos ,
316
+ new ConverterProperties ().setCreateAcroForm (true ).setImmediateFlush (false ));
317
+ }
318
+ }
319
+
320
+ @ Test
321
+ @ LogMessages (messages = {
322
+ @ LogMessage (messageTemplate = Html2PdfLogMessageConstant .IMMEDIATE_FLUSH_DISABLED , logLevel =
323
+ LogLevelConstants .INFO , count = 0 )})
324
+ public void checkLogInfoDefault () throws IOException {
325
+ String html = sourceFolder + "radiobox1.html" ;
326
+ try (FileInputStream fileInputStream = new FileInputStream (html );
327
+ ByteArrayOutputStream baos = new ByteArrayOutputStream ()) {
328
+ HtmlConverter .convertToPdf (fileInputStream , baos );
329
+ }
330
+ }
331
+
241
332
private void runTest (String name ) throws IOException , InterruptedException {
242
333
runTest (name , true );
243
334
}
@@ -253,7 +344,8 @@ private void runTest(String name, boolean flattenPdfAcroFormFields) throws IOExc
253
344
String diff = "diff_" + name + "_" ;
254
345
255
346
HtmlConverter .convertToPdf (new File (htmlPath ), new File (outPdfPath ));
256
- HtmlConverter .convertToPdf (new File (htmlPath ), new File (outAcroPdfPath ), new ConverterProperties ().setCreateAcroForm (true ));
347
+ HtmlConverter .convertToPdf (new File (htmlPath ), new File (outAcroPdfPath ),
348
+ new ConverterProperties ().setCreateAcroForm (true ));
257
349
if (flattenPdfAcroFormFields ) {
258
350
PdfDocument document = new PdfDocument (new PdfReader (outAcroPdfPath ), new PdfWriter (outAcroFlattenPdfPath ));
259
351
PdfAcroForm acroForm = PdfFormCreator .getAcroForm (document , false );
@@ -264,7 +356,9 @@ private void runTest(String name, boolean flattenPdfAcroFormFields) throws IOExc
264
356
Assert .assertNull (new CompareTool ().compareByContent (outPdfPath , cmpPdfPath , destinationFolder , diff ));
265
357
Assert .assertNull (new CompareTool ().compareByContent (outAcroPdfPath , cmpAcroPdfPath , destinationFolder , diff ));
266
358
if (flattenPdfAcroFormFields ) {
267
- Assert .assertNull (new CompareTool ().compareByContent (outAcroFlattenPdfPath , cmpAcroFlattenPdfPath , destinationFolder , diff ));
359
+ Assert .assertNull (
360
+ new CompareTool ().compareByContent (outAcroFlattenPdfPath , cmpAcroFlattenPdfPath , destinationFolder ,
361
+ diff ));
268
362
}
269
363
}
270
364
}
0 commit comments