iText - 使用方括号将字段名称转换为不带方括号的字段?

时间:2014-10-17 23:30:36

标签: itext xfa

import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.AcroFields;
import com.itextpdf.text.pdf.PdfStamper;
import java.util.Set;
import java.io.FileOutputStream;

public class PDFFile {


 public static final String xfaForm3 = "C:/PDF_Service/pdf-project/src/sample.pdf";
 public static final String dest = "sample2.xml";

  public static void main(String[] args) 
  {

    PdfReader reader; 
    PdfReader.unethicalreading = true;
    AcroFields form;

    try{

       reader = new PdfReader(xfaForm3);
       PdfStamper stamper2 = new PdfStamper(reader, new FileOutputStream(dest));
       form = stamper2.getAcroFields();
       stamper2.close();
       Set<String> fldNames = form.getFields().keySet();


      for (String fldName : fldNames) 

      {

        System.out.println( fldName +  " : " + form.getField( fldName ) );

       }


      }
      catch(Exception e)
      {
        e.printStackTrace();

       }    
   }

}

上面的代码是读取具有XFA格式的PDF文件,并打印出如下所示的内容:

F [0] .P1 [0] .FFField1 [14]:11 Pine Drive

不是打印出“F [0] .P1 [0] .FFField1 [14]”,而是如何打印出“地址”?

我希望我的代码打印出来:

地址:11 Pine Drive

0 个答案:

没有答案