@@ -41,9 +41,13 @@ source product.
41
41
42
42
*/
43
43
using System ;
44
+ using System . Collections . Generic ;
44
45
using iText . Forms ;
46
+ using iText . Forms . Fields ;
45
47
using iText . Kernel . Colors ;
48
+ using iText . Kernel . Geom ;
46
49
using iText . Kernel . Pdf ;
50
+ using iText . Kernel . Pdf . Annot ;
47
51
using iText . Kernel . Utils ;
48
52
using iText . Test ;
49
53
@@ -75,5 +79,49 @@ public virtual void FillFormWithRotatedFieldAndPageTest() {
75
79
NUnit . Framework . Assert . Fail ( errorMessage ) ;
76
80
}
77
81
}
82
+
83
+ [ NUnit . Framework . Test ]
84
+ public virtual void BorderStyleInCreatedFormFieldsTest ( ) {
85
+ //TODO: update cmp file after fixing DEVSIX-836
86
+ String outPdf = destinationFolder + "borderStyleInCreatedFormFields.pdf" ;
87
+ PdfDocument doc = new PdfDocument ( new PdfWriter ( outPdf ) ) ;
88
+ PdfAcroForm form = PdfAcroForm . GetAcroForm ( doc , true ) ;
89
+ PdfFormField formField1 = PdfTextFormField . CreateText ( doc , new Rectangle ( 100 , 600 , 100 , 50 ) , "firstField" ,
90
+ "Hello, iText!" ) ;
91
+ formField1 . GetWidgets ( ) [ 0 ] . SetBorderStyle ( PdfAnnotation . STYLE_BEVELED ) ;
92
+ formField1 . SetBorderWidth ( 2 ) . SetBorderColor ( ColorConstants . BLUE ) ;
93
+ PdfFormField formField2 = PdfTextFormField . CreateText ( doc , new Rectangle ( 100 , 500 , 100 , 50 ) , "secondField"
94
+ , "Hello, iText!" ) ;
95
+ formField2 . GetWidgets ( ) [ 0 ] . SetBorderStyle ( PdfAnnotation . STYLE_UNDERLINE ) ;
96
+ formField2 . SetBorderWidth ( 2 ) . SetBorderColor ( ColorConstants . BLUE ) ;
97
+ PdfFormField formField3 = PdfTextFormField . CreateText ( doc , new Rectangle ( 100 , 400 , 100 , 50 ) , "thirdField" ,
98
+ "Hello, iText!" ) ;
99
+ formField3 . GetWidgets ( ) [ 0 ] . SetBorderStyle ( PdfAnnotation . STYLE_INSET ) ;
100
+ formField3 . SetBorderWidth ( 2 ) . SetBorderColor ( ColorConstants . BLUE ) ;
101
+ form . AddField ( formField1 ) ;
102
+ form . AddField ( formField2 ) ;
103
+ form . AddField ( formField3 ) ;
104
+ form . FlattenFields ( ) ;
105
+ doc . Close ( ) ;
106
+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outPdf , sourceFolder + "cmp_borderStyleInCreatedFormFields.pdf"
107
+ , destinationFolder ) ) ;
108
+ }
109
+
110
+ [ NUnit . Framework . Test ]
111
+ public virtual void UpdatingBorderStyleInFormFieldsTest ( ) {
112
+ //TODO: update cmp file after fixing DEVSIX-836
113
+ String inputPdf = sourceFolder + "borderStyleInCreatedFormFields.pdf" ;
114
+ String outPdf = destinationFolder + "updatingBorderStyleInFormFields.pdf" ;
115
+ PdfDocument doc = new PdfDocument ( new PdfReader ( inputPdf ) , new PdfWriter ( outPdf ) ) ;
116
+ PdfAcroForm form = PdfAcroForm . GetAcroForm ( doc , false ) ;
117
+ IDictionary < String , PdfFormField > fields = form . GetFormFields ( ) ;
118
+ fields . Get ( "firstField" ) . SetValue ( "New Value 1" ) ;
119
+ fields . Get ( "secondField" ) . SetValue ( "New Value 2" ) ;
120
+ fields . Get ( "thirdField" ) . SetValue ( "New Value 3" ) ;
121
+ form . FlattenFields ( ) ;
122
+ doc . Close ( ) ;
123
+ NUnit . Framework . Assert . IsNull ( new CompareTool ( ) . CompareByContent ( outPdf , sourceFolder + "cmp_updatingBorderStyleInFormFields.pdf"
124
+ , destinationFolder ) ) ;
125
+ }
78
126
}
79
127
}
0 commit comments