对不起我的英文...... 使用sluduyuschy代码,我想在PDF文档中添加一个字段,它已经是几个字符的组合,并且被填充,但它变成了我从Adober阅读器点击它或从Adobe填写它之后的组合读者再次。 这看作enter image description here,只有当我点击看到好enter image description here时 我做错了什么
public class TestClass {
public static void main(String[] args) throws IOException {
PdfWriter writer = new PdfWriter("D:\\TestPdf.pdf");
PdfDocument pdf = new PdfDocument(writer);
PdfAcroForm myAcro = PdfAcroForm.getAcroForm(pdf,true);
pdf.addNewPage();
PdfFormField text = PdfFormField.createText(pdf,new Rectangle(0f,800f,200f,50f),"textValue","")
.setFileSelect(false) //Meaningful only if the MaxLen entry is present in the text field dictionary and if the Multiline, Password, and FileSelect flags are clear. If true, the field is automatically divided into as many equally spaced positions, or combs, as the value of MaxLen, and the text is laid out into those combs.
.setMultiline(false)
.setPassword(false)
.setMaxLen(5)
.setComb(true);
text.setValue("What not good!");
text.regenerateField();
myAcro.addField(text);
pdf.close();
}
答案 0 :(得分:0)
尝试设置myAcro.setNeedAppearances(true);