![]() There's also a question and answer that explains how to draw the rectangle, should that really be one of your requirements. These questions were selected for the book "The Best iText Questions on StackOverflow". Using ColumnText results in "The document has no pages" exception.How to fit a String inside a rectangle?.Read these questions and answers before you start implementing: However, you need to be careful and make sure that the content fits the rectangle. If rectangle is a Rectangle object defining the coordinates of the rectangle where you want to add the two paragraphs, then you need this code: ColumnText ct = new ColumnText(writer.getDirectContent()) Īs you can see, there is no need for a third paragraph. If I were you, I would look at my answer to the question, and use the ColumnText object:Īdding paragraphs to a rectangle is done like this: You can do it the hard way, by using a sequence of low-level operations, as is done in this question: Separating redundant code from pdf generator function, but given your level of expertise, I would not advise you to do this. If you want to add text at absolute positions, for instance in a rectangle, you have two options. This will put the referred interaction name in the rectangle and it is the. When you use document.add() you tell iText to position the text for you, based on the size of the page and its margins. to StarUML Since it is an InteractionUse, you relate it to the interaction it refers to by using its 'refersTo' property. You say you want to add these paragraphs to a rectangle, yet you are using document.add(p). Either you create one Paragraph consisting of the blueText and greenText chunks, or you create two paragraphs, and you add them to the page sequentially. You created 2 paragraphs, and you add them to a third paragraph.Īlthough you can do that, it doesn't make any sense. ![]()
0 Comments
Leave a Reply. |