For that to work you must have a pdf with a field named "ENCROACHMENT". Do
you?

----- Original Message ----- 
From: "Kandula, Ravi" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, February 11, 2005 7:05 PM
Subject: [iText-questions] Inserting text into pdf and create new one


Hi,

I am trying to read a template PDF file and replace the some tags with
actual data and create a new pdf file using itext.
I am using Acroform and acrofields for this. Below is the program I had
written for accomplishing this. When I tried to the no of fields it gave
me 0 and it is not changing value of tag.

Is this the correct way of reading a template pdf using acroform.

If so am I doing wrong any where.
Any help on this would be appreciated.



import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
Import java.util.*;

public class EncroachTemplate {

public static void main(String[] args) {

  System.out.println("Starting to read pdf template and build
new pdf");

     try
     {
  PdfReader reader = new
PdfReader("c:/pdfwriter/General_Encroachment_Test.pdf ");
        PdfStamper stamp = new PdfStamper(reader, new
FileOutputStream("Test.pdf"));

        AcroFields form = stamp.getAcroFields();
        HashMap formfields = form.getFields();

  System.out.println(" No of fields "+formfields.size() );

    if(formfields.size>0)
           //set the field values in the pdf form
           form.setField("ENCROACHMENT","TEST");


         stamp.setFormFlattening(true);
         stamp.close();
}catch(Exception e){System.out.println("Error: " + e); }

}
}

Thanks


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=ick
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to