List of usage examples for com.lowagie.text.pdf PdfPRow getCells
public PdfPCell[] getCells()
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 . 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; }
From source file:fr.opensagres.xdocreport.itext.extension.ExtendedPdfPTable.java
License:Open Source License
/** * Checks if there are rows above belonging to a rowspan. * * @param currRow the current row to check * @param currCol the current column to check * @return true if there's a cell above that belongs to a rowspan * @since 2.1.6/*from w w w . j a v a2s.com*/ */ @SuppressWarnings("all") boolean rowSpanAbove(int currRow, int currCol) { if ((currCol >= getNumberOfColumns()) || (currCol < 0) || (currRow == 0)) return false; int row = currRow - 1; PdfPRow aboveRow = (PdfPRow) rows.get(row); if (aboveRow == null) return false; PdfPCell aboveCell = (PdfPCell) aboveRow.getCells()[currCol]; while ((aboveCell == null) && (row > 0)) { aboveRow = (PdfPRow) rows.get(--row); if (aboveRow == null) return false; aboveCell = (PdfPCell) aboveRow.getCells()[currCol]; } int distance = currRow - row; if (aboveCell == null) { int col = currCol - 1; aboveCell = (PdfPCell) aboveRow.getCells()[col]; while ((aboveCell == null) && (row > 0)) aboveCell = (PdfPCell) aboveRow.getCells()[--col]; return aboveCell != null && aboveCell.getRowspan() > distance; } if ((aboveCell.getRowspan() == 1) && (distance > 1)) { int col = currCol - 1; aboveRow = (PdfPRow) rows.get(row + 1); distance--; aboveCell = (PdfPCell) aboveRow.getCells()[col]; while ((aboveCell == null) && (col > 0)) aboveCell = (PdfPCell) aboveRow.getCells()[--col]; } return aboveCell != null && aboveCell.getRowspan() > distance; }
From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.itext.PatchRtfRow.java
License:Open Source License
/** * Imports a PdfPRow and copies all settings * * @param row//w ww . jav a 2 s.c o m * The PdfPRow to import * @since 2.1.3 */ private void importRow(PdfPRow row) { this.cells = new ArrayList<PatchRtfCell>(); this.width = this.document.getDocumentHeader().getPageSetting().getPageWidth() - this.document.getDocumentHeader().getPageSetting().getMarginLeft() - this.document.getDocumentHeader().getPageSetting().getMarginRight(); this.width = (int) (this.width * this.parentTable.getTableWidthPercent() / 100); int cellRight = 0; int cellWidth = 0; PdfPCell[] cells = row.getCells(); for (int i = 0; i < cells.length; i++) { cellWidth = (int) (this.width * this.parentTable.getProportionalWidths()[i] / 100); cellRight = cellRight + cellWidth; PdfPCell cell = cells[i]; PatchRtfCell rtfCell = new PatchRtfCell(this.document, this, cell); rtfCell.setCellRight(cellRight); rtfCell.setCellWidth(cellWidth); this.cells.add(rtfCell); } }