List of usage examples for com.lowagie.text Table addCell
public void addCell(String content) throws BadElementException
Cell
to the Table
. From source file:org.inbio.modeling.core.manager.impl.ExportManagerImpl.java
License:Open Source License
private void addTableRow(Table t, String title, String value) throws BadElementException { // Fonts Definition Font boldFont = new Font(Font.TIMES_ROMAN, 12, Font.BOLD); Cell cell = new Cell(new Chunk(title, boldFont)); cell.setHeader(true);/*from w w w . j a va2 s .c o m*/ t.addCell(cell); t.addCell(value); }
From source file:org.inbio.modeling.core.manager.impl.ExportManagerImpl.java
License:Open Source License
private void addTableHeader(Table t, String text) throws BadElementException { Chunk chunk = new Chunk(text, new Font(Font.TIMES_ROMAN, 15, Font.BOLD)); Cell cell = new Cell(chunk); cell.setHorizontalAlignment(Cell.ALIGN_CENTER); cell.setHeader(true);//from w ww. j a va 2s . co m cell.setColspan(2); t.addCell(cell); }
From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java
License:Open Source License
/** * This method adds the log lines into the report * /*w w w. j a v a 2s . co m*/ * @param reportLog */ private void generateReportLogBody(List<String[]> reportLog) { try { Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL); int columnwidths[]; columnwidths = new int[] { 40, 15 }; Table aTable = new Table(2, linesPerPage); int rowsWritten = 0; for (String[] columns : reportLog) { if (pageNumber == 0 || line >= linesPerPage) { if (pageNumber > 0) { this.document.add(aTable); } int elementsLeft = reportLog.size() - rowsWritten; int rowsNeeded = (elementsLeft >= linesPerPage ? linesPerPage : elementsLeft); this.document.newPage(); this.generateColumnHeaders(); aTable = new Table(2, rowsNeeded); // 12 columns, 11 rows. aTable.setAutoFillEmptyCells(true); aTable.setPadding(3); aTable.setWidths(columnwidths); aTable.setWidth(100); aTable.setBorder(Rectangle.NO_BORDER); line = 0; pageNumber++; } rowsWritten++; Cell cell; cell = new Cell(new Phrase(columns[0], font)); cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable.addCell(cell); cell = new Cell(new Phrase(columns[1], font)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); aTable.addCell(cell); line++; } this.document.add(aTable); } catch (DocumentException de) { throw new RuntimeException( "DepreciationReport.generateReportLogBody(List<String[]> reportLog) - error: " + de.getMessage()); } }
From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java
License:Open Source License
/** * This method creates a report group for the error message on the report * /* ww w . j a v a 2 s . c o m*/ * @throws DocumentException */ private void generateErrorColumnHeaders() throws DocumentException { try { int headerwidths[] = { 60 }; Table aTable = new Table(1, 1); // 2 columns, 1 rows. aTable.setAutoFillEmptyCells(true); aTable.setPadding(3); aTable.setWidths(headerwidths); aTable.setWidth(100); Cell cell; Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL); cell = new Cell(new Phrase("Error(s)", font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setGrayFill(0.9f); aTable.addCell(cell); this.document.add(aTable); } catch (Exception e) { throw new RuntimeException( "DepreciationReport.generateErrorColumnHeaders() - Error: " + e.getMessage()); } }
From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java
License:Open Source License
/** * This method creates the headers for the report statistics *///from w w w . j a v a2 s .c o m private void generateColumnHeaders() { try { int headerwidths[] = { 40, 15 }; Table aTable = new Table(2, 1); // 2 columns, 1 rows. aTable.setAutoFillEmptyCells(true); aTable.setPadding(3); aTable.setWidths(headerwidths); aTable.setWidth(100); Cell cell; Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL); cell = new Cell(new Phrase(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString( CamsKeyConstants.Depreciation.MSG_REPORT_DEPRECIATION_HEADING1), font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setGrayFill(0.9f); aTable.addCell(cell); cell = new Cell(new Phrase(SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString( CamsKeyConstants.Depreciation.MSG_REPORT_DEPRECIATION_HEADING2), font)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setGrayFill(0.9f); aTable.addCell(cell); this.document.add(aTable); } catch (Exception e) { throw new RuntimeException("DepreciationReport.generateColumnHeaders() - Error: " + e.getMessage()); } }
From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java
License:Open Source License
/** * Get the PDF Table containing trip information like trip id, date, and destination * * @returns {@link Table} used for a PDF *///from ww w . jav a2 s .c o m protected Table getTripInfo() throws BadElementException { final Table retval = new Table(3); retval.setWidth(100f); retval.setBorder(NO_BORDER); retval.addCell(getHeaderCell("Trip/Event ID")); final Cell dateHeaderCell = getHeaderCell("Date"); retval.addCell(dateHeaderCell); retval.addCell(getHeaderCell("Destination/Event Name")); retval.endHeaders(); retval.addCell(getBorderlessCell(getTripId())); final Cell dateCell = getBorderlessCell(getDate()); retval.addCell(dateCell); retval.addCell(getBorderlessCell(getDestination())); return retval; }
From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java
License:Open Source License
/** * Get the PDF Table with personal information about the initiator and traveler * * @returns {@link Table} used for a PDF */// w w w. j av a 2 s . co m protected Table getPersonalInfo() throws BadElementException { final Table retval = new Table(2); retval.setWidth(100f); retval.setBorder(NO_BORDER); retval.addCell(getHeaderCell("Traveler")); final Cell initiatorHeaderCell = getHeaderCell("Request Submitted By"); retval.addCell(initiatorHeaderCell); retval.endHeaders(); retval.addCell(getTravelerInfo()); final Cell initiatorCell = getInitiatorInfo(); retval.addCell(initiatorCell); return retval; }
From source file:org.kuali.kfs.module.tem.pdf.Coversheet.java
License:Open Source License
public Table getExpenses() throws BadElementException { final Table retval = new Table(3); retval.setWidth(100f);//from w ww.j a v a2s. c o m retval.setBorder(NO_BORDER); retval.addCell(getHeaderCell("Expenses")); retval.addCell(getHeaderCell("Amount")); retval.addCell(getHeaderCell("Receipt Required?")); retval.endHeaders(); for (final Map<String, String> expense : expenses) { retval.addCell(getBorderlessCell(expense.get("expenseType"))); retval.addCell(getBorderlessCell(expense.get("amount"))); retval.addCell(getBorderlessCell(expense.get("receipt"))); } return retval; }
From source file:org.netxilia.server.rest.pdf.SheetPdfProvider.java
License:Open Source License
/** * Generates the header cells, which persist on every page of the PDF document. * /*from www . java 2 s .c o m*/ * @throws BadElementException * IText exception * @throws NetxiliaBusinessException * @throws NetxiliaResourceException */ protected void generateHeaders(ISheet sheet, Table tablePDF, Font font, int columnCount) throws BadElementException, NetxiliaResourceException, NetxiliaBusinessException { Cell hdrCell = getCell("", font, Element.ALIGN_CENTER, 50); hdrCell.setGrayFill(0.9f); hdrCell.setHeader(true); tablePDF.addCell(hdrCell); List<ColumnData> columnData = sheet.receiveColumns(Range.ALL).getNonBlocking(); for (int i = 0; i < columnCount; ++i) { ColumnData column = i < columnData.size() ? columnData.get(i) : null; hdrCell = getCell(CellReference.columnLabel(i), font, Element.ALIGN_CENTER, column != null ? column.getWidth() : 120); hdrCell.setGrayFill(0.9f); hdrCell.setHeader(true); tablePDF.addCell(hdrCell); } }
From source file:org.netxilia.server.rest.pdf.SheetPdfProvider.java
License:Open Source License
/** * Generates all the row cells.// w w w.j ava 2 s . c om * * @throws JspException * for errors during value retrieving from the table model * @throws BadElementException * errors while generating content * @throws NetxiliaBusinessException * @throws NetxiliaResourceException */ protected void generateRows(ISheet sheet, boolean summarySheet, Table tablePDF, Font font, int columnCount) throws JspException, BadElementException, NetxiliaResourceException, NetxiliaBusinessException { Styles rightAlign = Styles.styles("a-r"); List<RowData> rowData = sheet.receiveRows(Range.ALL).getNonBlocking(); List<ColumnData> columnData = sheet.receiveColumns(Range.ALL).getNonBlocking(); Matrix<CellData> cellData = sheet.receiveCells(AreaReference.ALL).getNonBlocking(); for (RowData row : rowData) { String rowHdr = ""; if (summarySheet) { rowHdr += "S"; } rowHdr += Integer.toString(row.getIndex() + 1); Cell rowHdrCell = getCell(rowHdr, font, Element.ALIGN_LEFT, -1); rowHdrCell.setGrayFill(0.9f); tablePDF.addCell(rowHdrCell); int c = 0; for (CellData cell : cellData.getRow(row.getIndex())) { RichValue formattedValue = styleService.formatCell(sheet.getWorkbook().getId(), cell, rowData.get(cell.getReference().getRowIndex()), columnData.get(cell.getReference().getColumnIndex())); // TODO check for aligns int horizAlign = Element.ALIGN_LEFT; if (formattedValue.getStyles() != null && formattedValue.getStyles().contains(rightAlign)) { horizAlign = Element.ALIGN_RIGHT; } Cell pdfCell = getCell(formattedValue.getDisplay(), font, horizAlign, -1); tablePDF.addCell(pdfCell); c++; } for (; c < columnCount; ++c) { tablePDF.addCell(getCell("", font, Element.ALIGN_LEFT, -1)); } } }