@@ -60,6 +60,16 @@ public class BlockTest : ExtendedITextTest {
6060 public static readonly String destinationFolder = NUnit . Framework . TestContext . CurrentContext . TestDirectory
6161 + "/test/itext/layout/BlockTest/" ;
6262
63+ private const String textByronNarrow = "When a man hath no freedom to fight for at home, " + "Let him combat for that of his neighbours; "
64+ + "Let him think of the glories of Greece and of Rome, " + "And get knocked on the head for his labours. "
65+ + "\n " + "To do good to Mankind is the chivalrous plan, " + "And is always as nobly requited; " + "Then battle for Freedom wherever you can, "
66+ + "And, if not shot or hanged, you'll get knighted." ;
67+
68+ private const String textByron = "When a man hath no freedom to fight for at home,\n " + " Let him combat for that of his neighbours;\n "
69+ + "Let him think of the glories of Greece and of Rome,\n " + " And get knocked on the head for his labours.\n "
70+ + "\n " + "To do good to Mankind is the chivalrous plan,\n " + " And is always as nobly requited;\n "
71+ + "Then battle for Freedom wherever you can,\n " + " And, if not shot or hanged, you'll get knighted." ;
72+
6373 [ NUnit . Framework . OneTimeSetUp ]
6474 public static void BeforeClass ( ) {
6575 CreateOrClearDestinationFolder ( destinationFolder ) ;
@@ -73,10 +83,6 @@ public virtual void BlockWithSetHeightProperties01() {
7383 String outFileName = destinationFolder + "blockWithSetHeightProperties01.pdf" ;
7484 String cmpFileName = sourceFolder + "cmp_blockWithSetHeightProperties01.pdf" ;
7585 PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
76- String textByron = "When a man hath no freedom to fight for at home,\n " + " Let him combat for that of his neighbours;\n "
77- + "Let him think of the glories of Greece and of Rome,\n " + " And get knocked on the head for his labours.\n "
78- + "\n " + "To do good to Mankind is the chivalrous plan,\n " + " And is always as nobly requited;\n "
79- + "Then battle for Freedom wherever you can,\n " + " And, if not shot or hanged, you'll get knighted." ;
8086 Document doc = new Document ( pdfDocument ) ;
8187 Paragraph p = new Paragraph ( textByron ) ;
8288 for ( int i = 0 ; i < 10 ; i ++ ) {
@@ -127,10 +133,6 @@ public virtual void BlockWithSetHeightProperties02() {
127133 String outFileName = destinationFolder + "blockWithSetHeightProperties02.pdf" ;
128134 String cmpFileName = sourceFolder + "cmp_blockWithSetHeightProperties02.pdf" ;
129135 PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
130- String textByron = "When a man hath no freedom to fight for at home,\n " + " Let him combat for that of his neighbours;\n "
131- + "Let him think of the glories of Greece and of Rome,\n " + " And get knocked on the head for his labours.\n "
132- + "\n " + "To do good to Mankind is the chivalrous plan,\n " + " And is always as nobly requited;\n "
133- + "Then battle for Freedom wherever you can,\n " + " And, if not shot or hanged, you'll get knighted." ;
134136 Document doc = new Document ( pdfDocument ) ;
135137 Paragraph p = new Paragraph ( textByron ) ;
136138 Div div = new Div ( ) ;
@@ -177,6 +179,159 @@ public virtual void BlockWithSetHeightProperties02() {
177179 , "diff" ) ) ;
178180 }
179181
182+ /// <exception cref="System.IO.IOException"/>
183+ /// <exception cref="System.Exception"/>
184+ [ NUnit . Framework . Test ]
185+ public virtual void OverflowTest01 ( ) {
186+ // TODO DEVSIX-1373
187+ String outFileName = destinationFolder + "overflowTest01.pdf" ;
188+ String cmpFileName = sourceFolder + "cmp_overflowTest01.pdf" ;
189+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
190+ Document doc = new Document ( pdfDocument ) ;
191+ Paragraph explanation = new Paragraph ( "In this sample iText will not try to fit text in container's width, because overflow property is set. However no text is hidden."
192+ ) ;
193+ doc . Add ( explanation ) ;
194+ Paragraph p = new Paragraph ( textByronNarrow ) ;
195+ p . SetWidth ( 200 ) ;
196+ p . SetBorder ( new SolidBorder ( Color . BLUE , 1 ) ) ;
197+ p . SetProperty ( Property . OVERFLOW_X , OverflowPropertyValue . HIDDEN ) ;
198+ Div div = new Div ( ) ;
199+ div . SetWidth ( 100 ) ;
200+ div . SetBorder ( new SolidBorder ( Color . BLACK , 1 ) ) ;
201+ div . SetProperty ( Property . OVERFLOW_X , OverflowPropertyValue . VISIBLE ) ;
202+ div . Add ( p ) ;
203+ doc . Add ( div ) ;
204+ doc . Close ( ) ;
205+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
206+ , "diff" ) ) ;
207+ }
208+
209+ /// <exception cref="System.IO.IOException"/>
210+ /// <exception cref="System.Exception"/>
211+ [ NUnit . Framework . Test ]
212+ public virtual void OverflowTest02 ( ) {
213+ String outFileName = destinationFolder + "overflowTest02.pdf" ;
214+ String cmpFileName = sourceFolder + "cmp_overflowTest02.pdf" ;
215+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
216+ Document doc = new Document ( pdfDocument ) ;
217+ Paragraph p = new Paragraph ( ) ;
218+ p . SetWidth ( 200 ) ;
219+ p . SetHeight ( 100 ) ;
220+ p . SetBorder ( new SolidBorder ( Color . BLUE , 1 ) ) ;
221+ p . SetBackgroundColor ( Color . YELLOW ) ;
222+ for ( int i = 0 ; i < 10 ; i ++ ) {
223+ p . Add ( textByronNarrow ) ;
224+ }
225+ p . SetProperty ( Property . OVERFLOW_Y , OverflowPropertyValue . VISIBLE ) ;
226+ doc . Add ( p ) ;
227+ doc . Add ( new Paragraph ( "Hello!!!" ) . SetBackgroundColor ( Color . RED ) ) ;
228+ doc . Close ( ) ;
229+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
230+ , "diff" ) ) ;
231+ }
232+
233+ /// <exception cref="System.IO.IOException"/>
234+ /// <exception cref="System.Exception"/>
235+ [ NUnit . Framework . Test ]
236+ public virtual void OverflowTest03 ( ) {
237+ String outFileName = destinationFolder + "overflowTest03.pdf" ;
238+ String cmpFileName = sourceFolder + "cmp_overflowTest03.pdf" ;
239+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
240+ Document doc = new Document ( pdfDocument ) ;
241+ Paragraph p = new Paragraph ( ) ;
242+ p . SetWidth ( 1400 ) ;
243+ p . SetHeight ( 1400 ) ;
244+ p . SetBorder ( new SolidBorder ( Color . BLUE , 1 ) ) ;
245+ p . SetBackgroundColor ( Color . YELLOW ) ;
246+ for ( int i = 0 ; i < 100 ; i ++ ) {
247+ p . Add ( textByronNarrow ) ;
248+ }
249+ p . SetProperty ( Property . OVERFLOW_Y , OverflowPropertyValue . VISIBLE ) ;
250+ p . SetProperty ( Property . OVERFLOW_X , OverflowPropertyValue . VISIBLE ) ;
251+ doc . Add ( p ) ;
252+ doc . Add ( new Paragraph ( "Hello!!!" ) . SetBackgroundColor ( Color . RED ) ) ;
253+ doc . Close ( ) ;
254+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
255+ , "diff" ) ) ;
256+ }
257+
258+ /// <exception cref="System.IO.IOException"/>
259+ /// <exception cref="System.Exception"/>
260+ [ NUnit . Framework . Ignore ( "DEVSIX-1375" ) ]
261+ [ NUnit . Framework . Test ]
262+ public virtual void OverflowTest04 ( ) {
263+ String outFileName = destinationFolder + "overflowTest04.pdf" ;
264+ String cmpFileName = sourceFolder + "cmp_overflowTest04.pdf" ;
265+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
266+ iText . Layout . Element . Image image = new iText . Layout . Element . Image ( ImageDataFactory . Create ( sourceFolder + "Desert.jpg"
267+ ) ) ;
268+ image . SetWidth ( 200 ) ;
269+ Document doc = new Document ( pdfDocument ) ;
270+ Paragraph p = new Paragraph ( ) ;
271+ p . SetRotationAngle ( Math . PI / 2 ) ;
272+ p . SetWidth ( 100 ) ;
273+ p . SetHeight ( 100 ) ;
274+ p . SetBorder ( new SolidBorder ( Color . BLUE , 1 ) ) ;
275+ p . SetProperty ( Property . OVERFLOW_Y , OverflowPropertyValue . VISIBLE ) ;
276+ p . SetProperty ( Property . OVERFLOW_X , OverflowPropertyValue . VISIBLE ) ;
277+ p . Add ( image ) ;
278+ doc . Add ( p ) ;
279+ doc . Add ( new Paragraph ( "Hello!!!" ) . SetBackgroundColor ( Color . RED ) ) ;
280+ doc . Close ( ) ;
281+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
282+ , "diff" ) ) ;
283+ }
284+
285+ /// <exception cref="System.IO.IOException"/>
286+ /// <exception cref="System.Exception"/>
287+ [ NUnit . Framework . Ignore ( "DEVSIX-1373" ) ]
288+ [ NUnit . Framework . Test ]
289+ public virtual void OverflowTest05 ( ) {
290+ String outFileName = destinationFolder + "overflowTest05.pdf" ;
291+ String cmpFileName = sourceFolder + "cmp_overflowTest05.pdf" ;
292+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
293+ Document doc = new Document ( pdfDocument ) ;
294+ Div div = new Div ( ) ;
295+ div . SetWidth ( 100 ) ;
296+ div . SetHeight ( 150 ) ;
297+ div . SetBackgroundColor ( Color . GREEN ) ;
298+ div . SetProperty ( Property . OVERFLOW_X , OverflowPropertyValue . VISIBLE ) ;
299+ div . SetProperty ( Property . OVERFLOW_Y , OverflowPropertyValue . VISIBLE ) ;
300+ List list = new List ( ) ;
301+ list . Add ( "Make Greeeeeeeeeetzky Great Again" ) ;
302+ list . Add ( "Greeeeeeeeeetzky Great Again Make" ) ;
303+ list . Add ( "Great Again Make Greeeeeeeeeetzky" ) ;
304+ list . Add ( "Again Make Greeeeeeeeeetzky Great" ) ;
305+ div . Add ( list ) ;
306+ doc . Add ( div ) ;
307+ doc . Add ( new Paragraph ( "Hello!!!" ) . SetBackgroundColor ( Color . RED ) ) ;
308+ doc . Close ( ) ;
309+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
310+ , "diff" ) ) ;
311+ }
312+
313+ /// <exception cref="System.IO.IOException"/>
314+ /// <exception cref="System.Exception"/>
315+ [ NUnit . Framework . Ignore ( "DEVSIX-1373" ) ]
316+ [ NUnit . Framework . Test ]
317+ public virtual void OverflowTest06 ( ) {
318+ String outFileName = destinationFolder + "overflowTest06.pdf" ;
319+ String cmpFileName = sourceFolder + "cmp_overflowTest06.pdf" ;
320+ PdfDocument pdfDocument = new PdfDocument ( new PdfWriter ( outFileName ) ) ;
321+ Document doc = new Document ( pdfDocument ) ;
322+ Div div = new Div ( ) ;
323+ div . SetWidth ( 100 ) ;
324+ div . SetHeight ( 100 ) ;
325+ div . SetBackgroundColor ( Color . GREEN ) ;
326+ div . SetProperty ( Property . OVERFLOW_Y , OverflowPropertyValue . VISIBLE ) ;
327+ div . Add ( new Paragraph ( textByron ) ) ;
328+ doc . Add ( div ) ;
329+ doc . Add ( new Paragraph ( "Hello!!!" ) . SetBackgroundColor ( Color . RED ) ) ;
330+ doc . Close ( ) ;
331+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outFileName , cmpFileName , destinationFolder
332+ , "diff" ) ) ;
333+ }
334+
180335 /// <exception cref="System.IO.IOException"/>
181336 /// <exception cref="System.Exception"/>
182337 [ NUnit . Framework . Test ]
0 commit comments