Example usage for com.lowagie.text HeaderFooter setPageNumber

List of usage examples for com.lowagie.text HeaderFooter setPageNumber

Introduction

In this page you can find the example usage for com.lowagie.text HeaderFooter setPageNumber.

Prototype


public void setPageNumber(int pageN) 

Source Link

Document

Sets the page number.

Usage

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

License:Educational Community License

/**
 * Generates the report in PDF using iText
 * //  ww  w . jav a  2s  . c om
 * @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.TrialBalanceReportPrint.java

License:Educational Community License

/**
 * Generates the report in PDF using iText
 * /* www .  j  a  va  2 s. co  m*/
 * @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;
}