@@ -43,6 +43,7 @@ This file is part of the iText (R) project.
43
43
package com .itextpdf .layout ;
44
44
45
45
46
+ import com .itextpdf .io .LogMessageConstant ;
46
47
import com .itextpdf .io .image .ImageDataFactory ;
47
48
import com .itextpdf .kernel .color .Color ;
48
49
import com .itextpdf .kernel .geom .Rectangle ;
@@ -62,6 +63,8 @@ This file is part of the iText (R) project.
62
63
import com .itextpdf .layout .property .Property ;
63
64
import com .itextpdf .layout .property .UnitValue ;
64
65
import com .itextpdf .test .ExtendedITextTest ;
66
+ import com .itextpdf .test .annotations .LogMessage ;
67
+ import com .itextpdf .test .annotations .LogMessages ;
65
68
import com .itextpdf .test .annotations .type .IntegrationTest ;
66
69
import org .junit .Assert ;
67
70
import org .junit .BeforeClass ;
@@ -434,7 +437,7 @@ public void floatingImageInParagraph() throws IOException, InterruptedException
434
437
435
438
document .close ();
436
439
437
- Assert .assertNull (new CompareTool ().compareByContent (outFile , cmpFileName , destinationFolder , "diff10_ " ));
440
+ Assert .assertNull (new CompareTool ().compareByContent (outFile , cmpFileName , destinationFolder , "diff11_ " ));
438
441
}
439
442
440
443
@ Test
@@ -472,7 +475,66 @@ public void floatsOnCanvas() throws IOException, InterruptedException {
472
475
canvas .close ();
473
476
pdfDoc .close ();
474
477
475
- Assert .assertNull (new CompareTool ().compareByContent (outFile , cmpFileName , destinationFolder , "diff10_" ));
478
+ Assert .assertNull (new CompareTool ().compareByContent (outFile , cmpFileName , destinationFolder , "diff12_" ));
479
+ }
480
+
481
+ @ Test
482
+ @ LogMessages (messages = @ LogMessage (messageTemplate = LogMessageConstant .CLIP_ELEMENT , count = 3 ))
483
+ public void floatFixedHeightContentNotFit () throws IOException , InterruptedException {
484
+ String cmpFileName = sourceFolder + "cmp_floatFixedHeightContentNotFit.pdf" ;
485
+ String outFile = destinationFolder + "floatFixedHeightContentNotFit.pdf" ;
486
+
487
+ Document document = new Document (new PdfDocument (new PdfWriter (outFile )));
488
+
489
+ Div div = new Div ().setBorder (new SolidBorder (Color .RED , 2 ));
490
+ div .add (new Paragraph ("Floating div." )).add (new Paragraph (text ));
491
+ div .setHeight (200 ).setWidth (100 );
492
+ div .setProperty (Property .FLOAT , FloatPropertyValue .RIGHT );
493
+ document .add (div );
494
+ document .add (new Paragraph (text ));
495
+
496
+ Paragraph p = new Paragraph ("Floating p.\n " + text ).setBorder (new SolidBorder (Color .RED , 2 ));
497
+ p .setHeight (200 ).setWidth (100 );
498
+ p .setProperty (Property .FLOAT , FloatPropertyValue .RIGHT );
499
+ document .add (p );
500
+ document .add (new Paragraph (text ));
501
+
502
+ Table table = new Table (UnitValue .createPercentArray (new float []{0.3f , 0.7f })).setBorder (new SolidBorder (Color .RED , 2 ));
503
+ table .addCell (new Paragraph ("Floating table." )).addCell (new Paragraph (text ));
504
+ table .setHeight (200 ).setWidth (300 );
505
+ table .setProperty (Property .FLOAT , FloatPropertyValue .RIGHT );
506
+ document .add (table );
507
+ document .add (new Paragraph (text ));
508
+
509
+ document .close ();
510
+
511
+ Assert .assertNull (new CompareTool ().compareByContent (outFile , cmpFileName , destinationFolder , "diff13_" ));
512
+ }
513
+
514
+ @ Test
515
+ public void clearanceApplyingPageSplit () throws IOException , InterruptedException {
516
+ String cmpFileName = sourceFolder + "cmp_clearanceApplyingPageSplit.pdf" ;
517
+ String outFile = destinationFolder + "clearanceApplyingPageSplit.pdf" ;
518
+
519
+ Document document = new Document (new PdfDocument (new PdfWriter (outFile )));
520
+
521
+ document .add (new Paragraph (text ));
522
+
523
+ Div div = new Div ().setBorder (new SolidBorder (Color .RED , 2 ));
524
+ div .add (new Paragraph ("Floating div." ));
525
+ div .setHeight (200 ).setWidth (100 );
526
+ div .setProperty (Property .FLOAT , FloatPropertyValue .RIGHT );
527
+ document .add (div );
528
+
529
+ Div divClear = new Div ().setBackgroundColor (Color .GREEN );
530
+ divClear .add (new Paragraph ("Cleared div." )).add (new Paragraph (text ));
531
+ divClear .setHeight (400 );
532
+ divClear .setProperty (Property .CLEAR , ClearPropertyValue .BOTH );
533
+ document .add (divClear );
534
+
535
+ document .close ();
536
+
537
+ Assert .assertNull (new CompareTool ().compareByContent (outFile , cmpFileName , destinationFolder , "diff13_" ));
476
538
}
477
539
478
540
}
0 commit comments