List of usage examples for com.lowagie.text.pdf PdfPRow setMaxHeights
public void setMaxHeights(float maxHeight)
From source file:fr.opensagres.xdocreport.itext.extension.ExtendedPdfPTable.java
License:Open Source License
/** * Gets the height of a particular row./*from w w w . ja v a 2 s. c o 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; }