Use a Paragraph to set the alignment. setPhrase() only sets the text, the alignment and other parameters are set in the cell. addElement() allows to add more than one Paragraph, List, PdfPTable, etc, to to cell. In this case the objects themselves carry the attributes such as the alignment.
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Eric Marshall > Sent: Monday, August 29, 2005 4:14 PM > To: [email protected] > Subject: [iText-questions] cell.setPhrase vs cell.addElement > (was leading problem) > > I've tracked my leading problem down to the cell.setPhrase method I > was using to add my multi-lined text containing different sized fonts. > I changed the setPhrase call to addElement, and that > corrected the leading > problem, but now the horizontal alignment of the text is gone :-( What > is the intended difference between these two methods? Here is my code: > > document.open(); > table = new PdfPTable(1); > cell = new PdfPCell(); > cell.setHorizontalAlignment(Element.ALIGN_CENTER); > phrase = new Phrase(); > phrase.setLeading(BIG_FONT.size()); > phrase.add(new Chunk("T", BIG_FONT)); > phrase.add(new Chunk("HIS\n", SMALL_FONT)); > phrase.add(new Chunk("IS\n", SMALL_FONT)); > phrase.add(new Chunk("T", BIG_FONT)); > phrase.add(new Chunk("HE ", SMALL_FONT)); > phrase.add(new Chunk("C", BIG_FONT)); > phrase.add(new Chunk("OVER", SMALL_FONT)); > cell.setPhrase(phrase); /* or cell.addElement(phrase); */ > table.addCell(cell); > document.add(table); > document.close(); > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development > Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects & Teams * > Testing & QA > Security * Process Improvement & Measurement * > http://www.sqe.com/bsce5sf > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions > ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
