Example usage for com.lowagie.text Element ALIGN_RIGHT

List of usage examples for com.lowagie.text Element ALIGN_RIGHT

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_RIGHT.

Prototype

int ALIGN_RIGHT

To view the source code for com.lowagie.text Element ALIGN_RIGHT.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

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

License:Educational Community License

/**
 * Generates the Transaction Statement report    
 * //from  w w w.  ja  v  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 report in PDF using iText
 * /*from ww w. j  a  v  a  2 s  .c  o m*/
 * @param reportRequestHeaderDataHolder
 * @param transactionStatementDataReportHolders
 * @return pdfStream
 */
public ByteArrayOutputStream printTransactionSummaryReport(
        EndowmentReportHeaderDataHolder reportRequestHeaderDataHolder,
        List<TransactionSummaryReportDataHolder> transactionSummaryDataReportHolders, String listKemidsInHeader,
        String reportOption, String summaryTotalsOnly) {
    Document document = new Document();
    document.setPageSize(LETTER_PORTRAIT);
    document.addTitle("Endowment Transaction Summary");

    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 (transactionSummaryDataReportHolders != null && transactionSummaryDataReportHolders.size() > 0) {
                if ("Y".equalsIgnoreCase(summaryTotalsOnly)) {
                    printReportBodyBySummaryTotals(transactionSummaryDataReportHolders, document, reportOption);
                } else {
                    printReportBodyByAllTotals(transactionSummaryDataReportHolders, document, reportOption);
                }
            }
        } else {
            LOG.error("Transaction Summary Report Header Error");
        }

        document.close();

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

    return pdfStream;
}

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

License:Educational Community License

/**
 * Helper method to write the details line.
 * /*from   ww w  . j a v  a 2  s  .co  m*/
 * @param table
 * @param cellFont
 * @param description
 * @param incomeAmount
 * @param principalAmount
 * @param totalAmount
 */
protected void writeDetailLineRow(PdfPTable table, Font cellFont, String description, BigDecimal incomeAmount,
        BigDecimal principalAmount, BigDecimal totalAmount) {
    table.addCell("\t\t".concat(description));
    table.addCell(createCell(formatAmount(incomeAmount), cellFont, Element.ALIGN_RIGHT, true));
    table.addCell(createCell(formatAmount(principalAmount), cellFont, Element.ALIGN_RIGHT, true));
    table.addCell(createCell(formatAmount(totalAmount), cellFont, Element.ALIGN_RIGHT, true));
}

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

License:Educational Community License

/**
 * Helper method to write the details line.
 * /*from w w w .j av  a  2  s  .  c  om*/
 * @param table
 * @param cellFont
 * @param description
 * @param incomeAmount
 * @param principalAmount
 * @param totalAmount
 */
protected void writeDetailLineRow(PdfPTable table, Font cellFont, String description, BigDecimal totalAmount) {
    table.addCell("\t\t".concat(description));
    table.addCell(createCell(formatAmount(totalAmount), cellFont, Element.ALIGN_RIGHT, true));
}

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

License:Educational Community License

/**
 * Helper method to go through the contributions list and write the lines..
 * @param table/*from   ww w .  j a v a 2  s . co m*/
 * @param cellFont
 * @param transactionSummaryReport
 */
protected void writeContributionsRecordsForDetailReportOption(PdfPTable table, Font cellFont,
        TransactionSummaryReportDataHolder transactionSummaryReport) {
    String amount;
    BigDecimal totalIncomeAmounts = BigDecimal.ZERO;
    BigDecimal totalPrincipalAmounts = BigDecimal.ZERO;

    //write Contributions header....
    writeSubHeader(table, "Contibutions and Other Income", EndowConstants.EndowmentReport.DETAIL);

    //now write out the records....
    List<ContributionsDataHolder> contributionsData = transactionSummaryReport
            .getReportGroupsForContributions();

    if (contributionsData != null) {
        for (ContributionsDataHolder contribution : contributionsData) {
            table.addCell(createCell("\t\t\t\t\t\t\t".concat(contribution.getContributionsDescription()),
                    cellFont, Element.ALIGN_LEFT, true));
            totalIncomeAmounts = totalIncomeAmounts.add(contribution.getIncomeContributions());
            amount = formatAmount(contribution.getIncomeContributions());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            totalPrincipalAmounts = totalPrincipalAmounts.add(contribution.getPrincipalContributions());
            amount = formatAmount(contribution.getPrincipalContributions());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            amount = formatAmount(contribution.getTotalContributions());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
        }
    }

    //now write out the sub-total line....amount
    table.addCell("\t\t\t\t\t\t\t\tActivity Sub-Total");
    amount = formatAmount(totalIncomeAmounts);
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
    amount = formatAmount(totalPrincipalAmounts);
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
    amount = formatAmount(totalIncomeAmounts.add(totalPrincipalAmounts));
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
}

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

License:Educational Community License

/**
 * Helper method to go through the contributions list and write the lines..For summary report
 * @param table//from   w  ww  .java2 s.c o m
 * @param cellFont
 * @param transactionSummaryReport
 */
protected void writeContributionsRecordsForSummaryReportOption(PdfPTable table, Font cellFont,
        TransactionSummaryReportDataHolder transactionSummaryReport) {
    String amount;
    BigDecimal totalIncomeAmounts = BigDecimal.ZERO;
    BigDecimal totalPrincipalAmounts = BigDecimal.ZERO;

    //write Contributions header....
    writeSubHeader(table, "Contibutions and Other Income", EndowConstants.EndowmentReport.TOTAL);

    //now write out the records....
    List<ContributionsDataHolder> contributionsData = transactionSummaryReport
            .getReportGroupsForContributions();

    if (contributionsData != null) {
        for (ContributionsDataHolder contribution : contributionsData) {
            table.addCell(createCell("\t\t\t\t\t\t\t".concat(contribution.getContributionsDescription()),
                    cellFont, Element.ALIGN_LEFT, true));
            totalIncomeAmounts = totalIncomeAmounts.add(contribution.getIncomeContributions());
            totalPrincipalAmounts = totalPrincipalAmounts.add(contribution.getPrincipalContributions());
            amount = formatAmount(contribution.getTotalContributions());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
        }
    }

    //now write out the sub-total line....amount
    table.addCell("\t\t\t\t\t\t\t\tActivity Sub-Total");
    amount = formatAmount(totalIncomeAmounts.add(totalPrincipalAmounts));
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
}

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

License:Educational Community License

/**
 * Helper method to go through the expenses list and write the lines..
 * @param table/* ww w . j ava2 s.  c  o  m*/
 * @param cellFont
 * @param transactionSummaryReport
 */
protected void writeExpensesRecordsForDetailReportOption(PdfPTable table, Font cellFont,
        TransactionSummaryReportDataHolder transactionSummaryReport) {
    String amount;
    BigDecimal totalIncomeAmounts = BigDecimal.ZERO;
    BigDecimal totalPrincipalAmounts = BigDecimal.ZERO;

    //write Contributions header....
    writeSubHeader(table, "Expenses", EndowConstants.EndowmentReport.DETAIL);

    //now write out the records....
    List<ExpensesDataHolder> expensesData = transactionSummaryReport.getReportGroupsForExpenses();

    if (expensesData != null) {
        for (ExpensesDataHolder expenses : expensesData) {
            table.addCell(createCell("\t\t\t\t\t\t\t".concat(expenses.getExpensesDescription()), cellFont,
                    Element.ALIGN_LEFT, true));
            totalIncomeAmounts = totalIncomeAmounts.add(expenses.getIncomeExpenses());
            amount = formatAmount(expenses.getIncomeExpenses());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            totalPrincipalAmounts = totalPrincipalAmounts.add(expenses.getPrincipalExpenses());
            amount = formatAmount(expenses.getPrincipalExpenses());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            amount = formatAmount(expenses.getTotalExpenses());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
        }
    }

    //now write out the sub-total line....amount
    table.addCell("\t\t\t\t\t\t\t\tActivity Sub-Total");
    amount = formatAmount(totalIncomeAmounts);
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
    amount = formatAmount(totalPrincipalAmounts);
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
    amount = formatAmount(totalIncomeAmounts.add(totalPrincipalAmounts));
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
}

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

License:Educational Community License

/**
 * Helper method to go through the expenses list and write the lines..
 * @param table/*w  w w  .  j  av  a  2s. c  om*/
 * @param cellFont
 * @param transactionSummaryReport
 */
protected void writeExpensesRecordsForSummaryReportOption(PdfPTable table, Font cellFont,
        TransactionSummaryReportDataHolder transactionSummaryReport) {
    String amount;
    BigDecimal totalIncomeAmounts = BigDecimal.ZERO;
    BigDecimal totalPrincipalAmounts = BigDecimal.ZERO;

    //write Contributions header....
    writeSubHeader(table, "Expenses", EndowConstants.EndowmentReport.TOTAL);

    //now write out the records....
    List<ExpensesDataHolder> expensesData = transactionSummaryReport.getReportGroupsForExpenses();

    if (expensesData != null) {
        for (ExpensesDataHolder expenses : expensesData) {
            table.addCell(createCell("\t\t\t\t\t\t\t".concat(expenses.getExpensesDescription()), cellFont,
                    Element.ALIGN_LEFT, true));
            totalIncomeAmounts = totalIncomeAmounts.add(expenses.getIncomeExpenses());
            totalPrincipalAmounts = totalPrincipalAmounts.add(expenses.getPrincipalExpenses());
            amount = formatAmount(expenses.getTotalExpenses());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
        }
    }

    //now write out the sub-total line....amount
    table.addCell("\t\t\t\t\t\t\t\tActivity Sub-Total");
    amount = formatAmount(totalIncomeAmounts.add(totalPrincipalAmounts));
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
}

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

License:Educational Community License

/**
 * Helper method to go through the cash transfers list and write the lines..
 * @param table//from   w  w  w . j  a va 2 s. c  o m
 * @param cellFont
 * @param transactionSummaryReport
 */
protected void writeCashTransfersRecordsForDetailReportOption(PdfPTable table, Font cellFont,
        TransactionSummaryReportDataHolder transactionSummaryReport) {
    String amount;
    BigDecimal totalIncomeAmounts = BigDecimal.ZERO;
    BigDecimal totalPrincipalAmounts = BigDecimal.ZERO;

    //write Contributions header....
    writeSubHeader(table, "Cash Transfers", EndowConstants.EndowmentReport.DETAIL);

    //now write out the records....
    List<CashTransfersDataHolder> cashTransfersData = transactionSummaryReport
            .getReportGroupsForCashTransfers();

    if (cashTransfersData != null) {
        for (CashTransfersDataHolder cashTransfer : cashTransfersData) {
            table.addCell(createCell("\t\t\t\t\t\t\t".concat(cashTransfer.getCashTransfersDescription()),
                    cellFont, Element.ALIGN_LEFT, true));
            totalIncomeAmounts = totalIncomeAmounts.add(cashTransfer.getIncomeCashTransfers());
            amount = formatAmount(cashTransfer.getIncomeCashTransfers());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            totalPrincipalAmounts = totalPrincipalAmounts.add(cashTransfer.getPrincipalCashTransfers());
            amount = formatAmount(cashTransfer.getPrincipalCashTransfers());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
            amount = formatAmount(cashTransfer.getTotalCashTransfers());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
        }
    }

    //now write out the sub-total line....amount
    table.addCell("\t\t\t\t\t\t\t\tActivity Sub-Total");
    amount = formatAmount(totalIncomeAmounts);
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
    amount = formatAmount(totalPrincipalAmounts);
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
    amount = formatAmount(totalIncomeAmounts.add(totalPrincipalAmounts));
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
}

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

License:Educational Community License

/**
 * Helper method to go through the expenses list and write the lines..
 * @param table//from  ww w  . j a  va 2s  . c  o  m
 * @param cellFont
 * @param transactionSummaryReport
 */
protected void writeCashTransfersRecordsForSummaryReportOption(PdfPTable table, Font cellFont,
        TransactionSummaryReportDataHolder transactionSummaryReport) {
    String amount;
    BigDecimal totalIncomeAmounts = BigDecimal.ZERO;
    BigDecimal totalPrincipalAmounts = BigDecimal.ZERO;

    //write Contributions header....
    writeSubHeader(table, "Cash Transfers", EndowConstants.EndowmentReport.TOTAL);

    //now write out the records....
    List<CashTransfersDataHolder> cashTransfersData = transactionSummaryReport
            .getReportGroupsForCashTransfers();

    if (cashTransfersData != null) {
        for (CashTransfersDataHolder cashTransfer : cashTransfersData) {
            table.addCell(createCell("\t\t\t\t\t\t\t".concat(cashTransfer.getCashTransfersDescription()),
                    cellFont, Element.ALIGN_LEFT, true));
            totalIncomeAmounts = totalIncomeAmounts.add(cashTransfer.getIncomeCashTransfers());
            totalPrincipalAmounts = totalPrincipalAmounts.add(cashTransfer.getPrincipalCashTransfers());
            amount = formatAmount(cashTransfer.getTotalCashTransfers());
            table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
        }
    }

    //now write out the sub-total line....amount
    table.addCell("\t\t\t\t\t\t\t\tActivity Sub-Total");
    amount = formatAmount(totalIncomeAmounts.add(totalPrincipalAmounts));
    table.addCell(createCell(amount, cellFont, Element.ALIGN_RIGHT, true));
}