Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

Re: [iText-questions] Table vs. PdfPTable, Cell vs. PdfPCell; and
removing borders.

Bruno

2005-07-12

Replies:

John M. Gabriele wrote:

>What's a good rule of thumb for deciding whether to use
>a Table or a PdfPTable?
>
>
If you are generating PDF only, use PdfPTable.

>I also need to remove all borders from it -- so the text is
>just floating there. :) I see that I can use a Table and
>then setBorderWidth( 0 ) to remove that one big border around
>the entire table. Can I do something similar with the PdfPTable?
>
>
A PdfPTable hasn't got a border around the entire table.
(You can add one with a PdfPTableEvent.)

>I also need to remove the borders from the individual cells
>inside the table. (I suppose that I can use either PdfPCells or
>Cells. What's the rule of thumb there (for deciding between
>the two)?)
>
>
PdfPCells can only be used in a PdfPTable.
Cells can only be used in a Table.

>I've tried mycell.setBorderWidth( 0 ) (like I did with the
>Table above) but it doesn't work with the Cell or PdfPCell
>for me.
>
>
That's because you shouldn't remove the borders by setting the width to 0.
You should use this method (Cell and PdfPCell extend Rectangle):
http://itextdocs.lowagie.com/docs/com/lowagie/text/Rectangle.html#setBorder(int)
with value Rectangle.NO_BORDER
http://itextdocs.lowagie.com/docs/com/lowagie/text/Rectangle.html#NO_BORDER

>It looks as if, with either Cell or PdfPCell (since they
>both inherit from Rectangle), I'm supposed to be able to do:
>disableBorderSide( Rectangle.LEFT | Rectangle.RIGHT | Rectangle.TOP |
>Rectangle.BOTTOM )
>but that's not working for me. I've also tried setBorder( 0 )
>but that fails to do anything either (that is, the grey border
>on the page around the cells in my table is still there).
>
>
Oops, you already tried my advice.
Are you sure you are generating PDF?
The way you describe it, it looks like you are generating RTF.

>BTW, why doesn't PdfPTable inherit from Rectangle like Table
>does? (like both cell classes)
>
I know I had a reason when I wrote class Table, but I forgot.
br,
Bruno


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
©2008 junlu.com - Jax Systems, LLC, U.S.A.