Hello -
I need to build a very standard form layout as you would see on paper,
something like:

ADDRESS

First Name:  ____FirstName_____      Last Name: ____Last Name________
Address:  ____ 33 Main St.________________
City: __Tulsa________________  State: _OK_   Zip: __22311__


It sounded simple to put together, and I tried several ways to do this, all
within a PdfPTable/PdfPCell structure:

1. simply underlining the data using Font setStyle()
2. using the Border on the TextField objects
3. using PdfPCell.setCellEvent() with a PdfPCellEvent class that uses
PdfContentByte a la section 10.2.2 of iTextInAction

however each had their drawbacks, including #3 which prevented the
PdfStamper from setting field values, as it appears only 1 Cell Event is
honored per cell. 

Here is an example of how I'm currently building a row of the form:

        // -- Line 2 --------------------------------------------------
                PdfPTable table = new PdfPTable(3);
                table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
                table.setWidthPercentage(70);
                table.setWidths(new float[]{110f, 100f, 700f});

                // Label 1
                cell = new PdfPCell();
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setPaddingRight(0f);
                labelFont.setSize(10f);
                cell.addElement(new Phrase("Start Date:", labelFont));
                table.addCell(cell); 

                // Field 1
                cell = new PdfPCell();
                cell.setBorder(Rectangle.NO_BORDER);
                f1 = new TextField(writer, new Rectangle(0,0,50,10),
"q.address.address1");
                f1.setFont(fieldFont.getBaseFont());
                f1.setFontSize(10f);  // Yes this is redundant but necessary

                cell.setCellEvent(new FieldCell(f1.getTextField(), 30,
writer));
                cell.setCellEvent(underline);

                table.addCell(cell);
                table.addCell(blank);
                mainTable.addCell(table);


I'm curious how other people are rendering such a standard form and 
maintaining the "fill in the blanks" look and feel of the form - i.e.
underlines should exist for each field whether or not data exists - and
having the underlines wrap with wrapped data.

I can think of a couple other possibilities such as:
* upgrade to 2.x and use the new drawing package?? Big question mark there
* I recall seeing that text could be overlayed using absolute positioning of
the data over top, but that sounds rife with problems

I did initially upgrade to 2.1.7, had the bouncycastle-dependency issue,
downgraded to 2.1.3 and saw that setBorder() no longer functioned as it did
in 1.3.1, and finally reverted back to 1.3.1 where I have other stuff
working. 

Could anyone offer another perspective on this? Strangely I don't see these
sorts of examples laying around.

Thanks for any ideas -
Kent



-- 
View this message in context: 
http://www.nabble.com/Form-with-underlined-field-values-tp24731524p24731524.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to