List of usage examples for com.lowagie.text.pdf PdfPCell PdfPCell
public PdfPCell(PdfPCell cell)
PdfPCell
. From source file:org.goodoldai.jeff.report.pdf.PDFDataChunkBuilder.java
License:Open Source License
/** * This is a private method that is used to insert one dimensional data * content into the PDF document./* w w w .ja v a 2 s .c om*/ * * @param data one dimensional data which needs to be transformed * @param document PDF document in which the transformed data will be * written */ private void inputOneDimDataContent(OneDimData data, Document document) { //Create table with only one column and set some formatting options PdfPTable table = new PdfPTable(1); table.setWidthPercentage(30); table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT); table.setSpacingBefore(15.0F); table.setSpacingAfter(15.0F); //Create the header cell PdfPCell cell1 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension()))); cell1.setBackgroundColor(Color.lightGray); table.addCell(cell1); //Create and insert data cells ArrayList<Object> values = data.getValues(); for (int i = 0; i < values.size(); i++) { table.addCell(new Paragraph(transformValue(values.get(i)))); } try { document.add(table); } catch (DocumentException ex) { throw new ExplanationException(ex.getMessage()); } }
From source file:org.goodoldai.jeff.report.pdf.PDFDataChunkBuilder.java
License:Open Source License
/** * This is a private method that is used to insert two dimensional data * content into the PDF document.//from w w w .ja v a 2s. c o m * * @param data two dimensional data which needs to be transformed * @param document PDF document in which the transformed data will be * written */ private void inputTwoDimDataContent(TwoDimData data, Document document) { //Create table with two columns and set some formatting options PdfPTable table = new PdfPTable(2); table.setWidthPercentage(50); table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT); table.setSpacingBefore(15.0F); table.setSpacingAfter(15.0F); //Create the header cells PdfPCell cell1 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension1()))); cell1.setBackgroundColor(Color.lightGray); table.addCell(cell1); PdfPCell cell2 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension2()))); cell2.setBackgroundColor(Color.lightGray); table.addCell(cell2); //Create and insert data cells ArrayList<Tuple> values = data.getValues(); for (int i = 0; i < values.size(); i++) { Tuple tuple = (Tuple) (values.get(i)); table.addCell(new Paragraph(transformValue(tuple.getValue1()))); table.addCell(new Paragraph(transformValue(tuple.getValue2()))); } try { document.add(table); } catch (DocumentException ex) { throw new ExplanationException(ex.getMessage()); } }
From source file:org.goodoldai.jeff.report.pdf.PDFDataChunkBuilder.java
License:Open Source License
/** * This is a private method that is used to insert three dimensional data * content into the PDF document.//from w w w .ja va2s . c o m * * @param data three dimensional data which needs to be transformed * @param document PDF document in which the transformed data will be * written */ private void inputThreeDimDataContent(ThreeDimData data, Document document) { //Create table with three columns and set some formatting options PdfPTable table = new PdfPTable(3); table.setWidthPercentage(80); table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT); table.setSpacingBefore(15.0F); table.setSpacingAfter(15.0F); //Create the header cells PdfPCell cell1 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension1()))); cell1.setBackgroundColor(Color.lightGray); table.addCell(cell1); PdfPCell cell2 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension2()))); cell2.setBackgroundColor(Color.lightGray); table.addCell(cell2); PdfPCell cell3 = new PdfPCell(new Paragraph(turnDimensionIntoHeader(data.getDimension3()))); cell3.setBackgroundColor(Color.lightGray); table.addCell(cell3); //Create and insert data cells ArrayList<Triple> values = data.getValues(); for (int i = 0; i < values.size(); i++) { Triple triple = (Triple) (values.get(i)); table.addCell(new Paragraph(transformValue(triple.getValue1()))); table.addCell(new Paragraph(transformValue(triple.getValue2()))); table.addCell(new Paragraph(transformValue(triple.getValue3()))); } try { document.add(table); } catch (DocumentException ex) { throw new ExplanationException(ex.getMessage()); } }
From source file:org.gtdfree.addons.PDFExportAddOn.java
License:Open Source License
private PdfPCell newCell(Paragraph p) throws BadElementException { PdfPCell c = new PdfPCell(p); c.setBorder(PdfPCell.BOX);/*from w w w . j a v a 2s .c om*/ c.setBorderWidth(0.1f); c.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); c.setPaddingBottom(3f); c.setPaddingLeft(3f); c.setPaddingRight(3f); c.setPaddingTop(0f); c.setUseBorderPadding(true); return c; }
From source file:org.jboss.as.quickstarts.ejbinwar.ejb.GreeterEJB.java
License:Apache License
public ByteArrayOutputStream generatePDFDocumentBytes(String selectedTariff) throws DocumentException { java.util.Set<String> users = getRestUsers(selectedTariff); Document doc = new Document(); ByteArrayOutputStream baosPDF = new ByteArrayOutputStream(); PdfWriter docWriter = null;//from w w w. jav a 2s.c o m try { docWriter = PdfWriter.getInstance(doc, baosPDF); doc.addAuthor(this.getClass().getName()); doc.addCreationDate(); doc.addProducer(); doc.addCreator(this.getClass().getName()); doc.addTitle(selectedTariff + " clients"); doc.addKeywords("pdf, itext, Java, ecare, http"); doc.setPageSize(PageSize.LETTER); HeaderFooter footer = new HeaderFooter(new Phrase("E-Care report"), false); doc.setFooter(footer); doc.open(); doc.add(new Paragraph(selectedTariff + " clients")); doc.add(new Paragraph("\n")); doc.add(new Paragraph("\n")); PdfPTable table = new PdfPTable(4); // 3 columns. PdfPCell cell1 = new PdfPCell(new Paragraph("Name")); PdfPCell cell2 = new PdfPCell(new Paragraph("Surname")); PdfPCell cell3 = new PdfPCell(new Paragraph("Address")); PdfPCell cell4 = new PdfPCell(new Paragraph("Email")); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); for (Iterator<String> it = users.iterator(); it.hasNext();) { String user = it.next(); table.addCell(new PdfPCell(new Paragraph(user.split(" ")[0]))); table.addCell(new PdfPCell(new Paragraph(user.split(" ")[1]))); table.addCell(new PdfPCell(new Paragraph(user.split(" ")[2]))); table.addCell(new PdfPCell(new Paragraph(user.split(" ")[3]))); } doc.add(table); } catch (DocumentException dex) { baosPDF.reset(); throw dex; } finally { if (doc != null) { doc.close(); } if (docWriter != null) { docWriter.close(); } } if (baosPDF.size() < 1) { throw new DocumentException("document has " + baosPDF.size() + " bytes"); } return baosPDF; }
From source file:org.jmesa.view.pdfp.PdfPView.java
License:Apache License
@Override public PdfPTable render() { PdfPTable pdfpTable = new PdfPTable(getTable().getRow().getColumns().size()); pdfpTable.setSpacingBefore(3);//w ww. java 2 s . c om Row row = getTable().getRow(); List<Column> columns = row.getColumns(); // build table headers for (Iterator<Column> iter = columns.iterator(); iter.hasNext();) { Column column = iter.next(); PdfPCell cell = new PdfPCell(new Paragraph(column.getTitle(), getHeaderCellFont())); cell.setPadding(3.0f); cell.setBackgroundColor(getHeaderBackgroundColor()); pdfpTable.addCell(cell); } // build table body Collection<?> items = getCoreContext().getPageItems(); int rowcount = 0; for (Object item : items) { rowcount++; columns = row.getColumns(); for (Iterator<Column> iter = columns.iterator(); iter.hasNext();) { Column column = iter.next(); String property = column.getProperty(); Object value = column.getCellEditor().getValue(item, property, rowcount); PdfPCell cell = new PdfPCell( new Paragraph(value == null ? "" : String.valueOf(value), getCellFont())); cell.setPadding(3.0f); if (isRowEven(rowcount)) { cell.setBackgroundColor(getEvenCellBackgroundColor()); } else { cell.setBackgroundColor(getOddCellBackgroundColor()); } pdfpTable.addCell(cell); } } return pdfpTable; }
From source file:org.kuali.kfs.gl.report.TransactionReport.java
License:Open Source License
/** * Appends the scrubber totals/statistics and error report to the given (iText) document object. * // ww w.ja v a 2s . co m * @param document the PDF document * @param headerFont font for header * @param textFont font for report text * @param errorSortedList list of error'd transactions * @param reportErrors map containing transactions and the errors associated with each transaction * @param reportSummary list of summary objects * @param runDate date report was run * @throws DocumentException */ public void appendReport(Document document, Font headerFont, Font textFont, List<Transaction> errorSortedList, Map<Transaction, List<Message>> reportErrors, List<Summary> reportSummary, Date runDate) throws DocumentException { // Sort what we get Collections.sort(reportSummary); float[] summaryWidths = { 80, 20 }; PdfPTable summary = new PdfPTable(summaryWidths); summary.setWidthPercentage(40); PdfPCell cell = new PdfPCell(new Phrase("S T A T I S T I C S", headerFont)); cell.setColspan(2); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); summary.addCell(cell); for (Iterator iter = reportSummary.iterator(); iter.hasNext();) { Summary s = (Summary) iter.next(); cell = new PdfPCell(new Phrase(s.getDescription(), textFont)); cell.setBorder(Rectangle.NO_BORDER); summary.addCell(cell); if ("".equals(s.getDescription())) { cell = new PdfPCell(new Phrase("", textFont)); cell.setBorder(Rectangle.NO_BORDER); summary.addCell(cell); } else { DecimalFormat nf = new DecimalFormat("###,###,###,##0"); cell = new PdfPCell(new Phrase(nf.format(s.getCount()), textFont)); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); summary.addCell(cell); } } cell = new PdfPCell(new Phrase("")); cell.setColspan(2); cell.setBorder(Rectangle.NO_BORDER); summary.addCell(cell); document.add(summary); if (reportErrors != null && reportErrors.size() > 0) { float[] warningWidths = { 4, 3, 6, 5, 5, 4, 5, 5, 4, 5, 5, 9, 4, 36 }; PdfPTable warnings = new PdfPTable(warningWidths); warnings.setHeaderRows(2); warnings.setWidthPercentage(100); cell = new PdfPCell(new Phrase("W A R N I N G S", headerFont)); cell.setColspan(14); cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); warnings.addCell(cell); // Add headers cell = new PdfPCell(new Phrase("Year", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("COA", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("Account", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("Sacct", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("Obj", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("SObj", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("BalTyp", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("ObjTyp", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("Prd", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("DocType", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("Origin", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("DocNbr", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("Seq", headerFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase("Warning", headerFont)); warnings.addCell(cell); for (Iterator errorIter = errorSortedList.iterator(); errorIter.hasNext();) { Transaction tran = (Transaction) errorIter.next(); boolean first = true; List errors = (List) reportErrors.get(tran); for (Iterator listIter = errors.iterator(); listIter.hasNext();) { String msg = null; Object m = listIter.next(); if (m instanceof Message) { Message mm = (Message) m; msg = mm.getMessage(); } else { if (m == null) { msg = ""; } else { msg = m.toString(); } } if (first) { first = false; if (tran.getUniversityFiscalYear() == null) { cell = new PdfPCell(new Phrase("NULL", textFont)); } else { cell = new PdfPCell(new Phrase(tran.getUniversityFiscalYear().toString(), textFont)); } warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getChartOfAccountsCode(), textFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getAccountNumber(), textFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getSubAccountNumber(), textFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getFinancialObjectCode(), textFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getFinancialSubObjectCode(), textFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getFinancialBalanceTypeCode(), textFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getFinancialObjectTypeCode(), textFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getUniversityFiscalPeriodCode(), textFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getFinancialDocumentTypeCode(), textFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getFinancialSystemOriginationCode(), textFont)); warnings.addCell(cell); cell = new PdfPCell(new Phrase(tran.getDocumentNumber(), textFont)); warnings.addCell(cell); if (tran.getTransactionLedgerEntrySequenceNumber() == null) { cell = new PdfPCell(new Phrase("NULL", textFont)); } else { cell = new PdfPCell(new Phrase( tran.getTransactionLedgerEntrySequenceNumber().toString(), textFont)); } warnings.addCell(cell); } else { cell = new PdfPCell(new Phrase("", textFont)); cell.setColspan(13); warnings.addCell(cell); } cell = new PdfPCell(new Phrase(msg, textFont)); warnings.addCell(cell); } } document.add(warnings); } }
From source file:org.kuali.kfs.module.endow.report.util.AssetStatementReportPrint.java
License:Educational Community License
/** * Prints report body for endowment detail * //from w w w. ja v a2s . com * @param endowmentAssetStatementReportDataHolders * @param document * @return */ public boolean printAssetStatementReportBodyForEndowmentTotal( List<AssetStatementReportDataHolder> endowmentAssetStatementReportDataHolders, Document document) { BigDecimal totalHistoryIncomeCash = BigDecimal.ZERO; BigDecimal totalHistoryPrincipalCash = BigDecimal.ZERO; TreeMap<Integer, TreeMap<String, List<ReportGroupData>>> reportGroupsForIncomeTotal = null; TreeMap<Integer, TreeMap<String, List<ReportGroupData>>> reportGroupsForPrincipalTotal = null; // get the cash totals for (AssetStatementReportDataHolder data : endowmentAssetStatementReportDataHolders) { totalHistoryIncomeCash = totalHistoryIncomeCash.add(data.getHistoryIncomeCash()); totalHistoryPrincipalCash = totalHistoryPrincipalCash.add(data.getHistoryPrincipalCash()); } // for income reportGroupsForIncomeTotal = createReportGroupsForTotal(endowmentAssetStatementReportDataHolders, IncomePrincipalIndicator.INCOME); // for principal reportGroupsForPrincipalTotal = createReportGroupsForTotal(endowmentAssetStatementReportDataHolders, IncomePrincipalIndicator.PRINCIPAL); // for each kemid try { Font cellFont = regularFont; // for the common info AssetStatementReportDataHolder reportData = endowmentAssetStatementReportDataHolders.get(0); document.newPage(); // header StringBuffer title = new StringBuffer(); title.append(reportData.getInstitution()).append("\n"); title.append("STATEMENT OF ASSETS FOR PERIOD ENDING").append("\n"); title.append(reportData.getMonthEndDate()).append("\n\n"); Paragraph header = new Paragraph(title.toString()); header.setAlignment(Element.ALIGN_CENTER); document.add(header); // report table float[] colsWidth = { 15f, 17f, 17f, 17f, 17f, 17f }; PdfPTable table = new PdfPTable(colsWidth); table.setWidthPercentage(FULL_TABLE_WIDTH); table.getDefaultCell().setPadding(5); // column titles table.addCell(""); table.addCell(createCell("UNITS HELD", titleFont, Element.ALIGN_RIGHT, true)); table.addCell(createCell("MARKET VALUE", titleFont, Element.ALIGN_RIGHT, true)); table.addCell(createCell("ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true)); table.addCell( createCell("FY REMAINDER ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true)); table.addCell(createCell("NEXT FY ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true)); // 1. Expendable funds PdfPCell cellExpendableFunds = new PdfPCell(new Paragraph("EXPENDABLE FUNDS", titleFont)); cellExpendableFunds.setColspan(6); table.addCell(cellExpendableFunds); PdfPCell cellCashEquivalnets = new PdfPCell(new Paragraph("CASH AND EQUIVALENTS", titleFont)); cellCashEquivalnets.setColspan(6); table.addCell(cellCashEquivalnets); // report groups for income printReportGroupForIncomeEndowmentTotal(reportGroupsForIncomeTotal, totalHistoryIncomeCash, document, table, cellFont); // 2. Endowed funds PdfPCell cellEndowedFunds = new PdfPCell(new Paragraph("ENDOWED FUNDS", titleFont)); cellEndowedFunds.setColspan(6); table.addCell(cellEndowedFunds); table.addCell(cellCashEquivalnets); // report groups for principal printReportGroupForPrincipalEndowmentTotal(reportGroupsForPrincipalTotal, totalHistoryPrincipalCash, document, table, cellFont); // 3. total (endowment + non-endowed) PdfPCell blank = new PdfPCell(new Paragraph("", cellFont)); blank.setColspan(6); blank.setBackgroundColor(Color.LIGHT_GRAY); table.addCell(blank); BigDecimal totalKemidMarketValue = BigDecimal.ZERO; BigDecimal totalKemidEstimatedAnnualIncome = BigDecimal.ZERO; BigDecimal totalKemidFYRemainderEstimatedAnnualIncome = BigDecimal.ZERO; BigDecimal totalKemidNextFYEstimayedAnnualIncome = BigDecimal.ZERO; for (AssetStatementReportDataHolder data : endowmentAssetStatementReportDataHolders) { totalKemidMarketValue = totalKemidMarketValue .add(data.getTotalSumOfMarketValue(IncomePrincipalIndicator.INCOME) .add(data.getTotalSumOfMarketValue(IncomePrincipalIndicator.PRINCIPAL))); totalKemidEstimatedAnnualIncome = totalKemidEstimatedAnnualIncome .add(data.getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.INCOME) .add(data.getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.PRINCIPAL))); totalKemidFYRemainderEstimatedAnnualIncome = totalKemidFYRemainderEstimatedAnnualIncome .add(data.getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.INCOME) .add(data.getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.PRINCIPAL))); totalKemidNextFYEstimayedAnnualIncome = totalKemidNextFYEstimayedAnnualIncome .add(data.getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.INCOME) .add(data.getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.PRINCIPAL))); } table.addCell(new Paragraph("TOTAL KEMID VALUE", titleFont)); table.addCell(""); table.addCell(getAmountCell( totalKemidMarketValue.add(totalHistoryIncomeCash).add(totalHistoryPrincipalCash), titleFont)); table.addCell(getAmountCell(totalKemidEstimatedAnnualIncome, titleFont)); table.addCell(getAmountCell(totalKemidFYRemainderEstimatedAnnualIncome, titleFont)); table.addCell(getAmountCell(totalKemidNextFYEstimayedAnnualIncome, titleFont)); document.add(table); } catch (Exception e) { LOG.error(e.getMessage()); return false; } return true; }
From source file:org.kuali.kfs.module.endow.report.util.AssetStatementReportPrint.java
License:Educational Community License
/** * Generates the Asset Statement report for Non-Endowed total * /* ww w . java2 s . c om*/ * @param transactionStatementReports * @param document * @return */ public boolean printAssetStatementReportBodyForNonEndowedTotal( List<AssetStatementReportDataHolder> nonEndowedAssetStatementReportDataHolders, Document document) { BigDecimal totalHistoryIncomeCash = BigDecimal.ZERO; BigDecimal totalHistoryPrincipalCash = BigDecimal.ZERO; TreeMap<Integer, TreeMap<String, List<ReportGroupData>>> reportGroupsForTotal = null; // get the cash totals for (AssetStatementReportDataHolder data : nonEndowedAssetStatementReportDataHolders) { totalHistoryIncomeCash = totalHistoryIncomeCash.add(data.getHistoryIncomeCash()); totalHistoryPrincipalCash = totalHistoryPrincipalCash.add(data.getHistoryPrincipalCash()); } reportGroupsForTotal = createReportGroupsForTotal(nonEndowedAssetStatementReportDataHolders, IncomePrincipalIndicator.INCOME); // for each kemid try { Font cellFont = regularFont; // for the common info AssetStatementReportDataHolder reportData = nonEndowedAssetStatementReportDataHolders.get(0); document.newPage(); // header StringBuffer title = new StringBuffer(); title.append(reportData.getInstitution()).append("\n"); title.append("STATEMENT OF ASSETS FOR PERIOD ENDING").append("\n"); title.append(reportData.getMonthEndDate()).append("\n\n"); Paragraph header = new Paragraph(title.toString()); header.setAlignment(Element.ALIGN_CENTER); document.add(header); // report table float[] colsWidth = { 15f, 17f, 17f, 17f, 17f, 17f }; PdfPTable table = new PdfPTable(colsWidth); table.setWidthPercentage(FULL_TABLE_WIDTH); table.getDefaultCell().setPadding(5); // column titles table.addCell(""); table.addCell(createCell("UNITS HELD", titleFont, Element.ALIGN_RIGHT, true)); table.addCell(createCell("MARKET VALUE", titleFont, Element.ALIGN_RIGHT, true)); table.addCell(createCell("ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true)); table.addCell( createCell("FY REMAINDER ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true)); table.addCell(createCell("NEXT FY ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true)); PdfPCell cellCashEquivalnets = new PdfPCell(new Paragraph("CASH AND EQUIVALENTS", titleFont)); cellCashEquivalnets.setColspan(6); table.addCell(cellCashEquivalnets); // report groups printReportGroupForNonEndowedTotal(reportGroupsForTotal, totalHistoryIncomeCash, totalHistoryPrincipalCash, document, table, cellFont); // total PdfPCell blank = new PdfPCell(new Paragraph("", cellFont)); blank.setColspan(6); blank.setBackgroundColor(Color.LIGHT_GRAY); table.addCell(blank); BigDecimal totalKemidMarketValue = BigDecimal.ZERO; BigDecimal totalKemidEstimatedAnnualIncome = BigDecimal.ZERO; BigDecimal totalKemidFYRemainderEstimatedAnnualIncome = BigDecimal.ZERO; BigDecimal totalKemidNextFYEstimayedAnnualIncome = BigDecimal.ZERO; for (AssetStatementReportDataHolder data : nonEndowedAssetStatementReportDataHolders) { totalKemidMarketValue = totalKemidMarketValue .add(data.getTotalSumOfMarketValue(IncomePrincipalIndicator.INCOME)); totalKemidEstimatedAnnualIncome = totalKemidEstimatedAnnualIncome .add(data.getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.INCOME)); totalKemidFYRemainderEstimatedAnnualIncome = totalKemidFYRemainderEstimatedAnnualIncome .add(totalKemidFYRemainderEstimatedAnnualIncome .add(data.getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.INCOME))); totalKemidNextFYEstimayedAnnualIncome = totalKemidNextFYEstimayedAnnualIncome .add(data.getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.INCOME)); } table.addCell(new Paragraph("TOTAL KEMID VALUE", titleFont)); table.addCell(""); table.addCell(getAmountCell( totalKemidMarketValue.add(totalHistoryIncomeCash).add(totalHistoryPrincipalCash), titleFont)); table.addCell(getAmountCell(totalKemidEstimatedAnnualIncome, titleFont)); table.addCell(getAmountCell(totalKemidFYRemainderEstimatedAnnualIncome, titleFont)); table.addCell(getAmountCell(totalKemidNextFYEstimayedAnnualIncome, titleFont)); document.add(table); } catch (Exception e) { LOG.error(e.getMessage()); return false; } return true; }
From source file:org.kuali.kfs.module.endow.report.util.AssetStatementReportPrint.java
License:Educational Community License
/** * Generates the Asset Statement report for Endowment detail * /*ww w .j a va 2 s . co m*/ * @param transactionStatementReports * @param document * @return */ public boolean printAssetStatementReportBodyForEndowmentDetail( List<AssetStatementReportDataHolder> endowmentAssetStatementReportDataHolders, Document document) { // for each kemid try { Font cellFont = regularFont; for (AssetStatementReportDataHolder reportData : endowmentAssetStatementReportDataHolders) { document.newPage(); // header StringBuffer title = new StringBuffer(); title.append(reportData.getInstitution()).append("\n"); title.append("STATEMENT OF ASSETS FOR PERIOD ENDING").append("\n"); title.append(reportData.getMonthEndDate()).append("\n"); title.append(reportData.getKemid()).append(" ").append(reportData.getKemidLongTitle()) .append("\n\n"); Paragraph header = new Paragraph(title.toString()); header.setAlignment(Element.ALIGN_CENTER); document.add(header); // report table float[] colsWidth = { 15f, 17f, 17f, 17f, 17f, 17f }; PdfPTable table = new PdfPTable(colsWidth); table.setWidthPercentage(FULL_TABLE_WIDTH); table.getDefaultCell().setPadding(5); // column titles table.addCell(""); table.addCell(createCell("UNITS HELD", titleFont, Element.ALIGN_RIGHT, true)); table.addCell(createCell("MARKET VALUE", titleFont, Element.ALIGN_RIGHT, true)); table.addCell(createCell("ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true)); table.addCell( createCell("FY REMAINDER ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true)); table.addCell(createCell("NEXT FY ESTIMATED\nANNUAL INCOME", titleFont, Element.ALIGN_RIGHT, true)); // 1. Expendable funds PdfPCell cellExpendableFunds = new PdfPCell(new Paragraph("EXPENDABLE FUNDS", titleFont)); cellExpendableFunds.setColspan(6); //cellExpendableFunds.setBackgroundColor(Color.LIGHT_GRAY); table.addCell(cellExpendableFunds); PdfPCell cellCashEquivalnets = new PdfPCell(new Paragraph("CASH AND EQUIVALENTS", cellFont)); cellCashEquivalnets.setColspan(6); table.addCell(cellCashEquivalnets); // report groups printReportGroupForIncomeEndowmentDetail(reportData, document, table, cellFont); // 2. Endowed funds PdfPCell cellEndowedFunds = new PdfPCell(new Paragraph("ENDOWED FUNDS", titleFont)); cellEndowedFunds.setColspan(6); //cellEndowedFunds.setBackgroundColor(Color.LIGHT_GRAY); table.addCell(cellEndowedFunds); table.addCell(cellCashEquivalnets); printReportGroupForPrincipalEndowmentDetail(reportData, document, table, cellFont); // 3. total (endowment + non-endowed) PdfPCell blank = new PdfPCell(new Paragraph("", cellFont)); blank.setColspan(6); blank.setBackgroundColor(Color.LIGHT_GRAY); table.addCell(blank); BigDecimal totalKemidMarketValue = reportData .getTotalSumOfMarketValue(IncomePrincipalIndicator.INCOME) .add(reportData.getHistoryIncomeCash()) .add(reportData.getTotalSumOfMarketValue(IncomePrincipalIndicator.PRINCIPAL) .add(reportData.getHistoryPrincipalCash())); BigDecimal totalKemidEstimatedAnnualIncome = reportData .getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.INCOME) .add(reportData.getTotalSumOfEstimatedIncome(IncomePrincipalIndicator.PRINCIPAL)); BigDecimal totalKemidFYRemainderEstimatedAnnualIncome = reportData .getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.INCOME) .add(reportData.getTotalSumOfRemainderOfFYEstimated(IncomePrincipalIndicator.PRINCIPAL)); BigDecimal totalKemidNextFYEstimayedAnnualIncome = reportData .getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.INCOME) .add(reportData.getTotalSumOfNextFYEstimatedIncome(IncomePrincipalIndicator.PRINCIPAL)); table.addCell(new Paragraph("TOTAL KEMID VALUE", titleFont)); table.addCell(""); table.addCell(getAmountCell(totalKemidMarketValue, titleFont)); table.addCell(getAmountCell(totalKemidEstimatedAnnualIncome, titleFont)); table.addCell(getAmountCell(totalKemidFYRemainderEstimatedAnnualIncome, titleFont)); table.addCell(getAmountCell(totalKemidNextFYEstimayedAnnualIncome, titleFont)); document.add(table); // footer printFooter(reportData.getFooter(), document); } } catch (Exception e) { LOG.error(e.getMessage()); return false; } return true; }