FormFilling.java(iText 5)

在這個 iText 5 示例中,我們將更改文字欄位的屬性和值:

StackOverflow 文件

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();
}

資料來源: developers.itextpdf.com