Thanks Paulo and Adam.
I got all the field names, inserted the variables from the XML file.
Very cool!


Jim Sloey

-----Original Message-----
From: Paulo Soares [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 23, 2005 1:40 PM
To: [EMAIL PROTECTED]; Sloey, James
Cc: [email protected]
Subject: RE: [iText-questions] Retrieving all fields from a PDF form

I'm not sure what is your question/problem. 

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Adam

> T. Gautier
> Sent: Monday, May 23, 2005 9:48 PM
> To: Sloey, James
> Cc: [email protected]
> Subject: Re: [iText-questions] Retrieving all fields from a PDF form
> 
> I use the seperate vunctions because you will get an exception if you 
> need to delete a field which I did.
> 
> try:
> 
> mport com.lowagie.text.pdf.*;
> import java.io.*;
> import java.util.*;
> 
> public class PDFListFields {
> 
>     public final static Collection getFieldNames(AcroFields fields)
>         throws Exception {
>         Collection names = new Vector();
>         Map map = fields.getFields();
>         Iterator field_names = map.keySet().iterator();
>         while(field_names.hasNext()) {
>             String field_name = (String)field_names.next();
>             names.add(field_name);
>         }
>         return names;
>     }
> 
>     public final static void main(String[] args) {
>         try {
>             PdfReader reader = new PdfReader(args[0]);
>             AcroFields fields = reader.getAcroFields();
>             Iterator field_names = getFieldNames(fields).iterator();
>             while(field_names.hasNext()) {
>                 String field_name = (String)field_names.next();
>                 System.out.println(field_name);
>             }
>             reader.close();
>             System.exit(0);
>         } catch(Exception e) {
>             e.printStackTrace();
>             System.exit(1);
>         }
>     }
> }
> 
> 
>  all the form field names from a PDF file? I
> > have to retrieve an unknown number of form fields from a
> PDF template
> > and fill in the matching fields with data from an XML file.
> >
> > I tried using...
> >
> > //   Reads in the pdf Template
> >   PdfReader reader = new PdfReader(templatePath + template);
> >   PdfStamper stamp = new PdfStamper(reader, new 
> > FileOutputStream(path+outfile));
> >   AcroFields form = stamp.getAcroFields();
> >   Collection fieldlist = form.getFields().values();
> >   for (Iterator i = fieldlist.iterator(); i.hasNext(); ) {
> >        System.out.println(i.next().toString());
> >   }
> >
> > And I get ...
> > [EMAIL PROTECTED]
> > [EMAIL PROTECTED]
> > [EMAIL PROTECTED]
> > [EMAIL PROTECTED]
> >
> > Thanks for any help...
> > Jim Sloey
> >
> >
> > !DSPAM:42923d4551521829713830!
> >
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by Oracle Space Sweepstakes Want to be 
> the first software developer in space?
> Enter now for the Oracle Space Sweepstakes!
> http://ads.osdn.com/?ad_idt12&alloc_id344&op=ick
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 


-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to