[EMAIL PROTECTED] wrote:
> Hi all,
>  
> I'm having a problem trying to format a pdf report according to what the 
> business needs.  I was able to create the pdf without any issues, with a 
> header/footer, "page X of Y", etc...  However, I'm having trouble 
> displaying groups.  For example, let's say I have the following, a 
> "name" which has a bunch of subgroups.  I'm supressing the "name" value 
> if the previous record has the same name.  However, if the records 
> rollover to a new page, I want to display the "name" again.  I'm finding 
> it hard to do this because I first create the PdfPTable and then add it 
> to a ColumnText which displays the data on the pdf.  Therefore, I don't 
> know where the pagebreak will occur when creating the PdfPTable:
>  
> _*Example of what I'm getting:*_
> __ 
> /_Header                              _/
> /name abc/
> /         def/
> /         ghi/
> /         etc.../
> /----------------------------------/
> /Footer              Page 1 of 2/
>  
>  
> _/Header                                 /_/       /
> /         jkl           <--- want "name" to display again since it's a 
> new page./
> /         mno/
> /         etc.../
> /-----------------------------/
> /Footer               Page 2 of 2/
>  
>  
> _*Example of what I need:*_
> __ 
> _/Header                              /_
> /name abc/
> /         def/
> /         ghi/
> /         etc.../
> /----------------------------------/
> /Footer              Page 1 of 2/
>  
>  
> _/Header                              /_
> /name jkl           <--- "name" is displayed since it's a new page/
> /         mno/
> /         etc.../
> /----------------------------------/
> /Footer              Page 2 of 2/
>  
>  
> Below is what I use to display the table. In my example above, the table 
> will only have two columns and I want to suppress the first column if 
> it's the same as the previous row's first column ( I have no problem 
> with this ) and I want to display the first column if it's a new page ( 
> Here's where I have the issue ):
> 
> /*ColumnText tableCt = new ColumnText(this.cb);   //cb is a PdfContentByte
> tableCt.addElement(table);  //table is a PdfPTable
> tableCt.setSimpleColumn( this.leftMargin, this.footerHeight, 
> this.pageWidth - this.rightMargin, this.headerHeight ); */
> /**/ 
> /*try{
>          int status = ColumnText.NO_MORE_COLUMN ;
>          while((status & ColumnText.NO_MORE_TEXT) == 0){
>           status = tableCt.go();
>           tableCt.setYLine( 399 );
>           doc.newPage();           
>          }
>  } catch ( DocumentException de ){         
> } */
>  
> Please let me anyone has done something similar and can point me in the 
> right direction.

I don't have the time for a complete solution, but maybe
this will help: you say say "Therefore, I don't know where
the pagebreak will occur," but that's not entirely true:
the page break occurs when you invoke doc.newPage();
Of course: at that time, your PdfPTable is already constructed,
BUT: you can always add content with ColumnText; you could add
the "name" in this cell with ColumnText instead of PdfPTable.
The only problem you need to overcome to achieve this, is to
find out the coordinate of the upper left cell. I'm not sure
if this will work, but I would try if TableEvents can help me
with this... (I haven't tried this myself, so I apologize in
advance if I'm pointing you in the wrong direction.)
-- 
This answer is provided by 1T3XT BVBA

-------------------------------------------------------------------------
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
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to