
I read the pdf that contain of text field and I want to fill this field in the same pdf file that it oppened? what the sutible procedure?
I have the folloing statment but I do not want this can you correct my code depond on my request??? I want read the PDFform.pdf and I want fill the field in PDFform.pdf ( the changing in the same file).... How I can do my request!?
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.AcroFields;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
public class FillText {
public static void main(String[] args) throws IOException,DocumentException
{
editField(); // call methode editField
} // end methode main
private static void editField() throws IOException,FileNotFoundException, DocumentException
{
// read an existing pdf file
PdfReader reader1 = new PdfReader("PDFform.pdf");
// I do not want the chang in the test.pdf .... I want the chang in PDFform.pdf
PdfStamper stamper = new PdfStamper(reader1, new FileOutputStream("test.pdf"));
stamper.getAcroFields().setField("Name", "She is work");
stamper.close();
reader1.close(); } // end methode
} // end class