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


Example

In this iText 7 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 IOException {
    PdfReader reader = new PdfReader(src);
    PdfDocument pdf = new PdfDocument(reader, new PdfWriter(dest));
    PdfAcroForm form = PdfAcroForm.getAcroForm(pdf, true);
    PdfFormField tf = form.getFormFields().get("text");
    tf.setBorderColor(Color.RED)
        .setColor(Color.BLUE)
        .setFontSize(14)
        .setValue("Field Text");
    pdf.close();
}

Source: developers.itextpdf.com