Example usage for com.lowagie.text.pdf PdfPCell getMaxHeight

List of usage examples for com.lowagie.text.pdf PdfPCell getMaxHeight

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPCell getMaxHeight.

Prototype

public float getMaxHeight() 

Source Link

Document

Returns the height of the cell.

Usage

From source file:fr.opensagres.xdocreport.itext.extension.ExtendedPdfPTable.java

License:Open Source License

/**
 * Gets the height of a particular row./* ww w  .jav  a2  s  .co  m*/
 *
 * @param idx the row index (starts at 0)
 * @param firsttime is this the first time the row heigh is calculated?
 * @return the height of a particular row
 * @since 3.0.0
 */
public float getRowHeight(int idx, boolean firsttime) {
    if (totalWidth <= 0 || idx < 0 || idx >= rows.size())
        return 0;
    PdfPRow row = (PdfPRow) rows.get(idx);
    if (row == null)
        return 0;
    if (firsttime)
        row.setWidths(absoluteWidths);
    float height = row.getMaxHeights();
    PdfPCell cell;
    PdfPRow tmprow;
    for (int i = 0; i < relativeWidths.length; i++) {
        if (!rowSpanAbove(idx, i))
            continue;
        int rs = 1;
        while (rowSpanAbove(idx - rs, i)) {
            rs++;
        }
        tmprow = (PdfPRow) rows.get(idx - rs);
        cell = tmprow.getCells()[i];
        float tmp = 0;
        // AZERR patch : sometimes cell is null????
        // LP : cell may be null if colspan/rowspan occurs
        // create a dummy cell to avoid NullPointerException
        if (cell == null) {
            cell = new PdfPCell();
            tmprow.getCells()[i] = cell;
        }
        if (cell.getRowspan() == rs + 1) {
            tmp = cell.getMaxHeight();
            while (rs > 0) {
                tmp -= getRowHeight(idx - rs);
                rs--;
            }
        }
        if (tmp > height)
            height = tmp;
    }
    row.setMaxHeights(height);
    return height;
}