Example usage for com.itextpdf.text Section add

List of usage examples for com.itextpdf.text Section add

Introduction

In this page you can find the example usage for com.itextpdf.text Section add.

Prototype

@Override
public boolean add(final Element element) 

Source Link

Document

Adds a Paragraph, List, Table or another Section to this Section.

Usage

From source file:uk.ac.openmf.utils.OpenMFPDFGenerator.java

private static void createLAOTable(Section subCatPart, String clientId) throws DocumentException {
    PdfPTable table = new PdfPTable(5);

    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);

    PdfPCell c1 = new PdfPCell(new Phrase("Loan Acc#"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);/*from w w  w  . j a  va2 s .  c o m*/

    c1 = new PdfPCell(new Phrase("Loan Code"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Approved Amount"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("OutStd Amount"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Start Date"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    float[] columnWidths = new float[] { 10f, 10f, 15f, 15f, 10f };
    table.setWidths(columnWidths);
    table.setHeaderRows(1);

    ArrayList<OpenMFLoanAccount> loanAccounts = OMFUtils.getLoanAccountsByClientList(clientId);
    //ArrayList<OpenMFSavingsAccount> savingsAccounts = OMFUtils.getSavingsAccountsByClientList(clientId);
    for (OpenMFLoanAccount openMFLoanAccount : loanAccounts) {
        table.addCell(openMFLoanAccount.getLoanaccountnumber());
        table.addCell(openMFLoanAccount.getLoancode());
        table.addCell(openMFLoanAccount.getApprovedamount());
        table.addCell(openMFLoanAccount.getBalanceoutstandingamount());
        table.addCell(openMFLoanAccount.getLoanstartdate());
    }

    subCatPart.add(table);

}

From source file:uk.ac.openmf.utils.OpenMFPDFGenerator.java

private static void createSAOTable(Section subCatPart, String clientId) throws DocumentException {
    PdfPTable table = new PdfPTable(5);

    PdfPCell c1 = new PdfPCell(new Phrase("Savings Acc#"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);// ww w  .  j a v a  2 s.  co m

    c1 = new PdfPCell(new Phrase("Savings Code"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Available Balance"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Total# Deposits"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Matures On"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    float[] columnWidths = new float[] { 10f, 10f, 15f, 15f, 10f };
    table.setWidths(columnWidths);
    table.setHeaderRows(1);

    ArrayList<OpenMFSavingsAccount> savingsAccounts = OMFUtils.getSavingsAccountsByClientList(clientId);
    for (OpenMFSavingsAccount openMFSavingsAccount : savingsAccounts) {
        table.addCell(openMFSavingsAccount.getSavingsaccountnumber());
        table.addCell(openMFSavingsAccount.getSavingscode());
        table.addCell(openMFSavingsAccount.getAvailablebalance());
        table.addCell(openMFSavingsAccount.getTotalnumdeposits());
        table.addCell(openMFSavingsAccount.getMatureson());
    }

    subCatPart.add(table);

}

From source file:uk.ac.openmf.utils.OpenMFPDFGenerator.java

private static void createTasksTable(Section subCatPart, String omfuId) throws DocumentException {
    PdfPTable table = new PdfPTable(5);

    PdfPCell c1 = new PdfPCell(new Phrase("Task#"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);//from w w w  .j  ava2s. c o  m

    c1 = new PdfPCell(new Phrase("Date Assigned"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Amount"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Acc#"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Type"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    float[] columnWidths = new float[] { 10f, 10f, 15f, 15f, 10f };
    table.setWidths(columnWidths);
    table.setHeaderRows(1);

    OpenMFUser omfuser = null;
    if (omfuId != null) {
        omfuser = AppContext.getAppContext().getUserManager().getUser(ServletUtils.validateEventId(omfuId));
    }

    ArrayList<OpenMFTask> tasks = OMFUtils.getTasksByUsername(omfuser.getUsername(), false);
    for (OpenMFTask task : tasks) {
        table.addCell(task.getTaskId());
        table.addCell(task.getDateassigned());
        table.addCell(task.getAmount());
        table.addCell(task.getAccountnumber());
        table.addCell(task.getCollectiontype());
    }

    subCatPart.add(table);

}

From source file:wtw.ui.GeneratingPdfAction.java

private static void addContent(Document document) throws DocumentException {
    Anchor anchor = new Anchor("First Chapter", catFont);
    anchor.setName("First Chapter");

    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);

    Paragraph subPara = new Paragraph("Subcategory 1", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Hello"));

    subPara = new Paragraph("Subcategory 2", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("Paragraph 1"));
    subCatPart.add(new Paragraph("Paragraph 2"));
    subCatPart.add(new Paragraph("Paragraph 3"));

    // Add a list
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 5);//from  w ww .  j a  va  2 s .c om
    subCatPart.add(paragraph);

    // Add a table
    createTable(subCatPart);

    // Now add all this to the document
    document.add(catPart);

    // Next section
    anchor = new Anchor("Second Chapter", catFont);
    anchor.setName("Second Chapter");

    // Second parameter is the number of the chapter
    catPart = new Chapter(new Paragraph(anchor), 1);

    subPara = new Paragraph("Subcategory", subFont);
    subCatPart = catPart.addSection(subPara);
    subCatPart.add(new Paragraph("This is a very important message"));

    // Now add all this to the document
    document.add(catPart);

}

From source file:wtw.ui.GeneratingPdfAction.java

private static void createTable(Section subCatPart) throws BadElementException {
    PdfPTable table = new PdfPTable(3);

    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);
    PdfPCell c1 = new PdfPCell(new Phrase("Table Header 1"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);/*from  w  ww .  jav  a2s  .  com*/

    c1 = new PdfPCell(new Phrase("Table Header 2"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Table Header 3"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    table.setHeaderRows(1);

    table.addCell("1.0");
    table.addCell("1.1");
    table.addCell("1.2");
    table.addCell("2.1");
    table.addCell("2.2");
    table.addCell("2.3");

    subCatPart.add(table);

}