2016-12-20 2 views
0

Извините за мой английский .... Используя sluduyuschy код, я хочу добавить поле в документе PDF, что оно было комбинацией нескольких символов и было заполнено, но оно становится комбинацией сразу после того, как я нажму на него от читателя Adober или снова заполните его с Adobe Reader. Это видеть, как enter image description here, только тогда, когда я нажимаю, что увидеть хороший enter image description here Что я делаю неправильноAcroForm гребень TextField в Itextpdf7

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

попытку установить myAcro.setNeedAppearances(true);

+0

он работал. Большое спасибо. Как долго я страдал, теперь я понимаю, как мало моих знаний. –

Смежные вопросы