@@ -361,59 +361,50 @@ public void wordSplitAcrossMultipleRenderersOverflowXVisible() throws IOExceptio
361
361
}
362
362
363
363
@ Test
364
- public void wordSplitAcrossMutipleTextRenderersWithinFloatingContainer () throws IOException , InterruptedException {
365
- String outFileName = destinationFolder + "wordSplitAcrossMutipleTextRenderersWithinFloatingContainer .pdf" ;
366
- String cmpFileName = sourceFolder + "cmp_wordSplitAcrossMutipleTextRenderersWithinFloatingContainer .pdf" ;
364
+ public void wordSplitRenderersWithFittingFloatingElementInBetween () throws IOException , InterruptedException {
365
+ String outFileName = destinationFolder + "wordSplitRenderersWithFittingFloatingElementInBetween .pdf" ;
366
+ String cmpFileName = sourceFolder + "cmp_wordSplitRenderersWithFittingFloatingElementInBetween .pdf" ;
367
367
368
368
PdfDocument pdfDocument = new PdfDocument (new PdfWriter (outFileName ));
369
369
Document doc = new Document (pdfDocument );
370
370
371
371
doc .setFontSize (20 );
372
372
373
- Text oooooooooover = new Text ("oooooooooover" )
374
- .setFontColor (ColorConstants .LIGHT_GRAY );
375
- Text flooooo = new Text ("flooooo" )
376
- .setFontColor (ColorConstants .GRAY );
377
- Text ooooowNextWords = new Text ("ooooow next words" )
378
- .setFontColor (ColorConstants .DARK_GRAY );
373
+ Text reg = new Text ("reg" ).setFontColor (ColorConstants .LIGHT_GRAY );
374
+ Text ul = new Text ("ul" ).setFontColor (ColorConstants .DARK_GRAY );
375
+ Text aaaaaaaaaaaaaaaaaaaaaaati = new Text ("aaaaaaaaaaaaaaaaaaaaaaati" ).setFontColor (ColorConstants .GRAY );
376
+ Text ngAndRestOfText = new Text ("ng overflow text renderers with floating elements between them" )
377
+ .setFontColor (ColorConstants .RED );
379
378
380
- Paragraph floatingParagraph = new Paragraph ()
381
- .add (oooooooooover )
382
- .add (flooooo )
383
- .add (ooooowNextWords )
379
+
380
+ Div floatDiv = new Div ().setWidth (20 ).setHeight (60 )
381
+ .setBackgroundColor (ColorConstants .LIGHT_GRAY )
382
+ .setBorder (new SolidBorder (2 ));
383
+ floatDiv .setProperty (Property .FLOAT , FloatPropertyValue .RIGHT );
384
+
385
+ Paragraph p = new Paragraph ()
386
+ .add (reg )
387
+ .add (ul )
388
+ .add (floatDiv )
389
+ .add (aaaaaaaaaaaaaaaaaaaaaaati )
390
+ .add (ngAndRestOfText )
384
391
.setBackgroundColor (ColorConstants .CYAN )
385
392
.setWidth (150 )
386
393
.setBorder (new SolidBorder (1 ));
387
- // TODO DEVSIX-1438 bring reviewer's attention: if overflow is set on the div, then forced split occurs.
388
- // is it expected?
389
- floatingParagraph .setProperty (Property .OVERFLOW_X , OverflowPropertyValue .VISIBLE );
390
- floatingParagraph .setProperty (Property .FLOAT , FloatPropertyValue .RIGHT );
391
-
392
- Text regularText = new Text ("regular words regular words regular words regular words regular words regular " +
393
- "words regular words regular words regular words" );
394
- Paragraph regularParagraph = new Paragraph (regularText )
395
- .setBackgroundColor (ColorConstants .MAGENTA );
396
-
397
- Div div = new Div ()
398
- .add (floatingParagraph )
399
- .add (regularParagraph )
400
- .setMaxWidth (300 )
401
- .setHeight (300 )
402
- .setBackgroundColor (ColorConstants .YELLOW );
403
-
404
- div .setProperty (Property .RENDERING_MODE , RenderingMode .HTML_MODE );
405
394
406
- doc .add (div );
395
+ p .setProperty (Property .OVERFLOW_X , OverflowPropertyValue .VISIBLE );
396
+ doc .setProperty (Property .RENDERING_MODE , RenderingMode .HTML_MODE );
407
397
398
+ doc .add (p );
408
399
doc .close ();
409
400
410
401
Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder ));
411
402
}
412
403
413
404
@ Test
414
- public void wordSplitRenderersWithFloatingElementInsertedInBetween () throws IOException , InterruptedException {
415
- String outFileName = destinationFolder + "wordSplitRenderersWithFloatingElementInsertedInBetween .pdf" ;
416
- String cmpFileName = sourceFolder + "cmp_wordSplitRenderersWithFloatingElementInsertedInBetween .pdf" ;
405
+ public void wordSplitRenderersWithNotFittingFloatingElementInBetween () throws IOException , InterruptedException {
406
+ String outFileName = destinationFolder + "wordSplitRenderersWithNotFittingFloatingElementInBetween .pdf" ;
407
+ String cmpFileName = sourceFolder + "cmp_wordSplitRenderersWithNotFittingFloatingElementInBetween .pdf" ;
417
408
418
409
PdfDocument pdfDocument = new PdfDocument (new PdfWriter (outFileName ));
419
410
Document doc = new Document (pdfDocument );
@@ -437,7 +428,6 @@ public void wordSplitRenderersWithFloatingElementInsertedInBetween() throws IOEx
437
428
.setWidth (150 )
438
429
.setBorder (new SolidBorder (1 ));
439
430
440
- // todo mention that it's crucial to set both overflow and rendering_mode!!!
441
431
paragraph .setProperty (Property .OVERFLOW_X , OverflowPropertyValue .VISIBLE );
442
432
paragraph .setProperty (Property .RENDERING_MODE , RenderingMode .HTML_MODE );
443
433
@@ -448,6 +438,139 @@ public void wordSplitRenderersWithFloatingElementInsertedInBetween() throws IOEx
448
438
Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder ));
449
439
}
450
440
441
+ @ Test
442
+ public void wordSplitRenderersWithFittingFloatingInBetweenInSecondWord () throws IOException , InterruptedException {
443
+ String outFileName = destinationFolder + "wordSplitRenderersWithFittingFloatingInBetweenInSecondWord.pdf" ;
444
+ String cmpFileName = sourceFolder + "cmp_wordSplitRenderersWithFittingFloatingInBetweenInSecondWord.pdf" ;
445
+
446
+ PdfDocument pdfDocument = new PdfDocument (new PdfWriter (outFileName ));
447
+ Document doc = new Document (pdfDocument );
448
+
449
+ doc .setFontSize (20 );
450
+
451
+ Text itsAndSpace = new Text ("It's " );
452
+ Text reg = new Text ("reg" ).setFontColor (ColorConstants .LIGHT_GRAY );
453
+ Text ul = new Text ("ul" ).setFontColor (ColorConstants .DARK_GRAY );
454
+ Text aaaaaaaaaaaaaaaaaaaaaaati = new Text ("aaaaaaaaaaaaaaaaaaaaaaati" ).setFontColor (ColorConstants .GRAY );
455
+ Text ngAndRestOfText = new Text ("ng overflow text renderers with floating elements between them" )
456
+ .setFontColor (ColorConstants .RED );
457
+
458
+
459
+ Div floatDiv = new Div ().setWidth (20 ).setHeight (60 )
460
+ .setBackgroundColor (ColorConstants .LIGHT_GRAY )
461
+ .setBorder (new SolidBorder (2 ));
462
+ floatDiv .setProperty (Property .FLOAT , FloatPropertyValue .RIGHT );
463
+
464
+ Paragraph p = new Paragraph ()
465
+ .add (itsAndSpace )
466
+ .add (reg )
467
+ .add (ul )
468
+ .add (floatDiv )
469
+ .add (aaaaaaaaaaaaaaaaaaaaaaati )
470
+ .add (ngAndRestOfText )
471
+ .setBackgroundColor (ColorConstants .CYAN )
472
+ .setWidth (150 )
473
+ .setBorder (new SolidBorder (1 ));
474
+
475
+ p .setProperty (Property .OVERFLOW_X , OverflowPropertyValue .VISIBLE );
476
+ doc .setProperty (Property .RENDERING_MODE , RenderingMode .HTML_MODE );
477
+
478
+ doc .add (p );
479
+
480
+ doc .close ();
481
+
482
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder ));
483
+ }
484
+
485
+ @ Test
486
+ public void wordSplitRenderersWithOverflowedFloatingElementInBetween () throws IOException , InterruptedException {
487
+ String outFileName = destinationFolder + "wordSplitRenderersWithOverflowedFloatingElementInBetween.pdf" ;
488
+ String cmpFileName = sourceFolder + "cmp_wordSplitRenderersWithOverflowedFloatingElementInBetween.pdf" ;
489
+
490
+ PdfDocument pdfDocument = new PdfDocument (new PdfWriter (outFileName ));
491
+ Document doc = new Document (pdfDocument );
492
+
493
+ doc .setFontSize (20 );
494
+
495
+ Text reg = new Text ("reg" ).setFontColor (ColorConstants .LIGHT_GRAY );
496
+ Text ul = new Text ("ul" ).setFontColor (ColorConstants .DARK_GRAY );
497
+ Text aaaaaaaaaaaaaaaaaaaaaaati = new Text ("aaaaaaaaaaaaaaaaaaaaaaati" ).setFontColor (ColorConstants .GRAY );
498
+ Text ngAndRestOfText = new Text ("ng overflow text renderers with floating elements between them" )
499
+ .setFontColor (ColorConstants .RED );
500
+
501
+
502
+ Div floatDiv = new Div ().setWidth (20 ).setHeight (60 )
503
+ .setBackgroundColor (ColorConstants .LIGHT_GRAY )
504
+ .setBorder (new SolidBorder (2 ));
505
+ floatDiv .setProperty (Property .FLOAT , FloatPropertyValue .RIGHT );
506
+
507
+ Paragraph p = new Paragraph ()
508
+ .add (reg )
509
+ .add (ul )
510
+ .add (aaaaaaaaaaaaaaaaaaaaaaati )
511
+ .add (floatDiv )
512
+ .add (ngAndRestOfText )
513
+ .setBackgroundColor (ColorConstants .CYAN )
514
+ .setWidth (150 )
515
+ .setBorder (new SolidBorder (1 ));
516
+
517
+ p .setProperty (Property .OVERFLOW_X , OverflowPropertyValue .VISIBLE );
518
+ doc .setProperty (Property .RENDERING_MODE , RenderingMode .HTML_MODE );
519
+
520
+ doc .add (p );
521
+ doc .close ();
522
+
523
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder ));
524
+ }
525
+
526
+ @ Test
527
+ public void wordSplitAcrossMutipleTextRenderersWithinFloatingContainer () throws IOException , InterruptedException {
528
+ String outFileName = destinationFolder + "wordSplitAcrossMutipleTextRenderersWithinFloatingContainer.pdf" ;
529
+ String cmpFileName = sourceFolder + "cmp_wordSplitAcrossMutipleTextRenderersWithinFloatingContainer.pdf" ;
530
+
531
+ PdfDocument pdfDocument = new PdfDocument (new PdfWriter (outFileName ));
532
+ Document doc = new Document (pdfDocument );
533
+
534
+ doc .setFontSize (20 );
535
+
536
+ Text oooooooooover = new Text ("oooooooooover" )
537
+ .setFontColor (ColorConstants .LIGHT_GRAY );
538
+ Text flooooo = new Text ("flooooo" )
539
+ .setFontColor (ColorConstants .GRAY );
540
+ Text ooooowNextWords = new Text ("ooooow next words" )
541
+ .setFontColor (ColorConstants .DARK_GRAY );
542
+
543
+ Paragraph floatingParagraph = new Paragraph ()
544
+ .add (oooooooooover )
545
+ .add (flooooo )
546
+ .add (ooooowNextWords )
547
+ .setBackgroundColor (ColorConstants .CYAN )
548
+ .setWidth (150 )
549
+ .setBorder (new SolidBorder (1 ));
550
+ floatingParagraph .setProperty (Property .OVERFLOW_X , OverflowPropertyValue .VISIBLE );
551
+ floatingParagraph .setProperty (Property .FLOAT , FloatPropertyValue .RIGHT );
552
+
553
+ Text regularText = new Text ("regular words regular words regular words regular words regular words regular " +
554
+ "words regular words regular words regular words" );
555
+ Paragraph regularParagraph = new Paragraph (regularText )
556
+ .setBackgroundColor (ColorConstants .MAGENTA );
557
+
558
+ Div div = new Div ()
559
+ .add (floatingParagraph )
560
+ .add (regularParagraph )
561
+ .setMaxWidth (300 )
562
+ .setHeight (300 )
563
+ .setBackgroundColor (ColorConstants .YELLOW );
564
+
565
+ div .setProperty (Property .RENDERING_MODE , RenderingMode .HTML_MODE );
566
+
567
+ doc .add (div );
568
+
569
+ doc .close ();
570
+
571
+ Assert .assertNull (new CompareTool ().compareByContent (outFileName , cmpFileName , destinationFolder ));
572
+ }
573
+
451
574
@ Test
452
575
public void wordSplitAcrossRenderersWithPrecedingImageRenderer () throws IOException , InterruptedException {
453
576
String outFileName = destinationFolder + "wordSplitAcrossRenderersWithPrecedingImageRenderer.pdf" ;
0 commit comments