Skip to content

Commit 45f468b

Browse files
Add setFont3Ways test
1 parent 6a55637 commit 45f468b

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

forms/src/test/java/com/itextpdf/forms/PdfFormFieldTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,4 +1235,35 @@ private void fillAcroForm(PdfDocument pdfDocument, String text) {
12351235
field.setValue(text);
12361236
}
12371237
}
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+
}
12381269
}
Binary file not shown.

0 commit comments

Comments
 (0)