@@ -42,53 +42,141 @@ This file is part of the iText (R) project.
42
42
*/
43
43
package com .itextpdf .html2pdf .css ;
44
44
45
+ import com .itextpdf .html2pdf .ConverterProperties ;
45
46
import 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 ;
46
53
import com .itextpdf .test .annotations .type .IntegrationTest ;
47
54
55
+ import java .io .FileInputStream ;
48
56
import java .io .IOException ;
49
-
57
+ import org . junit . Assert ;
50
58
import org .junit .BeforeClass ;
51
59
import org .junit .Test ;
52
60
import org .junit .experimental .categories .Category ;
53
61
54
62
@ Category (IntegrationTest .class )
55
63
public class OverflowTest extends ExtendedHtmlConversionITextTest {
56
64
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/" ;
59
67
60
68
@ BeforeClass
61
69
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 );
63
86
}
64
87
65
88
@ 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 );
68
91
}
69
92
70
93
@ 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 );
73
96
}
74
97
75
98
@ 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 );
78
129
}
79
130
80
131
@ Test
81
132
public void overflowAndAlignment01 () throws IOException , InterruptedException {
82
- convertToPdfAndCompare ("overflowAndAlignment01" , sourceFolder , destinationFolder );
133
+ convertToPdfAndCompare ("overflowAndAlignment01" , SOURCE_FOLDER , DESTINATION_FOLDER );
83
134
}
84
135
85
136
@ Test
86
137
public void overflowAndAlignment02 () throws IOException , InterruptedException {
87
- convertToPdfAndCompare ("overflowAndAlignment02" , sourceFolder , destinationFolder );
138
+ convertToPdfAndCompare ("overflowAndAlignment02" , SOURCE_FOLDER , DESTINATION_FOLDER );
88
139
}
89
140
90
141
@ Test
91
142
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 ));
93
181
}
94
182
}
0 commit comments