0
votes

I am creating a one column PdfPTable given a Rectangle, at a particilar absolute position. In this table, I need to add a collection of PdfPCells and show as much of the cell content as possible and the cells must be clipped at the table rectangle boundaries. I took care of the width by:

    PdfPTable cutTable = new PdfPTable(1);
    cutTable.setTotalWidth(200f);
    cutTable.setLockedWidth(true);

I have a phrase object in each cell and I add a set of cells to the table. The problem is that the cells overflows the table height boundary and it is not clipped. I tried keeping track of the total cells' height after adding each cell, but the problem is that since I ask the table for the row height, a cell must be inserted before and my calculation is off as the last cell overflows.

How do I get the table to clip the cell contents at its boundaries? If I can't do this, how do I determine the height of the cell(the phrase uses Arial 8 font) with the default text wrapping, before it is added to the table?

Thanks in advance for your help.

1

1 Answers

0
votes

Take a look at the CellHeights example from my book "iText in Action." It uses the different options to set the height of a cell. I think you need the setFixedHeight() method. When using this method, all content added to the cell that doesn't fit the height will be dropped.