> 
> Nik Kolev wrote:
> > One approach that I tried but did not work (keep in mind that I've
> > only been using iText for 2 days before trying to kill me) is
keeping
> > track of the width of the data of each cell in a given column, using
> > ColumnText.getWidth(Phrase p) - p being used when constructing the
> > PdfPCell-s; and at the end doing a table.setWidths with the max
width
> > of each column.
> You're in the right direction.
> PDF isn't HTML, so you can't expect the table to adjust itself to the
> content of the cells.
> In other words: you have to examine the content first with something
> like getWidth.
> Please tell us what went wrong.

Don't know what was going wrong but I was able to get it to do what I
wanted by doing:
1) table.setLockedWidth(false); 
2) table.setWidthPercentage(maxWidths, pageSize);
Not sure if 1) is required - the javadocs are kinda sketchy, to say the
least... I may do table.setWidthPercentage in its various flavors more
than once though - so maybe that's where it helps

Couple of follow up questions:
o Seems that when I calculate the width I need to account for leading
and trailing space that each cell. Do I get this by adding the results
of PdfPCell.getPaddin{Left,Right}() ?
o When I do a Document.add(Element), element here being a PdfPTable, the
table gets centered on the page. How do I left-align it?

Thanks, -nik

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
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