iText - PDF字典中的TU条目

我在Java中有以下代码 . 如何创建PDF词典并向其添加TU条目?我有一个PdFReader,Acrofields和PdfStamper的实例 . 它目前正在打印字段名称 . 我正在尝试添加TU条目,以便我可以更改字段名称 .

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

   }    
  }

回答(0)