@@ -64,6 +64,8 @@ This file is part of the iText (R) project.
64
64
import com .itextpdf .kernel .pdf .canvas .PdfCanvas ;
65
65
import com .itextpdf .kernel .utils .CompareTool ;
66
66
import com .itextpdf .layout .Canvas ;
67
+ import com .itextpdf .layout .Document ;
68
+ import com .itextpdf .layout .element .AreaBreak ;
67
69
import com .itextpdf .layout .element .Paragraph ;
68
70
import com .itextpdf .test .ExtendedITextTest ;
69
71
import com .itextpdf .test .annotations .LogMessage ;
@@ -887,4 +889,34 @@ public void regenerateMaxLenCombTest() throws IOException, InterruptedException
887
889
Assert .fail (errorMessage );
888
890
}
889
891
}
892
+
893
+ @ Test
894
+ public void wrapPrecedingContentOnFlattenTest () throws IOException , InterruptedException {
895
+ String filename = destinationFolder + "wrapPrecedingContentOnFlattenTest.pdf" ;
896
+ PdfDocument pdfDoc = new PdfDocument (new PdfWriter (filename ));
897
+ PdfCanvas canvas = new PdfCanvas (pdfDoc .addNewPage ());
898
+ canvas .setFillColor (ColorConstants .MAGENTA );
899
+
900
+ PdfAcroForm form = PdfAcroForm .getAcroForm (pdfDoc , true );
901
+ PdfTextFormField [] fields = new PdfTextFormField [4 ];
902
+ for (int i = 0 ; i < 4 ; i ++)
903
+ fields [i ] = PdfFormField .createText (pdfDoc , new Rectangle (90 , 700 - i * 100 , 150 , 22 ), "black" + i , "black" );
904
+ form .addField (fields [0 ]);
905
+ form .addField (fields [1 ]);
906
+ Document doc = new Document (pdfDoc );
907
+ doc .add (new AreaBreak ());
908
+ canvas = new PdfCanvas (pdfDoc .getPage (2 ));
909
+ canvas .setFillColor (ColorConstants .CYAN );
910
+ form .addField (fields [2 ]);
911
+ form .addField (fields [3 ], pdfDoc .getFirstPage ());
912
+ form .flattenFields ();
913
+
914
+ pdfDoc .close ();
915
+
916
+ CompareTool compareTool = new CompareTool ();
917
+ String errorMessage = compareTool .compareByContent (filename , sourceFolder + "cmp_wrapPrecedingContentOnFlattenTest.pdf" , destinationFolder , "diff_" );
918
+ if (errorMessage != null ) {
919
+ Assert .fail (errorMessage );
920
+ }
921
+ }
890
922
}
0 commit comments