@@ -1235,4 +1235,35 @@ private void fillAcroForm(PdfDocument pdfDocument, String text) {
1235
1235
field .setValue (text );
1236
1236
}
1237
1237
}
1238
+
1239
+ @ Test
1240
+ public void setFont3Ways () throws IOException , InterruptedException {
1241
+ String filename = destinationFolder + "setFont3Ways.pdf" ;
1242
+ String cmpFilename = sourceFolder + "cmp_setFont3Ways.pdf" ;
1243
+ String testString = "Don't cry over spilt milk" ;
1244
+
1245
+ PdfDocument pdfDocument = new PdfDocument (new PdfWriter (filename ));
1246
+ PdfAcroForm form = PdfAcroForm .getAcroForm (pdfDocument , true );
1247
+
1248
+ PdfFont font = PdfFontFactory .createFont (sourceFolder + "SILEOT.ttf" , PdfEncodings .IDENTITY_H );
1249
+
1250
+ Rectangle rect1 = new Rectangle (10 , 700 , 200 , 25 );
1251
+ Rectangle rect2 = new Rectangle (30 , 600 , 200 , 25 );
1252
+ Rectangle rect3 = new Rectangle (50 , 500 , 200 , 25 );
1253
+
1254
+ PdfButtonFormField pushButton1 = PdfFormField .createPushButton (pdfDocument , rect1 , "Name1" , testString , font , 12 );
1255
+ form .addField (pushButton1 );
1256
+
1257
+ PdfButtonFormField pushButton2 = PdfFormField .createPushButton (pdfDocument , rect2 , "Name2" , testString );
1258
+ pushButton2 .setFontAndSize (font , 12f );
1259
+ form .addField (pushButton2 );
1260
+
1261
+ PdfButtonFormField pushButton3 = PdfFormField .createPushButton (pdfDocument , rect3 , "Name3" , testString );
1262
+ pushButton3 .setFont (font ).setFontSize (12 );
1263
+ form .addField (pushButton3 );
1264
+
1265
+ pdfDocument .close ();
1266
+
1267
+ Assert .assertNull (new CompareTool ().compareByContent (filename , cmpFilename , destinationFolder , "diff_" ));
1268
+ }
1238
1269
}
0 commit comments