Ok, first, I am sorry for using "urgent", and thanks for replies. 

My problem is that i used setCellEvent to place all my textfields, but from
what i've seen from the book examples...they used setWidget method to
specify the position of the textfield. And because TextField class doesn't
have this method(and PdfFormField has it, this is why I used the latter).
But, with PdfFormField i did not manage to set the background as I posted in
the first message.

I see 2 possible solutions that you can give me: either how to set the
background using PdfFormField, or how to specify in the cellLayout(PdfPCell
cell, Rectangle rect, PdfContentByte[] cb) method the position using
TextField(that has no setWidget method).

I thank you in advance, and I know you do this for a hobby!

It is very annoying not to see where the textfields are...

10X...and I hope for replies...


razvanb wrote:
> 
> Hi!
> I have an urgent problem! 
> 
> I made a form that has many textfields created with the method
> PdfFormField.createTextField(PdfWriter writer, boolean multiline, boolean
> password, int maxLen), and that because my textfields are in
> PdfPCell(table cells).
> My problem is that i want these textfields to have a Green background
> color(in general, not only when focused), and all that i managed to do was
> to set the backgroundcolor only when you focus that textfield(with
> setMKBackgroundColor(Color)).
> 
> So please...if anyone knows how this can be done...it would be of a great
> help!
> 
> Please notice that I'm not using the class Textfield, but PdfFormField,
> and this is because with TextField i do not know how to insert the
> textfield in a specific cell of a table.
> 
> Any solutions are good....!
> 
> Here is a part of the code:
> 
> PdfPTable nested2 = new PdfPTable(2);
> cell = new PdfPCell();
>             form = PdfFormField.createTextField(writer, false, false, 20);
>             form.setFieldName("AbrufNr");
>             form.setMKBackgroundColor(Color.LIGHT_GRAY);
>             writer.addAnnotation(form);
>             cell.setCellEvent(new TestMain(form, 1f, "textfieldAbrufNr"));
>             cell.setBorder(PdfPCell.NO_BORDER);
>             cell.setGrayFill(0.9f);
>             nested2.addCell(cell);
> 
> -----------------------
> public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] cb)
> {
> if(formType.equalsIgnoreCase("textfieldAbrufNr")){
>             form.setWidget(new Rectangle(rect.getLeft(padding),
> rect.getBottom(padding),
>                               rect.getLeft(padding) + 20, 
> rect.getBottom(padding) + 10),
>                               PdfAnnotation.HIGHLIGHT_INVERT);
>         }
> }
> -----------------------
> The class TestMain implements PdfPCellEvent; So this method cellLayout is
> executed at the end...setting the position of my textfield in the cell!
> 

-- 
View this message in context: 
http://www.nabble.com/PdfFormfield-textfield-background-color-tp16627283p16678817.html
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to