Last active
January 13, 2018 06:55
-
-
Save bjpeterdelacruz/f76795db2e2a84fd566995ccee8f6d73 to your computer and use it in GitHub Desktop.
How to set font size of field using iText 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void setFirstNameField(AcroFields form) throws IOException, DocumentException { | |
// Set font size. | |
form.setFieldProperty("first_name", "textsize", 10f, null); | |
// Set font to use. | |
final BaseFont font = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.EMBEDDED); | |
form.setFieldProperty("first_name", "textfont", font, null); | |
// The font size must be set first before setting the value of the field. | |
form.setField("first_name", value); | |
form.setFieldProperty("first_name", "setfflags", PdfFormField.FF_READ_ONLY, null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment