Thanks Paulo,
I saw the template that u sent me.
It is similar to the one that i sent you, but the form controls are bigger in
size. I fail to understand howz that gonna help me.
Still I tried with what u suggested.

1 - start with template2.pdf
2 - fill the header fields and note the table field positions with
3 AcroFields.getFieldPositions(). Make also note of the field content to select
the DB.
4 - flatten template2, probably to memory. The result is a pdf, that we shall
call template3, containing the header and the look and feel.
5 - create a PdfWriter and use template3 as a background.
6 - output the table data at absolute positions withing the bounds of the table
fields.


I am through till the step 5. But I am unable to get how to output the table
data at absolute positions within the bounds of the table fields? I am not
getting the class which will help me to accomplish the same.

Can u please explain it a little bit more.


Following is the code...........



String outputPDFTemp = "C:\\itext\\Nitin_Temp.pdf";
String templateName = pdfForm.getPdfTemplateName();
PdfReader reader = new PdfReader(templateName);
ByteArrayOutputStream lBAOS = new ByteArrayOutputStream();
PdfStamper stamp = new PdfStamper(reader, lBAOS);
AcroFields form = stamp.getAcroFields();
HashMap lHashMapFieldDetails = new HashMap();
HashMap formFields = form.getFields();
Set formFieldNames = formFields.keySet();
Iterator nameIterator = formFieldNames.iterator();
FieldDetails lFieldDetails = null;

//loops through all field names in the pdf template
while(nameIterator.hasNext())
{
            lFieldDetails = new FieldDetails();
            //pdf template field name
            String fieldName = (String) nameIterator.next();
            //value for field, if any
            String value = form.getField(fieldName);
            float [] pos = form.getFieldPositions(fieldName);
            lFieldDetails.setFieldName(fieldName);
            lFieldDetails.setFieldValue(value);
            lFieldDetails.setPageNumber(pos[0]);
            lFieldDetails.setLowerLeftX(pos[1]);
            lFieldDetails.setLowerLeftY(pos[2]);
            lFieldDetails.setUpperRightX(pos[3]);
            lFieldDetails.setUpperRightY(pos[4]);
            lHashMapFieldDetails.put(fieldName,lFieldDetails);
            ByteArrayInputStream lBAIS = new 
ByteArrayInputStream(lBAOS.toByteArray());
            if(value != null)
            {
                form.setField(fieldName, value);

            }
}

//gets rid of editable fields, makes them part of the document
stamp.setFormFlattening(true);
//Closes the document. No more content can be written after the document is
closed.
stamp.close();
//            Document lDocument = new Document();
//            PdfWriter lPdfWriter;
//            lPdfWriter = PdfWriter.getInstance(lDocument, lBAOS);

        PdfReader lPdfReader = new PdfReader(lBAOS.toByteArray());
        PdfStamper lPdfStamper = new PdfStamper(lPdfReader, new
FileOutputStream(outputPDF));
        PdfWriter lPdfWriter = lPdfStamper.getWriter();
//            AcroFields lAcroFields = lPdfStamper.getAcroFields();
        lPdfStamper.close();




Hopes that I am heading in the right direction.


Thanks,
Nitin




Quoting Paulo Soares <[EMAIL PROTECTED]>:

> - start with template2.pdf
> - fill the header fields and note the table field positions with
> AcroFields.getFieldPositions(). Make also note of the field content to
> select the DB.
> - flatten template2, probably to memory. The result is a pdf, that we
> shall call template3, containing the header and the look and feel.
> - create a PdfWriter and use template3 as a background.
> - output the table data at absolute positions withing the bounds of the
> table fields.
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, March 16, 2005 8:00 AM
> > To: Paulo Soares
> > Cc: [EMAIL PROTECTED];
> > iText-questions@lists.sourceforge.net
> > Subject: RE: [iText-questions] PDF Generation using
> > PDFFormanddatafromdatabase
> >
> > I need to mantain same look and feel for the output flat pdf.
> > And this template is also not fixed. These templates will be
> > provided by the
> > front end users and I need to create a flate pdf file with
> > same look and feel
> > as in template and fetch the data from database.
> > Is it possible using PdfWriter?
> >
> > Thanks,
> > Nitin Gulati
> >
> >
> > Quoting Paulo Soares <[EMAIL PROTECTED]>:
> >
> > > Forget about using the template to fill values. Use the
> > template to get
> > > the field values and create a new pdf with PdfWriter.
> > >
> > > > -----Original Message-----
> > > > From: [EMAIL PROTECTED]
> > > > [mailto:[EMAIL PROTECTED]
> > > > Sent: Tuesday, March 15, 2005 1:32 PM
> > > > To: Paulo Soares
> > > > Cc: [EMAIL PROTECTED];
> > > > iText-questions@lists.sourceforge.net
> > > > Subject: RE: [iText-questions] PDF Generation using PDF
> > > > Formanddatafromdatabase
> > > >
> > > > Hi Paulo,
> > > >
> > > > Thanks for taking all the pain.
> > > > Please find the template attached with the mail.
> > > >
> > > > It has few form fields. these form fields have the value as
> > > > tablename.columname
> > > > in the database table.
> > > >
> > > > There can be multiple companies and each company will have
> > > > multiple Employees.
> > > > I have to create the same template for each company and
> > > > multiple rows (one row
> > > > for each employee (which
> > > > can span over number of pages)) in the employees table. I
> > > > have to add these
> > > > templates to the final pdf file.
> > > >
> > > > Hope I am clear in explaining my needs.
> > > >
> > > > Thanks,
> > > > Nitin Gulati
> > > > Quoting Paulo Soares <[EMAIL PROTECTED]>:
> > > >
> > > > > Send me one of those template and I'll give you more directions.
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: [EMAIL PROTECTED]
> > > > > > [mailto:[EMAIL PROTECTED]
> > > > > > Sent: Tuesday, March 15, 2005 12:28 PM
> > > > > > To: Paulo Soares
> > > > > > Cc: iText-questions@lists.sourceforge.net
> > > > > > Subject: RE: [iText-questions] PDF Generation using PDF Form
> > > > > > anddatafromdatabase
> > > > > >
> > > > > > I am totally new to iText (as you might have guessed by now,
> > > > > > seeing the kind of
> > > > > > questions that i post). Can you please give me a headstart
> > > > > > (i.e. the sample
> > > > > > code showing how to use AcroFields and PdfStamper for the
> > > > > > kind of application i
> > > > > > need).
> > > > > > I know I am asking for too much, but it will definately
> > > > help me out.
> > > > > >
> > > > > > Thanks,
> > > > > > Nitin Gulati
> > > > > >
> > > > > > Quoting Paulo Soares <[EMAIL PROTECTED]>:
> > > > > >
> > > > > > > It can be done but not with forms. Use the form just to get
> > > > > > the field
> > > > > > > positions and column names but fill the values with
> > > > > > PdfContentByte. See
> > > > > > > AcroFields and PdfStamper.
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: [EMAIL PROTECTED]
> > > > > > > > [mailto:[EMAIL PROTECTED] On
> > > > > > > > Behalf Of [EMAIL PROTECTED]
> > > > > > > > Sent: Tuesday, March 15, 2005 4:40 AM
> > > > > > > > To: Paulo Soares
> > > > > > > > Cc: iText-questions@lists.sourceforge.net
> > > > > > > > Subject: Re: [iText-questions] PDF Generation
> > using PDF Form
> > > > > > > > and datafromdatabase
> > > > > > > >
> > > > > > > > Thanks Paulo,
> > > > > > > > But I need to create the table dynamically, as in the form
> > > > > > > > (template) there will
> > > > > > > > be just 2 rows for that table. One header and second a row
> > > > > > > > with form controls
> > > > > > > > having the value specifying the database
> > columname from where
> > > > > > > > that value has to
> > > > > > > > be fetched.
> > > > > > > > Can I craete the table dynamically.
> > > > > > > > Please suggest. It would be great if I could get
> > the staring
> > > > > > > > poin (in terms of
> > > > > > > > code) on which can build upon.
> > > > > > > >
> > > > > > > > Thanks,
> > > > > > > > Nitin Gulati
> > > > > > > >
> > > > > > > > Quoting Paulo Soares <[EMAIL PROTECTED]>:
> > > > > > > >
> > > > > > > > > The easiest way is to dispose the fields as a table.
> > > > > > > > > If you have a 10x10 table you'll need 100 fields.
> > > > > > > > >
> > > > > > > > > --- "[EMAIL PROTECTED]"
> > > > > > > > > <[EMAIL PROTECTED]> wrote:
> > > > > > > > > > Hi,
> > > > > > > > > > I need to create a pdf using the template (pdf fprm)
> > > > > > > > > > that is provided by the
> > > > > > > > > > user from front end. my output flat file needs to be
> > > > > > > > > > same as the template. But
> > > > > > > > > > it should be faltenned, moreover In the template
> > > > > > > > > > there can be a table with the
> > > > > > > > > > columns like
> > > > > > > > > >
> > > > > > > > > > Name  Address  City  State  Country  Zip
> > > > > > > > > >
> > > > > > > > > > in one row and it's values like
> > > > > > > > > >
> > > > > > > > > > USER.USERNAME USER.ADDRESS USER.CITY USER.STATE
> > > > > > > > > > USER.COUNTRY USER.ZIP
> > > > > > > > > >
> > > > > > > > > > in the form fields in the next row.
> > > > > > > > > >
> > > > > > > > > > Say there are 100 records in the USER table. I need
> > > > > > > > > > to fetch all the 100 records
> > > > > > > > > > from the database and need to create a new file
> > > > > > > > > > which matches the format of the
> > > > > > > > > > template(form) and displays all the 100 records.
> > > > > > > > > > (Note in the template there is
> > > > > > > > > > the table with one header row and one more row to
> > > > > > > > > > map the header and the data
> > > > > > > > > > that is to be displayed under that header.)
> > > > > > > > > >
> > > > > > > > > > Is this possible using iText.
> > > > > > > > > > Please advise.
> > > > > > > > > >
> > > > > > > > > > Thanks,
> > > > > > > > > > Nitin Gulati
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > -------------------------------------------------------
> > > > > > > > > > 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
> > > > > > > > > > iText-questions@lists.sourceforge.net
> > > > > > > > > >
> > > > > > > > >
> > https://lists.sourceforge.net/lists/listinfo/itext-questions
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > __________________________________
> > > > > > > > > Do you Yahoo!?
> > > > > > > > > Yahoo! Small Business - Try our new resources site!
> > > > > > > > > http://smallbusiness.yahoo.com/resources/
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -------------------------------------------------------
> > > > > > > > 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
> > > > > > > > iText-questions@lists.sourceforge.net
> > > > > > > >
> > 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_ide95&alloc_id396&op=click
> > > _______________________________________________
> > > iText-questions mailing list
> > > iText-questions@lists.sourceforge.net
> > > 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
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to