@@ -27,19 +27,23 @@ This file is part of the iText (R) project.
2727import com .itextpdf .forms .logs .FormsLogMessageConstants ;
2828import com .itextpdf .html2pdf .ConverterProperties ;
2929import com .itextpdf .html2pdf .HtmlConverter ;
30+ import com .itextpdf .html2pdf .logs .Html2PdfLogMessageConstant ;
3031import com .itextpdf .io .logs .IoLogMessageConstant ;
32+ import com .itextpdf .io .source .ByteArrayOutputStream ;
3133import com .itextpdf .io .util .UrlUtil ;
3234import com .itextpdf .kernel .pdf .PdfDocument ;
3335import com .itextpdf .kernel .pdf .PdfReader ;
3436import com .itextpdf .kernel .pdf .PdfWriter ;
3537import com .itextpdf .kernel .utils .CompareTool ;
3638import com .itextpdf .layout .logs .LayoutLogMessageConstant ;
3739import com .itextpdf .test .ExtendedITextTest ;
40+ import com .itextpdf .test .LogLevelConstants ;
3841import com .itextpdf .test .annotations .LogMessage ;
3942import com .itextpdf .test .annotations .LogMessages ;
4043import com .itextpdf .test .annotations .type .IntegrationTest ;
4144
4245import java .io .File ;
46+ import java .io .FileInputStream ;
4347import java .io .IOException ;
4448import org .junit .Assert ;
4549import org .junit .BeforeClass ;
@@ -67,6 +71,41 @@ public void textFieldWithPlaceholderTest() throws IOException, InterruptedExcept
6771 runTest ("textFieldWithPlaceholder" );
6872 }
6973
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+
70109 @ Test
71110 public void splitTextFieldTest () throws IOException , InterruptedException {
72111 runTest ("splitTextField" );
@@ -185,6 +224,7 @@ public void radiobox1Test() throws IOException, InterruptedException {
185224 public void radiobox2Test () throws IOException , InterruptedException {
186225 runTest ("radiobox2" );
187226 }
227+
188228 @ Test
189229 @ LogMessages (messages = {
190230 @ LogMessage (messageTemplate = IoLogMessageConstant .MULTIPLE_VALUES_ON_A_NON_MULTISELECT_FIELD )})
@@ -238,6 +278,57 @@ public void radioButtonNoPageCounterTest() throws IOException, InterruptedExcept
238278 pdf , sourceFolder + "cmp_radioButtonNoPageCounter.pdf" , destinationFolder ));
239279 }
240280
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+
241332 private void runTest (String name ) throws IOException , InterruptedException {
242333 runTest (name , true );
243334 }
@@ -253,7 +344,8 @@ private void runTest(String name, boolean flattenPdfAcroFormFields) throws IOExc
253344 String diff = "diff_" + name + "_" ;
254345
255346 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 ));
257349 if (flattenPdfAcroFormFields ) {
258350 PdfDocument document = new PdfDocument (new PdfReader (outAcroPdfPath ), new PdfWriter (outAcroFlattenPdfPath ));
259351 PdfAcroForm acroForm = PdfFormCreator .getAcroForm (document , false );
@@ -264,7 +356,9 @@ private void runTest(String name, boolean flattenPdfAcroFormFields) throws IOExc
264356 Assert .assertNull (new CompareTool ().compareByContent (outPdfPath , cmpPdfPath , destinationFolder , diff ));
265357 Assert .assertNull (new CompareTool ().compareByContent (outAcroPdfPath , cmpAcroPdfPath , destinationFolder , diff ));
266358 if (flattenPdfAcroFormFields ) {
267- Assert .assertNull (new CompareTool ().compareByContent (outAcroFlattenPdfPath , cmpAcroFlattenPdfPath , destinationFolder , diff ));
359+ Assert .assertNull (
360+ new CompareTool ().compareByContent (outAcroFlattenPdfPath , cmpAcroFlattenPdfPath , destinationFolder ,
361+ diff ));
268362 }
269363 }
270364}
0 commit comments