We do all of the page formatting - and have to for setting text in things like the page on & number of pages field - which we then convert to text on the output. Plus we've put in a gigantic effort to match Word and there is a boatload of small weird rules that impact layout, and iText does not have that level of control.
So when we say the text must fit on a line - it all must go on that line. The output we produce is clean so the text we select for a line does fit - but I can't use an iText call that may decide that the last word should go on the next line. Also, for centered/right/justified text - it has to know that this is all the text for this line. And for justified text, needs to know if it is the last line of the paragraph (no justify) or a line before the last. Thanks - dave -----Original Message----- From: 1T3XT info [mailto:[email protected]] Sent: Monday, December 22, 2008 12:53 PM To: Post all your questions about iText here Subject: Re: [iText-questions] How should we write text to the PDF file? David Thielen wrote: > At present we write to the document using ColumnText.showTextAligned(). > We pass in the X, Y of the start of the text and in the case of > justified text, call it word by word. We then also draw underlines > ourselves afterwards. Wow, that's a lot of work. > I would prefer that we could call an iText method a line at a time and > give it the start & end of the line, if it's left, center, right, or > justified aligned, and if it's underlined. But it would not word wrap - > it would put everything on that one line. If you dropped the requirement "it would not word wrap", I'd say: that's easy. Please explain why you want to avoid word wrap. For instance: what happens when the text doesn't fit the line? (How) do you know the text will only take one line? Depending on your answers to this question, the solution could already be present, but I don't know. > Is there a way to do this? And if not, is our present approach using > ColumnText.showTextAligned() setting the left of each string the best > approach? I'd use ColumnText, but not ColumnText.showTextAligned(). I'd use setSimpleColumn to define a Rectangle that takes one line. Then I'd call ColumnText.go(). If the text doesn't fit the line, the remaining part is still in the ColumnText object for you to use in another Rectangle. -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------ ------ _______________________________________________ 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 ------------------------------------------------------------------------------ _______________________________________________ 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
