Example usage for com.lowagie.text Document newPage

List of usage examples for com.lowagie.text Document newPage

Introduction

In this page you can find the example usage for com.lowagie.text Document newPage.

Prototype


public boolean newPage() 

Source Link

Document

Signals that an new page has to be started.

Usage

From source file:org.kuali.kfs.module.endow.report.util.AssetStatementReportPrint.java

License:Educational Community License

/**
 * Prints report body for endowment detail
 * /*from  w ww. j  av  a  2  s.c om*/
 * @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 
 * /*  www  . j  a v a  2 s.  co  m*/
 * @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  
 * //from   w  ww  . j ava  2  s. c o  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;
}

From source file:org.kuali.kfs.module.endow.report.util.AssetStatementReportPrint.java

License:Educational Community License

/**
 * Generates the Asset Statement report for Non-Endowed    
 * /*  w w  w .  jav  a2 s .  co  m*/
 * @param transactionStatementReports
 * @param document
 * @return
 */
public boolean printAssetStatementReportBodyForNonEndowedDetail(
        List<AssetStatementReportDataHolder> nonEndowedAssetStatementReportDataHolders, Document document) {

    // for each kemid
    try {
        Font cellFont = regularFont;
        for (AssetStatementReportDataHolder reportData : nonEndowedAssetStatementReportDataHolders) {

            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));

            PdfPCell cellCashEquivalnets = new PdfPCell(new Paragraph("CASH AND EQUIVALENTS", cellFont));
            cellCashEquivalnets.setColspan(6);
            table.addCell(cellCashEquivalnets);

            // report groups 
            printReportGroupForNonEndowedDetail(reportData, document, table, cellFont);

            // total
            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.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;
}

From source file:org.kuali.kfs.module.endow.report.util.TransactionStatementReportPrint.java

License:Educational Community License

/**
 * Generates the Transaction Statement report    
 * // w  ww. j av  a 2  s.c  o  m
 * @param transactionStatementReports
 * @param document
 * @return
 */
public boolean printTransactionStatementReportBody(
        List<TransactionStatementReportDataHolder> transactionStatementReportDataHolders, Document document) {

    // for each kemid
    try {
        Font cellFont = regularFont;
        for (TransactionStatementReportDataHolder transactionStatementReport : transactionStatementReportDataHolders) {

            // new page
            document.newPage();

            // header
            StringBuffer title = new StringBuffer();
            title.append(transactionStatementReport.getInstitution()).append("\n");
            title.append("STATEMENT OF TRANSACTIONS FROM").append("\n");
            title.append(transactionStatementReport.getBeginningDate()).append(" to ")
                    .append(transactionStatementReport.getEndingDate()).append("\n");
            title.append(transactionStatementReport.getKemid()).append("     ")
                    .append(transactionStatementReport.getKemidLongTitle()).append("\n\n");
            Paragraph header = new Paragraph(title.toString());
            header.setAlignment(Element.ALIGN_CENTER);
            document.add(header);

            // report table
            PdfPTable table = new PdfPTable(4);
            table.setWidthPercentage(FULL_TABLE_WIDTH);
            int[] relativeWidths = { 10, 40, 25, 25 };
            table.setWidths(relativeWidths);
            table.getDefaultCell().setPadding(5);

            // table titles
            table.addCell(new Phrase("DATE", titleFont));
            table.addCell(new Phrase("DESCRIPTION", titleFont));
            table.addCell(
                    createCell("INCOME AMOUNT", titleFont, Element.ALIGN_RIGHT, Element.ALIGN_MIDDLE, true));
            table.addCell(
                    createCell("PRINCIPAL AMOUNT", titleFont, Element.ALIGN_RIGHT, Element.ALIGN_MIDDLE, true));

            // beginning cash balance
            table.addCell(new Phrase(transactionStatementReport.getBeginningDate(), cellFont));
            table.addCell(new Phrase("Beginning Cash Balance", cellFont));
            String amount = "";
            amount = formatAmount(transactionStatementReport.getBeginningIncomeCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            amount = formatAmount(transactionStatementReport.getBeginningPrincipalCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));

            // transactions
            List<TransactionArchiveInfo> TransactionArchiveInfoList = transactionStatementReport
                    .getTransactionArchiveInfoList();
            for (TransactionArchiveInfo transactionArchiveInfo : TransactionArchiveInfoList) {
                table.addCell(new Phrase(transactionArchiveInfo.getPostedDate(), cellFont));
                table.addCell(new Phrase(getDescription(transactionArchiveInfo), cellFont));
                amount = formatAmount(transactionArchiveInfo.getTransactionIncomeCash());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
                amount = formatAmount(transactionArchiveInfo.getTransactionPrincipalCash());
                table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            }

            // ending cash balance
            table.addCell(new Phrase(transactionStatementReport.getEndingDate(), cellFont));
            table.addCell(new Phrase("Ending Cash Balance", cellFont));
            amount = formatAmount(transactionStatementReport.getEndingIncomeCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            amount = formatAmount(transactionStatementReport.getEndingPrincipalCash());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));

            document.add(table);

            // footer
            printFooter(transactionStatementReport.getFooter(), document);
        }

    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:org.kuali.kfs.module.endow.report.util.TransactionSummaryReportPrint.java

License:Educational Community License

/**
 * Generates the Transaction Summary report showing all amounts fields.   
 * /*from   w  ww. jav  a  2 s.  com*/
 * @param transactionSummaryReports
 * @param document
 * @return true if document created else return false
 */
public boolean printReportBodyByAllTotalsForDetailReportOption(
        List<TransactionSummaryReportDataHolder> transactionSummaryReportDataHolders, Document document) {

    document.setPageCount(0);

    // for each kemid
    try {
        Font cellFont = regularFont;
        for (TransactionSummaryReportDataHolder transactionSummaryReport : transactionSummaryReportDataHolders) {
            // new page
            document.setPageSize(LETTER_LANDSCAPE);
            document.newPage();

            // header
            writeDocumentHeader(document, transactionSummaryReport);

            // report table column headers
            PdfPTable table = writeDocumentTitleHeadings(EndowConstants.EndowmentReport.DETAIL);

            if (ObjectUtils.isNull(table)) {
                return false;
            }

            // write out Beginning Market value row values
            writeDetailLineRow(table, cellFont, "Beginning Market Value",
                    transactionSummaryReport.getIncomeBeginningMarketValue(),
                    transactionSummaryReport.getPrincipalBeginningMarketValue(),
                    transactionSummaryReport.getTotalBeginningMarketValue());

            // contributions rows
            writeContributionsRecordsForDetailReportOption(table, cellFont, transactionSummaryReport);

            // expenses rows....
            writeExpensesRecordsForDetailReportOption(table, cellFont, transactionSummaryReport);

            // cash transfer rows...
            writeCashTransfersRecordsForDetailReportOption(table, cellFont, transactionSummaryReport);

            // cash transfer rows...
            writeSecurityTransfersRecordsForDetailReportOption(table, cellFont, transactionSummaryReport);

            //write change in market value row....
            writeDetailLineRow(table, cellFont, "Change in Market Value",
                    transactionSummaryReport.getIncomeChangeInMarketValue(),
                    transactionSummaryReport.getPrincipalChangeInMarketValue(),
                    transactionSummaryReport.getTotalChangeInMarketValue());

            //write period end total market value record....
            writeDetailLineRow(table, cellFont, "Period End total Market Value (Include Cash)",
                    transactionSummaryReport.getIncomeEndingMarketValue(),
                    transactionSummaryReport.getPrincipalEndingMarketValue(),
                    transactionSummaryReport.getTotalEndingMarketValue());

            // write out estimate income row
            writeDetailsLineWithTotalAmountOnly(table, cellFont, "Next 12 Months Estimated Income",
                    transactionSummaryReport.getNext12MonthsEstimatedIncome(),
                    EndowConstants.EndowmentReport.DETAIL);

            //write out the remainder FY estimated row...
            writeDetailsLineWithTotalAmountOnly(table, cellFont, "Remainder of Fiscal Year Estimated Income",
                    transactionSummaryReport.getRemainderOfFYEstimatedIncome(),
                    EndowConstants.EndowmentReport.DETAIL);

            //write out the next FY estimated row...
            writeDetailsLineWithTotalAmountOnly(table, cellFont, "Next Fiscal Year Estimated Income",
                    transactionSummaryReport.getNextFYEstimatedIncome(), EndowConstants.EndowmentReport.DETAIL);

            document.add(table);

            //print the footer...
            if (ObjectUtils.isNotNull(transactionSummaryReport.getFooter())) {
                printFooter(transactionSummaryReport.getFooter(), document);
            }
        }

    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:org.kuali.kfs.module.endow.report.util.TransactionSummaryReportPrint.java

License:Educational Community License

/**
 * Generates the Transaction Summary report showing only summary amount field.   
 * This report will only show the total amount field for each kemid
 * @param transactionSummaryReports//from   w w  w  .  ja v a 2 s  .co m
 * @param document
 * @return true if document created else return false
 */
public boolean printReportBodyForDetailReportOption(
        List<TransactionSummaryReportDataHolder> transactionSummaryReportDataHolders, Document document) {

    document.setPageCount(0);

    try {
        Font cellFont = regularFont;
        for (TransactionSummaryReportDataHolder transactionSummaryReport : transactionSummaryReportDataHolders) {
            // new page
            document.setPageSize(LETTER_LANDSCAPE);
            document.newPage();

            // header
            writeDocumentHeader(document, transactionSummaryReport);

            // report table column headers
            PdfPTable table = writeDocumentTitleHeadings(EndowConstants.EndowmentReport.TOTAL);

            if (ObjectUtils.isNull(table)) {
                return false;
            }

            // write out Beginning Market value row values
            writeDetailLineRow(table, cellFont, "Beginning Market Value",
                    transactionSummaryReport.getTotalBeginningMarketValue());

            // contributions rows
            writeContributionsRecordsForSummaryReportOption(table, cellFont, transactionSummaryReport);

            // expenses rows....
            writeExpensesRecordsForSummaryReportOption(table, cellFont, transactionSummaryReport);

            //cash transfers rows..
            writeCashTransfersRecordsForSummaryReportOption(table, cellFont, transactionSummaryReport);

            // security transfer rows...
            writeSecurityTransfersRecordsForSummaryReportOption(table, cellFont, transactionSummaryReport);

            //write change in market value row....
            writeDetailLineRow(table, cellFont, "Change in Market Value",
                    transactionSummaryReport.getTotalChangeInMarketValue());

            //write period end total market value record....
            writeDetailLineRow(table, cellFont, "Period End total Market Value (Include Cash)",
                    transactionSummaryReport.getTotalEndingMarketValue());

            // write out estimate income row
            writeDetailsLineWithTotalAmountOnly(table, cellFont, "Next 12 Months Estimated Income",
                    transactionSummaryReport.getNext12MonthsEstimatedIncome(),
                    EndowConstants.EndowmentReport.TOTAL);

            //write out the remainder FY estimated row...
            writeDetailsLineWithTotalAmountOnly(table, cellFont, "Remainder of Fiscal Year Estimated Income",
                    transactionSummaryReport.getRemainderOfFYEstimatedIncome(),
                    EndowConstants.EndowmentReport.TOTAL);

            //write out the next FY estimated row...
            writeDetailsLineWithTotalAmountOnly(table, cellFont, "Next Fiscal Year Estimated Income",
                    transactionSummaryReport.getNextFYEstimatedIncome(), EndowConstants.EndowmentReport.TOTAL);

            document.add(table);

            //print the footer...
            if (ObjectUtils.isNotNull(transactionSummaryReport.getFooter())) {
                printFooter(transactionSummaryReport.getFooter(), document);
            }
        }

    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:org.kuali.kfs.module.endow.report.util.TrialBalanceReportPrint.java

License:Educational Community License

/**
 * Generates the report in PDF using iText
 * //www  .  ja  v  a2s  .com
 * @param reportRequestHeaderDataHolder
 * @param trialBalanceDataReportHolders
 * @return ByteArrayOutputStream
 */
public ByteArrayOutputStream printTrialBalanceReport(
        EndowmentReportHeaderDataHolder reportRequestHeaderDataHolder,
        List<TrialBalanceReportDataHolder> trialBalanceDataReportHolders, String listKemidsInHeader) {

    final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(TrialBalanceReportPrint.class);

    Document document = new Document();
    document.setPageSize(LETTER_PORTRAIT);
    document.addTitle("Endowment Trial Balance");

    // get the stream for PDF
    ByteArrayOutputStream pdfStream = new ByteArrayOutputStream();

    try {
        PdfWriter.getInstance(document, pdfStream);
        document.open();

        // page
        HeaderFooter header = new HeaderFooter(new Phrase(new Date().toString() + "     Page: ", headerFont),
                true);
        header.setBorder(Rectangle.NO_BORDER);
        header.setAlignment(Element.ALIGN_RIGHT);
        header.setPageNumber(0);
        document.setHeader(header);

        // print the report header
        if (printReportHeaderPage(reportRequestHeaderDataHolder, document, listKemidsInHeader)) {

            if (trialBalanceDataReportHolders != null && trialBalanceDataReportHolders.size() > 0) {
                document.setPageSize(LETTER_LANDSCAPE);
                document.resetPageCount();
                header.setPageNumber(1);
                document.newPage();
                printTrialBalanceReportBody(trialBalanceDataReportHolders, document);
            } else {
                LOG.error("Trial Balance Report Header Error");
            }
        }

        document.close();

    } catch (Exception e) {
        LOG.error("PDF Error: " + e.getMessage());
        return null;
    }

    return pdfStream;
}

From source file:org.kuali.kra.printing.service.impl.PrintingServiceImpl.java

License:Educational Community License

/**
 * @param pdfBytesList/*from   ww w .ja  v a  2  s .  co m*/
 *            List containing the PDF data bytes
 * @param bookmarksList
 *            List of bookmarks corresponding to the PDF bytes.
 * @return
 * @throws PrintingException
 */

protected byte[] mergePdfBytes(List<byte[]> pdfBytesList, List<String> bookmarksList,
        boolean headerFooterRequired) throws PrintingException {
    Document document = null;
    PdfWriter writer = null;
    ByteArrayOutputStream mergedPdfReport = new ByteArrayOutputStream();
    int totalNumOfPages = 0;
    PdfReader[] pdfReaderArr = new PdfReader[pdfBytesList.size()];
    int pdfReaderCount = 0;
    for (byte[] fileBytes : pdfBytesList) {
        LOG.debug("File Size " + fileBytes.length + " For " + bookmarksList.get(pdfReaderCount));
        PdfReader reader = null;
        try {
            reader = new PdfReader(fileBytes);
            pdfReaderArr[pdfReaderCount] = reader;
            pdfReaderCount = pdfReaderCount + 1;
            totalNumOfPages += reader.getNumberOfPages();
        } catch (IOException e) {
            LOG.error(e.getMessage(), e);
        }
    }
    HeaderFooter footer = null;
    if (headerFooterRequired) {
        Calendar calendar = dateTimeService.getCurrentCalendar();
        String dateString = formateCalendar(calendar);
        StringBuilder footerPhStr = new StringBuilder();
        footerPhStr.append(" of ");
        footerPhStr.append(totalNumOfPages);
        footerPhStr.append(getWhitespaceString(WHITESPACE_LENGTH_76));
        footerPhStr.append(getWhitespaceString(WHITESPACE_LENGTH_76));
        footerPhStr.append(getWhitespaceString(WHITESPACE_LENGTH_60));
        footerPhStr.append(dateString);
        Font font = FontFactory.getFont(FontFactory.TIMES, 8, Font.NORMAL, Color.BLACK);
        Phrase beforePhrase = new Phrase("Page ", font);
        Phrase afterPhrase = new Phrase(footerPhStr.toString(), font);
        footer = new HeaderFooter(beforePhrase, afterPhrase);
        footer.setAlignment(Element.ALIGN_BASELINE);
        footer.setBorderWidth(0f);
    }
    for (int count = 0; count < pdfReaderArr.length; count++) {
        PdfReader reader = pdfReaderArr[count];
        int nop;
        if (reader == null) {
            LOG.debug("Empty PDF byetes found for " + bookmarksList.get(count));
            continue;
        } else {
            nop = reader.getNumberOfPages();
        }

        if (count == 0) {
            document = nop > 0 ? new com.lowagie.text.Document(reader.getPageSizeWithRotation(1))
                    : new com.lowagie.text.Document();
            try {
                writer = PdfWriter.getInstance(document, mergedPdfReport);
            } catch (DocumentException e) {
                LOG.error(e.getMessage(), e);
                throw new PrintingException(e.getMessage(), e);
            }
            if (footer != null) {
                document.setFooter(footer);
            }
            // writer.setPageEvent(new Watermark());  //  add watermark object here
            document.open();
        }

        PdfContentByte cb = writer.getDirectContent();
        int pageCount = 0;
        while (pageCount < nop) {
            document.setPageSize(reader.getPageSize(++pageCount));
            document.newPage();
            if (footer != null) {
                document.setFooter(footer);
            }
            PdfImportedPage page = writer.getImportedPage(reader, pageCount);

            cb.addTemplate(page, 1, 0, 0, 1, 0, 0);

            PdfOutline root = cb.getRootOutline();
            if (pageCount == 1) {
                String pageName = bookmarksList.get(count);
                cb.addOutline(new PdfOutline(root, new PdfDestination(PdfDestination.FITH), pageName),
                        pageName);
            }
        }
    }
    if (document != null) {
        try {
            document.close();
            return mergedPdfReport.toByteArray();
        } catch (Exception e) {
            LOG.error("Exception occured because the generated PDF document has no pages", e);
        }
    }
    return null;
}

From source file:org.kuali.ole.describe.controller.EditorController.java

License:Open Source License

private void generateCallSlip(EditorForm editorForm, HttpServletResponse response) {
    LOG.debug("Creating pdf");
    String title = "", author = "", callNumber = "", location = "", copyNumber = "", enumeration = "",
            chronology = "", barcode = "";
    SearchResponse searchResponse = null;
    SearchParams searchParams = new SearchParams();
    SearchField searchField1 = searchParams.buildSearchField("item", "ItemIdentifier_search",
            editorForm.getDocId());/*ww  w. j  a  va  2 s.  com*/
    searchParams.getSearchConditions().add(searchParams.buildSearchCondition("OR", searchField1, "AND"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("bibliographic", "Title"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("bibliographic", "Author"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "CallNumber"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "LocationName"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "CopyNumber"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "enumeration"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "chronology"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("item", "ItemBarcode"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("holdings", "CallNumber"));
    searchParams.getSearchResultFields().add(searchParams.buildSearchResultField("holdings", "LocationName"));
    try {
        searchResponse = getDocstoreClientLocator().getDocstoreClient().search(searchParams);
    } catch (Exception e) {
        LOG.error(e, e);
    }
    if (CollectionUtils.isNotEmpty(searchResponse.getSearchResults())) {
        for (SearchResultField searchResultField : searchResponse.getSearchResults().get(0)
                .getSearchResultFields()) {
            if (searchResultField.getDocType().equalsIgnoreCase(DocType.BIB.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("Title")) {
                if (StringUtils.isBlank(title)) {
                    title = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
                }
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.BIB.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("Author")) {
                if (StringUtils.isBlank(author)) {
                    author = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
                }
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("CallNumber")) {
                callNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("LocationName")) {
                location = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("CopyNumber")) {
                copyNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("enumeration")) {
                enumeration = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue()
                        : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("chronology")) {
                chronology = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.ITEM.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("ItemBarcode")) {
                barcode = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue() : "";
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.HOLDINGS.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("CallNumber")) {
                if (StringUtils.isBlank(callNumber)) {
                    callNumber = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue()
                            : "";
                }
            } else if (searchResultField.getDocType().equalsIgnoreCase(DocType.HOLDINGS.getCode())
                    && searchResultField.getFieldName().equalsIgnoreCase("LocationName")) {
                if (StringUtils.isBlank(location)) {
                    location = searchResultField.getFieldValue() != null ? searchResultField.getFieldValue()
                            : "";
                }
            }
        }
    }
    String fileName = "Call/Paging Slip" + "_" + (editorForm.getTitle() != null ? editorForm.getTitle() : "")
            + "_" + new Date(System.currentTimeMillis()) + ".pdf";
    if (LOG.isInfoEnabled()) {
        LOG.info("File Created :" + title + "file name ::" + fileName + "::");
    }
    try {
        Document document = this.getDocument(0, 0, 5, 5);
        OutputStream outputStream = null;
        response.setContentType("application/pdf");
        //response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
        outputStream = response.getOutputStream();
        PdfWriter.getInstance(document, outputStream);
        Font boldFont = new Font(Font.TIMES_ROMAN, 15, Font.BOLD);
        document.open();
        document.newPage();
        PdfPTable pdfTable = new PdfPTable(3);
        pdfTable.setWidths(new int[] { 20, 2, 30 });
        Paragraph paraGraph = new Paragraph();
        paraGraph.setAlignment(Element.ALIGN_CENTER);
        paraGraph.add(new Chunk("Call/Paging Slip", boldFont));
        paraGraph.add(Chunk.NEWLINE);
        paraGraph.add(Chunk.NEWLINE);
        paraGraph.add(Chunk.NEWLINE);
        document.add(paraGraph);

        pdfTable.addCell(getPdfPCellInJustified("Title"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(title));

        pdfTable.addCell(getPdfPCellInJustified("Author"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(author));

        pdfTable.addCell(getPdfPCellInJustified("Call Number"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(callNumber));

        pdfTable.addCell(getPdfPCellInJustified("Location"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(location));

        pdfTable.addCell(getPdfPCellInJustified("Copy Number"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(copyNumber));

        pdfTable.addCell(getPdfPCellInJustified("Enumeration"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(enumeration));

        pdfTable.addCell(getPdfPCellInJustified("Chronology"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(chronology));

        pdfTable.addCell(getPdfPCellInJustified("Barcode"));
        pdfTable.addCell(getPdfPCellInLeft(":"));
        pdfTable.addCell(getPdfPCellInJustified(barcode));

        document.add(pdfTable);
        document.close();
        outputStream.flush();
        outputStream.close();
    } catch (Exception e) {
        LOG.error(e, e);
    }
}