FormCreation.java(iText 7)
在這個 iText 7 示例中,我們將建立一個文字欄位,然後將其新增到 PDF:
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 = PdfTextFormField.createText(
pdf, new Rectangle(110, 780, 70, 26), "text", "Text Field")
.setBorderColor(Color.BLUE)
.setBorderWidth(2)
.setColor(Color.RED)
.setFontSize(12);
form.addField(tf);
pdf.close();
}
資料來源: developers.itextpdf.com