itext-questions  

[iText-questions] Combobox printed, prints undesired value

Fhomasp
Fri, 27 Jun 2008 02:28:44 -0700

Hey,

My document is getting in the final stages and I'm pretty happy with the
result.  Lots of code though for a 5 paged document.

But now that I am testing the document I encountered a problem when printing
the document, more specifially with comboboxes.

When I open the generated document everything seems to be good.  There isn't
a value in the combobox field, which is the way it's supposed to be. But
then when i print it the first element in the dropdown box is filled in the
field.  That's of course not a desired result.  The document should print
values that are either selected or filled in, nothing else.
I tried setting the option in the textfield "Hidden but printable", which
makes the button with the list disappear.

It might be something I overlooked (again!? :) )

Cheers,
Thomas

edit: When selecting a value and printing the page it's all okay.
Oh and another thing.
When I use table.getDefaultCell().<useASetter> doesn't work very well for me
in terms of borders and alignments for other cells set in the table.
Strange, but no biggy.

Here is the code:

 public void addComboField(String name,String...options) throws
DocumentException,IOException
    {
        PdfPCell cell;

        table.addCell(new Phrase(name,wrapFont));

        Rectangle rectangle = new Rectangle(posX,posY,300,20);
        rectangle.setBorder(0);
        TextField textField = new TextField(writer, rectangle,
name+this.huidigVak);
        textField.setBorderStyle((int)TextField.BORDER_WIDTH_MEDIUM);
        textField.setChoices(options);
        textField.setFont(wrapFont.getBaseFont());
        textField.setFontSize(11);
        textField.setAlignment(Element.ALIGN_LEFT);
        textField.setDefaultText("");
        textField.setText("");
        
        PdfFormField combo = textField.getComboField();
        combo.setValueAsString("");
        cell = new PdfPCell();
        combo.setDefaultValueAsString("");
        
        cell.setMinimumHeight(20);
        cell.setBorder(1);
        cell.setBorderColorRight(Color.BLACK);
        cell.setBorderColorBottom(Color.black);
        cell.setUseAscender(false);
        cell.setUseDescender(false);

        FieldPositioningEvents events = new FieldPositioningEvents(writer,
combo);
        cell.setCellEvent(events);

        table.addCell(cell);

        cb.stroke();
    }
-- 
View this message in context: 
http://www.nabble.com/Combobox-printed%2C-prints-undesired-value-tp18151124p18151124.html
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
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