You have to make the ColumnText wider than what you measured in the Paragraph or the floating point rounding errors may cause the Paragraph to wrap. An increase of 0.0001 points should be enough.
Paulo ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, August 20, 2008 8:20 PM Subject: [iText-questions] unwanted wrapping / false width in ColumnText Hello, I am experiencing a problem I haven't found so far: I'm adding a SimpleColumn (ColumnText) to the right side of the page at absolute position. The right border is easy, just the full length of 210mm (A4) minus the right margin. But I'm having trouble with the left border-position (the Alignment in the ColumnText is left). To get this x-position I aquire the maximum width of the paragraphs in this column (with the ColumnText.getWidth method), and simply substract this float-value from the right border-position. This works ALMOST very good and I think it is the right approach. BUT: Even though I took the maximum Paragraph width for the column, the widest Paragraph is still wrapped! I have to make the column a "little bit" wider so it doesn't wrap. And this "little bit" bothers me a lot, because it is different dependent on the widest Paragraph. Why is this? This is really a weak point in my application, because the content is dynamic, I can't just say "Oh well, I make the column wider by 0.3 points", because for a wider paragraph that might not be enough and it still wraps. Is there a way to determine this "extra space" in width which is obviously needed so the longest Paragraph doesn't wrap? Thank you in advance, I really don't know how! Bye M. Baumann Code: float rwidth=0; Paragraph tel = new Paragraph(obj.getPhone(), FONT2); Paragraph fax = new Paragraph(obj.getFax(), FONT2); Paragraph email = new Paragraph(obj.getEmail(), FONT2); if (ColumnText.getWidth(tel) > rwidth) rwidth = ColumnText.getWidth(tel); if (ColumnText.getWidth(fax) > rwidth) rwidth = ColumnText.getWidth(fax); if (ColumnText.getWidth(email) > rwidth) rwidth = ColumnText.getWidth(email); ColumnText ct2 = new ColumnText(cb); ct2.setSimpleColumn(getPointsFromMM(210)-marginRight-rwidth-0.05f, getPointsFromMM(207), getPointsFromMM(210)-marginRight, getPointsFromMM(252), 6.5f, Element.ALIGN_LEFT); ct2.go(); ct2.addText(new Chunk("Tel: ", FONT2_BOLD)); ct2.go(); ct2.setLeading(leadingFont2); ct2.addText(tel); ct2.go(); ct2.setYLine(ct2.getYLine()-(leadingFont2/2)); ct2.addText(new Chunk("Fax: ", FONT2_BOLD)); ct2.go(); ct2.addText(fax); ct2.go(); ct2.setYLine(ct2.getYLine()-(leadingFont2/2)); ct2.addText(new Chunk("E-Mail: ", FONT2_BOLD)); ct2.go(); ct2.addText(email); ct2.go(); ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php
