Hi,

I have form with fields and want to fill data from DB.I have the following 
code, but when I read the new create pdf form, the field doesn't show the value 
that I put it.
This code create an identical pdf file as the original, but the field name is 
still in blank.

I went through the mailing list and still could not find the solution.

---------------------------------------------------------------------------------------------
import com.lowagie.text.pdf.*;
import com.lowagie.text.DocumentException;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;

public class PDFServlet
{

        public static void main(String args[])
        {
                try
                {

                        PdfReader reader = new PdfReader("Application.pdf");
                        PdfDictionary acro = 
(PdfDictionary)PdfReader.getPdfObject(reader.getCatalog().get(PdfName.ACROFORM));

                        if(acro !=null)
                        {
                                acro.remove(new PdfName("XFA"));
                                System.out.println("Read2");
                        }

                        PdfStamper stamp = new PdfStamper(reader, new 
FileOutputStream("aNewPDF.pdf"));

                        stamp.setFormFlattening(true);
                        AcroFields af = stamp.getAcroFields();
                        HashMap f = new HashMap();
                        f = af.getFields();


                        System.out.println(" No of fields "+f.size() );//ALWAYS 
SHOWS '0' on my console

                        for (Iterator it = f.keySet().iterator(); it.hasNext();)
                        {
                                System.out.println("in the loop");
                        String name = (String)it.next();
                        System.out.println("Field is " + name);
                        af.setField(name,"1234");
                        }

                //stamp.setFormFlattening(true);
                stamp.close();
                }
                catch(Exception e)
                {
                        System.out.println("Exception is -->"+e);
                }
        }
}
--------------------------------------------------------------------------------------------

Please let me know where i'm making mistake. 

Thanks in advance.

-Kiran
-- 
_______________________________________________
NEW! Lycos Dating Search. The only place to search multiple dating sites at 
once.
http://datingsearch.lycos.com



-------------------------------------------------------
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

Reply via email to