Hello,
I'm trying to create a Table width an undeterminated number of cells before
the user enter the number of cells.
I'd like to have the first cell of my table a bit longer that the others.
For exemple, the user enter:
How many periods : 5
and I'd like to have a table like this:
| Lesson | P1 | P2 | P3 | P4 | P5 |
Total |
But I can't enter a width vector in myTable.setWidths() because I don't know
how many cells the user will enter.
Here is the code :
public boolean create() {
>
> document_ = new Document(PageSize.A4.rotate());
>
> try {
>
> PdfWriter.getInstance(document_,
>
> new FileOutputStream("bulletin.pdf"));
>
> cellList = new ArrayList();
>
>
>
> document_.open();
>
>
>> int nbColumns = 2 + nbPeriods_;
>
> if (this.hasDecemberExams_) {
>
> nbColumns++;
>
> }
>
>
>> PdfPTable table = new PdfPTable(nbColumns+1);
>>
>
> table.addCell("Cours");
>
>
>
> PdfPTable periodTable = new PdfPTable(nbPeriods_);
>
>
>> periodTable.getDefaultCell().setHorizontalAlignment(
>
> Element.ALIGN_CENTER);
>
> periodTable.getDefaultCell().setColspan(nbPeriods_);
>
> periodTable.addCell("Périodes");
>
> periodTable.getDefaultCell().setColspan(1);
>
>
>
> int i = 1;
>
> while ( i <= nbPeriods_) {
>
> periodTable.addCell("P"+i);
>
> ++i;
>
> }
>
>
>
> PdfPCell pt = new PdfPCell(periodTable);
>
> pt.setColspan(nbPeriods_+1);
>
> table.addCell(pt);
>
>
>
> if (this.hasDecemberExams_) {
>
> table.addCell("Examen Décembre");
>
> }
>
> table.addCell("Examen Juin");
>
>
>
> document_.add(table);
>
>
>> } catch (Exception e) {
>
> // handle exception
>
> return false;
>
> }
>
>
>
> document_.close();
>
>
>> return true;
>
> }
>
>
Thank you.
Sorry for my very bad english !
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
iText-questions mailing list
[email protected]
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/