Question

I am creating PdfPTable, PdfPCell and a Paragraph consisting of Chunks. I want to add the chunks to a page at a specific coordinate (absolute position).

Was it helpful?

Solution

I see that the question already has one down and one close vote. I must admit that your question is quite confusion. Actually it didn't make sense as the question in the title said "how to set chunk width in itext?" whereas the question in the body sounded more like How to add a Chunk at an absolute position?

These are two different questions. I assume that you don't need to rescale the width of a Chunk, but that you have a Chunk, with a certain width, and that you want to add it to a page at an absolute position. If that's not the case, you should post another question with a clear question.

You're using PdfPTable and PdfPCell, not pdfTable and pdfCell; errors like this aren't caused by not being fluent enough in English; they are proof that you don't respect the people on SO enough to be more careful when phrasing a question. If you want to add a PdfPTable at an absolute position, you need to look at the writeSelectedRows() method.

You're using Paragraph. If you want to add a Paragraph inside a rectangle defined by its lower-left and the upper-right coordinate, you need to use ColumnText in composite mode.

You're also talking about a Chunk. If you want to add a Chunk at an absolute position, you need to wrap it inside a Phrase and add it to the page using the ColumnText.showTextAligned() method.

There are many examples available for each of the solutions mentioned above, but you should first make up your mind about what you really need. That's not clear from your question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top