itext Forms: iText 5 vs iText 7 FormFilling.java (iText 5)


Example

In this iText 5 example, we'll change the properties and the value of a text field:

enter image description here

public void manipulatePdf(String src, String dest) throws DocumentException, IOException {
    PdfReader reader = new PdfReader(src);
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
    AcroFields fields = stamper.getAcroFields();
    fields.setFieldProperty("text", "textcolor", BaseColor.BLUE, null);
    fields.setFieldProperty("text", "bordercolor", BaseColor.RED, null);
    fields.setFieldProperty("text", "fontsize", 14, null);
    fields.setField("text", "Field Text");
    stamper.close();
    reader.close();
}

Source: developers.itextpdf.com