@@ -42,53 +42,141 @@ This file is part of the iText (R) project.
4242 */
4343package com .itextpdf .html2pdf .css ;
4444
45+ import com .itextpdf .html2pdf .ConverterProperties ;
4546import com .itextpdf .html2pdf .ExtendedHtmlConversionITextTest ;
47+ import com .itextpdf .html2pdf .HtmlConverter ;
48+ import com .itextpdf .io .util .UrlUtil ;
49+ import com .itextpdf .kernel .geom .PageSize ;
50+ import com .itextpdf .kernel .pdf .PdfDocument ;
51+ import com .itextpdf .kernel .pdf .PdfWriter ;
52+ import com .itextpdf .kernel .utils .CompareTool ;
4653import com .itextpdf .test .annotations .type .IntegrationTest ;
4754
55+ import java .io .FileInputStream ;
4856import java .io .IOException ;
49-
57+ import org . junit . Assert ;
5058import org .junit .BeforeClass ;
5159import org .junit .Test ;
5260import org .junit .experimental .categories .Category ;
5361
5462@ Category (IntegrationTest .class )
5563public class OverflowTest extends ExtendedHtmlConversionITextTest {
5664
57- public static final String sourceFolder = "./src/test/resources/com/itextpdf/html2pdf/css/OverflowTest/" ;
58- public static final String destinationFolder = "./target/test/com/itextpdf/html2pdf/css/OverflowTest/" ;
65+ public static final String SOURCE_FOLDER = "./src/test/resources/com/itextpdf/html2pdf/css/OverflowTest/" ;
66+ public static final String DESTINATION_FOLDER = "./target/test/com/itextpdf/html2pdf/css/OverflowTest/" ;
5967
6068 @ BeforeClass
6169 public static void beforeClass () {
62- createDestinationFolder (destinationFolder );
70+ createDestinationFolder (DESTINATION_FOLDER );
71+ }
72+
73+ @ Test
74+ public void divOverflowXOverflowYHiddenTest () throws IOException , InterruptedException {
75+ convertToPdfAndCompare ("divOverflowXOverflowYHidden" , SOURCE_FOLDER , DESTINATION_FOLDER );
76+ }
77+
78+ @ Test
79+ public void paragraphOverflowVisibleTest () throws IOException , InterruptedException {
80+ convertToPdfAndCompare ("paragraphOverflowVisible" , SOURCE_FOLDER , DESTINATION_FOLDER );
81+ }
82+
83+ @ Test
84+ public void divOverflowHiddenParagraphOverflowVisibleTest () throws IOException , InterruptedException {
85+ convertToPdfAndCompare ("divOverflowHiddenParagraphOverflowVisible" , SOURCE_FOLDER , DESTINATION_FOLDER );
6386 }
6487
6588 @ Test
66- public void overflowTest04 () throws IOException , InterruptedException {
67- convertToPdfAndCompare ("overflowTest04 " , sourceFolder , destinationFolder );
89+ public void divOverflowXOverflowYVisibleTest () throws IOException , InterruptedException {
90+ convertToPdfAndCompare ("divOverflowXOverflowYVisible " , SOURCE_FOLDER , DESTINATION_FOLDER );
6891 }
6992
7093 @ Test
71- public void overflowTest06 () throws IOException , InterruptedException {
72- convertToPdfAndCompare ("overflowTest06 " , sourceFolder , destinationFolder );
94+ public void tableOverflowXOverflowYVisibleTest () throws IOException , InterruptedException {
95+ convertToPdfAndCompare ("tableOverflowXOverflowYVisible " , SOURCE_FOLDER , DESTINATION_FOLDER );
7396 }
7497
7598 @ Test
76- public void overflowTest07 () throws IOException , InterruptedException {
77- convertToPdfAndCompare ("overflowTest07" , sourceFolder , destinationFolder );
99+ //TODO DEVSIX-5208 Overflown content should be placed over the content of backgrounds and borders of other elements
100+ public void paragraphOverflowXOverflowYVisibleTest () throws IOException , InterruptedException {
101+ convertToPdfAndCompare ("paragraphOverflowXOverflowYVisible" , SOURCE_FOLDER , DESTINATION_FOLDER );
102+ }
103+
104+ @ Test
105+ //TODO DEVSIX-5208 Overflown content should be placed over the content of backgrounds and borders of other elements
106+ public void ulOverflowXOverflowYVisibleTest () throws IOException , InterruptedException {
107+ convertToPdfAndCompare ("ulOverflowXOverflowYVisible" , SOURCE_FOLDER , DESTINATION_FOLDER );
108+ }
109+
110+ @ Test
111+ public void tableOverflowHiddenTest () throws IOException , InterruptedException {
112+ convertToPdfAndCompare ("tableOverflowHidden" , SOURCE_FOLDER , DESTINATION_FOLDER );
113+ }
114+
115+ @ Test
116+ public void divOverflowScrollTest () throws IOException , InterruptedException {
117+ convertToPdfAndCompare ("divOverflowScroll" , SOURCE_FOLDER , DESTINATION_FOLDER );
118+ }
119+
120+ @ Test
121+ public void divOverflowAutoTest () throws IOException , InterruptedException {
122+ convertToPdfAndCompare ("divOverflowAuto" , SOURCE_FOLDER , DESTINATION_FOLDER );
123+ }
124+
125+ @ Test
126+ //TODO DEVSIX-5211 Overflown due to 'overflow: visible' content should be wrapped to the next page
127+ public void overflowVisibleContentShouldBeSplitBetweenPagesTest () throws IOException , InterruptedException {
128+ convertToPdfAndCompare ("overflowVisibleContentShouldBeSplitBetweenPages" , SOURCE_FOLDER , DESTINATION_FOLDER );
78129 }
79130
80131 @ Test
81132 public void overflowAndAlignment01 () throws IOException , InterruptedException {
82- convertToPdfAndCompare ("overflowAndAlignment01" , sourceFolder , destinationFolder );
133+ convertToPdfAndCompare ("overflowAndAlignment01" , SOURCE_FOLDER , DESTINATION_FOLDER );
83134 }
84135
85136 @ Test
86137 public void overflowAndAlignment02 () throws IOException , InterruptedException {
87- convertToPdfAndCompare ("overflowAndAlignment02" , sourceFolder , destinationFolder );
138+ convertToPdfAndCompare ("overflowAndAlignment02" , SOURCE_FOLDER , DESTINATION_FOLDER );
88139 }
89140
90141 @ Test
91142 public void displayOverflowAutoScroll () throws IOException , InterruptedException {
92- convertToPdfAndCompare ("displayOverflowAutoScroll" , sourceFolder , destinationFolder );
143+ convertToPdfAndCompare ("displayOverflowAutoScroll" , SOURCE_FOLDER , DESTINATION_FOLDER );
144+ }
145+
146+ @ Test
147+ //TODO DEVSIX-5212 CSS parsing: implement correct handling of css tokens with escaped code point
148+ public void overflowYVisibleOverflowXAllValuesTest () throws IOException , InterruptedException {
149+ runTest ("overflowYVisibleOverflowXAllValues" , new PageSize (1200 , 1400 ));
150+ }
151+
152+ @ Test
153+ //TODO DEVSIX-5212 CSS parsing: implement correct handling of css tokens with escaped code point
154+ public void overflowYHiddenOverflowXAllValuesTest () throws IOException , InterruptedException {
155+ runTest ("overflowYHiddenOverflowXAllValues" , new PageSize (1200 , 1400 ));
156+ }
157+
158+ @ Test
159+ //TODO DEVSIX-5212 CSS parsing: implement correct handling of css tokens with escaped code point
160+ public void overflowYScrollOverflowXAllValuesTest () throws IOException , InterruptedException {
161+ runTest ("overflowYScrollOverflowXAllValues" , new PageSize (1200 , 1400 ));
162+ }
163+
164+ @ Test
165+ //TODO DEVSIX-5212 CSS parsing: implement correct handling of css tokens with escaped code point
166+ public void overflowYAutoOverflowXAllValues () throws IOException , InterruptedException {
167+ runTest ("overflowYAutoOverflowXAllValues" , new PageSize (1200 , 1400 ));
168+ }
169+
170+ private void runTest (String testName , PageSize pageSize ) throws IOException , InterruptedException {
171+ PdfDocument pdfDocument = new PdfDocument (new PdfWriter (DESTINATION_FOLDER + testName + ".pdf" ));
172+ if (null != pageSize ) {
173+ pdfDocument .setDefaultPageSize (pageSize );
174+ }
175+ HtmlConverter .convertToPdf (new FileInputStream (SOURCE_FOLDER + testName + ".html" ), pdfDocument ,
176+ new ConverterProperties ().setBaseUri (SOURCE_FOLDER ));
177+ System .out .println ("html: " + UrlUtil .getNormalizedFileUriString (SOURCE_FOLDER + testName + ".html" ) + "\n " );
178+ Assert .assertNull (new CompareTool ()
179+ .compareByContent (DESTINATION_FOLDER + testName + ".pdf" , SOURCE_FOLDER + "cmp_" + testName + ".pdf" ,
180+ DESTINATION_FOLDER , "diff_" + testName ));
93181 }
94182}
0 commit comments