Filling Pdf Form Problem
- From: "Paulo Soares" <psoares (at) consiste.pt>
- Date: Thu, 15 Jun 2006 16:39:41 +0100
Post the PDF.
Paulo
----- Original Message -----
From: <ravi.bhatt (at) tcs.com>
To: <itext-questions (at) lists.sourceforge.net>
Sent: Thursday, June 15, 2006 2:45 PM
Subject: [iText-questions] Filling Pdf Form Problem
> Hi,
>
> I need to create a new PDF from an existing PDF that contains PDF form. I
> need to fill the data into the form dynamically.
> The code creates a new PDF nicely. but when i open the new file with PDF
> reader ( i am using acrobat reader 7.0), i get the following error
>
> "Wrong type parameter supplied to a PDS procedure."
>
> After this error the document opens up with filled in data. Now, when i
> print the file, PDF reader crashes.
>
> I am using iText 1.4.
>
> The code that i am using is:-
>
> /**
> * Fills data into an existing pdf form.
> * (at) param fileToRead The Pdf file to be filled.
> * (at) param fileToWrite The Pdf file to be created.
> * (at) param formData HashMap containing field names and values.
> */
> public static void fillPdfForm(String fileToRead,String
> fileToWrite,HashMap formData)
> {
> try
> {
> PdfReader reader = new PdfReader(fileToRead);
> PdfStamper stamp1 = new PdfStamper(reader,
> new FileOutputStream(fileToWrite));
> stamp1.setEncryption(true,null,null,PdfWriter.AllowPrinting);
> AcroFields form2=stamp1.getAcroFields();
>
> HashMap fields = form2.getFields();
>
> Set keys = formData.keySet();
>
> for(Iterator i
> =keys.iterator();i.hasNext();)
> {
> String key = (String)i.next();
> System.out.println("key =" + key);
> if(fields.containsKey(key))
> {
> String value =
> (String)formData.get(key);
> System.out.println("value
> =" + value);
> form2.setField(key,value,value);
> }
> }
> stamp1.setFormFlattening(true);
> stamp1.close();
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> }
>
> Regards,
> Ravi Mukund Bhatt
> Tata Consultancy Services Limited
> Mailto: ravi.bhatt (at) tcs.com
> Website: http://www.tcs.com
> ForwardSourceID:NT0000509A
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>
--------------------------------------------------------------------------------
>
--------------------------------------------------------------------------------
> _______________________________________________
> iText-questions mailing list
> iText-questions (at) lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
_______________________________________________
iText-questions mailing list
iText-questions (at) lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions