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=click
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions