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:PDFmaker.java

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

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

    PdfPCell c1 = new PdfPCell(new Phrase("Uitgiftepunt"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);//from  w ww  .j ava  2s.  c  om

    c1 = new PdfPCell(new Phrase("Pakketten deze week (" + LocalDate.now() + ")"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    table.setHeaderRows(1);

    try {
        SQLget sql = new SQLget();
        ResultSet rs = sql.getProductielijst();
        while (rs.next()) {
            String uitgiftepunt = rs.getString("Uitgiftepunt");
            int aantalPakketten = rs.getInt("Pakketten");

            table.addCell(uitgiftepunt);
            table.addCell(Integer.toString(aantalPakketten));
        }

    } catch (Exception e) {
    }
    subCatPart.add(table);
}

From source file:PDFmaker.java

private static void createList(Section subCatPart) {
    List list = new List(true, false, 10);
    list.add(new ListItem("First point"));
    list.add(new ListItem("Second point"));
    list.add(new ListItem("Third point"));
    subCatPart.add(list);
}

From source file:Pdfsave.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
    createList(subCatPart);//from   w  ww. j  av  a  2s  .com
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 5);
    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:Pdfsave.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 w w  .ja  v a 2 s.c o  m

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

From source file:pdf_demo2.java

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

    // Second parameter is the number of the chapter ex: 1. Chapter 1 or 2. Chapter 2
    Chapter chapter = new Chapter(new Paragraph(anchor), 2);

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

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

    // add a list
    createList(subSection);//from  w ww  .j  a va2 s .  com
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 5);
    subSection.add(paragraph);

    // add a table
    createTable(subSection);

    // now add all this to the document
    document.add(chapter);

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

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

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

    // now add all this to the document
    document.add(chapter);
}

From source file:pdf_demo2.java

private static void createTable(Section section) throws BadElementException {
    // number of table-column = 3
    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);//w  w w . jav  a  2  s  .  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");

    section.add(table);
}

From source file:bl.pdf.PDFFile.java

@SuppressWarnings("unused")
private 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
    createList(subCatPart);//from  w  w  w.j  av  a 2 s  .c om
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 5);
    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:bl.pdf.PDFFile.java

private 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);//  w  ww.  j  a  va2  s  . co  m

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

}

From source file:bl.pdf.PDFFile.java

private void createList(Section subCatPart) {
    List list = new List(true, false, 10);
    list.add(new ListItem("First point"));
    list.add(new ListItem("Second point"));
    list.add(new ListItem("Third point"));
    subCatPart.add(list);
}

From source file:bookshopautomationsoftware.GenerateReceipt.java

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

    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);
    addEmptyLine(preface, 2);/*from  w  ww  .  j  av a2  s  .  c  om*/
    PdfPCell c1 = new PdfPCell(new Phrase("slno"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

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

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

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

    table.setHeaderRows(1);

    try {
        Connection con = DriverManager.getConnection(DB_URL1, USER1, PASS1);
        Statement stmnt = con.createStatement();
        String sql = "SELECT slno,book,quantity FROM cart";
        Connection con1 = DriverManager.getConnection(DB_URL1, USER1, PASS1);
        Statement stmnt1 = con.createStatement();
        int count = 0;
        ResultSet rs = stmnt.executeQuery(sql);
        ResultSet rs1;
        float total = 0;
        while (rs.next()) {
            String sql1 = "SELECT isbn,price FROM booktable WHERE isbn = " + rs.getLong("book");
            rs1 = stmnt1.executeQuery(sql1);
            rs1.next();
            count++;
            table.addCell("" + rs.getInt("slno"));
            table.addCell("" + rs.getLong("book"));
            table.addCell("" + rs.getInt("quantity"));
            table.addCell("" + rs1.getFloat("price"));
            total += (rs1.getFloat("price")) * (rs.getInt("quantity"));

            //  model.addRow(new Object[]{(""+rs.getInt("slno")),""+rs.getLong("book"),""+rs.getInt("quantity")});
        }
        table.addCell("");
        table.addCell("");
        table.addCell("");
        table.addCell("" + total);
        if (count == 0) {
            // dispose();

            return;
        }

    } catch (Exception e) {
        System.out.println(" " + e + " is caught");
    }
    /*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);

}