/** * Imports a PdfPRow and copies all settings * * @param row The PdfPRow to import * @since 2.1.3 */ private void importRow(PdfPRow row) { this.cells = new ArrayList(); 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]; RtfCell rtfCell = new RtfCell(this.document, this, cell); rtfCell.setCellRight(cellRight); rtfCell.setCellWidth(cellWidth); this.cells.add(rtfCell); } }
public PdfPCell[] getColumns(PdfPTable table, int col) { PdfPCell[] columns = new PdfPCell[table.getRows().size()]; for (int rid=0; rid < table.getRows().size(); rid++) { columns[rid] = ((PdfPRow)table.getRows().get(rid)).getCells()[col]; } return columns; }
/** * Imports the rows and settings from the Table into this * RtfTable. * * @param table The source PdfPTable * @since 2.1.3 */ private void importTable(PdfPTable table) { this.rows = new ArrayList(); this.tableWidthPercent = table.getWidthPercentage(); // this.tableWidthPercent = table.getWidth(); this.proportionalWidths = table.getAbsoluteWidths(); // this.proportionalWidths = table.getProportionalWidths(); this.cellPadding = (float) (table.spacingAfter() * TWIPS_FACTOR); // this.cellPadding = (float) (table.getPadding() * TWIPS_FACTOR); this.cellSpacing = (float) (table.spacingAfter() * TWIPS_FACTOR); // this.cellSpacing = (float) (table.getSpacing() * TWIPS_FACTOR); // this.borders = new RtfBorderGroup(this.document, RtfBorder.ROW_BORDER, table.getBorder(), table.getBorderWidth(), table.getBorderColor()); // this.borders = new RtfBorderGroup(this.document, RtfBorder.ROW_BORDER, table.getBorder(), table.getBorderWidth(), table.getBorderColor()); this.alignment = table.getHorizontalAlignment(); // this.alignment = table.getAlignment(); int i = 0; Iterator rowIterator = table.getRows().iterator(); // Iterator rowIterator = table.iterator(); while(rowIterator.hasNext()) { this.rows.add(new RtfRow(this.document, this, (PdfPRow) rowIterator.next(), i)); i++; } for(i = 0; i < this.rows.size(); i++) { ((RtfRow) this.rows.get(i)).handleCellSpanning(); ((RtfRow) this.rows.get(i)).cleanRow(); } this.headerRows = table.getHeaderRows(); // this.headerRows = table.getLastHeaderRow(); this.cellsFitToPage = table.getKeepTogether(); // this.cellsFitToPage = table.isCellsFitPage(); this.tableFitToPage = table.getKeepTogether(); // this.tableFitToPage = table.isTableFitsPage(); // if(!Float.isNaN(table.getOffset())) { // this.offset = (int) (table.getOffset() * 2); // } // if(!Float.isNaN(table.getOffset())) { // this.offset = (int) (table.getOffset() * 2); // } }
/** * Constructs a RtfRow for a Row. * * @param doc The RtfDocument this RtfRow belongs to * @param rtfTable The RtfTable this RtfRow belongs to * @param row The Row this RtfRow is based on * @param rowNumber The number of this row * @since 2.1.3 */ protected RtfRow(RtfDocument doc, RtfTable rtfTable, PdfPRow row, int rowNumber) { super(doc); this.parentTable = rtfTable; this.rowNumber = rowNumber; importRow(row); }