Hi,

My requirement is know the page number before writing the tables to the
document with the statement documnet.add(table).
Is there any way to get the page number of the document while writing the
table to the document.
I am writing tables to the document one by one and trying to know the page
number of the document in which this table is going to write.
For knowing the page number i tried the statements
1. writer.getPageNumber()
2. document.getPageNumber()
Both these two statements given me the value '0' though the tables are
writing in 2 page or in any other page.

Please give the possible solution for this. Thanks in advance.

Following is the code iam using to write the table to the document.

   table = new PdfPTable(columnDefinitionSize);
   table.setHorizontalAlignment(0);
   table.setTotalWidth(width - 72);
   table.setLockedWidth(true);
   table.getDefaultCell().setColspan(4);
   table.getDefaultCell().setBorderWidth(1);
   table.addCell(new Phrase("Table added with writeSelectedRows"));
   table.setHeaderRows(1);
   PdfPTable subTable = new PdfPTable(3);
    for(int j = 0;j<4;j++)
    {
     System.out.println("pageNumber is "+document.getPageNumber());
     if(j==0 || pageNumber+1 == document.getPageNumber())
     {
      txt = arr[i];
      pageNumber+=1;
     }else
     {
      txt = "";
     }
     table = new PdfPTable(columnDefinitionSize);
     table.setHorizontalAlignment(0);
     table.setTotalWidth(width - 72);
     table.setLockedWidth(true);
     table.getDefaultCell().setColspan(0);
     table.addCell(new Phrase(txt));
     //table.getDefaultCell().setBorderWidth(1);
     table.getDefaultCell().setBorder(Rectangle.RIGHT);
     table.getDefaultCell().setBorderWidth(1);
     System.out.println("before i is "+i+" j is "+j+" txt is "+arr[i]);
     System.out.println("docu pageNumber is "+document.getPageNumber()+"
pageNumber is "+pageNumber);
     System.out.println("after i is "+i+" j is "+j+" txt is "+arr[i]);
     table.setSplitLate(false);
     table.addCell(new Phrase("MSc(I.T)", font8));
     table.addCell(new Phrase("DR.M.G.R Engg.College", font8));
     table.addCell(new Phrase("2002-04-
alksdfjsadfsajdfklasdjflksadjfskladfjlaskdjfklsadjfsdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfadsflaskdfjlaskdfjlaskdjflaskfjlkasjdflskajflksajflkasjflkasjlkasjdflkasjdflkasjdflksdjflsakfjlaskdfjlaskdjflskadjflaksdfjlkasjflkasdjflaskdjflsakdjf",
font8));
     PdfPCell newspace = new PdfPCell();
     newspace.setBorder(Rectangle.RIGHT);
     newspace.setBorder(Rectangle.NO_BORDER);
     newspace.setBorderWidth(1);
     table.addCell(newspace);
     table.addCell(newspace);
     table.addCell(newspace);
     table.addCell(newspace);
     System.out.println("extended last row "+table.isExtendLastRow());
     document.add(table);

    }
    //table.addCell(subTable);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to