Example usage for com.itextpdf.text Chapter addSection

List of usage examples for com.itextpdf.text Chapter addSection

Introduction

In this page you can find the example usage for com.itextpdf.text Chapter addSection.

Prototype

public Section addSection(final Paragraph title) 

Source Link

Document

Creates a Section, adds it to this Section and returns it.

Usage

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);//  w  ww . j  a va  2s .  c o  m
    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: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);//ww w . j ava 2  s. co  m
    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: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);// ww w .j  ava2  s .  c o m
    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:bookshopautomationsoftware.GenerateReceipt.java

private static void addContent(Document document) throws DocumentException {
    Anchor anchor = new Anchor("BILL DETAILS(Generated by BAS) on " + new Date(), 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("CUSTOMER BILL", subFont);

    Section subCatPart = catPart.addSection(subPara);
    addEmptyLine(preface, 2);/*from  w  w w .j a v a 2s .com*/
    // add a table
    createTable(subCatPart);

    Paragraph subPara2 = new Paragraph("Thanks for choosing us .. please visit again", subFont);
    Section subCatPart2 = catPart.addSection(subPara2);
    /* Anchor anchor2 = new Anchor("Thanks for choosing us .. please visit again", catFont);
     Chapter catPart2 = new Chapter(new Paragraph(anchor), 1);*/

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

}

From source file:bsf.conn.DBMS.java

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

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

    Paragraph subPara = new Paragraph(null, smallBold);
    Section subCatPart = catPart.addSection(subPara);
    // add a table
    subPara.setAlignment(Element.ALIGN_LEFT);
    createTable(subCatPart, info.personalInfo);

    // now add all this to the document
    document.add(catPart);/* w  w  w.  j a  va  2s  .  c o  m*/

    // Next section
    anchor = new Anchor("Personal Information", catFont);
    anchor.setName("Personal Information");

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

    subPara = new Paragraph("Running Details", smallBold);
    subPara.setAlignment(Element.ALIGN_LEFT);

    subCatPart = catPart.addSection(subPara);
    // add a table
    addEmptyLine(subPara, 3);
    createTable(subCatPart, info.runningDetails);

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

    // Next section
    anchor = new Anchor("Personal Information", catFont);
    anchor.setName("Personal Information");

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

    subPara = new Paragraph("Leave Details", smallBold);
    subCatPart = catPart.addSection(subPara);
    // add a table
    addEmptyLine(subPara, 3);
    subPara.setAlignment(Element.ALIGN_LEFT);

    createTable(subCatPart, info.leaveDetails);

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

    // Next section
    anchor = new Anchor("Family Information", catFont);
    anchor.setName("Family Information");

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

    subPara = new Paragraph(null, smallBold);
    subCatPart = catPart.addSection(subPara);
    // add a table
    subPara.setAlignment(Element.ALIGN_LEFT);

    addEmptyLine(subPara, 3);
    createTable(subCatPart, info.familyInfo);

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

    // Next section
    anchor = new Anchor("Course Information", catFont);
    anchor.setName("Course Information");

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

    subPara = new Paragraph(null, smallBold);
    subCatPart = catPart.addSection(subPara);
    // add a table
    subPara.setAlignment(Element.ALIGN_LEFT);

    addEmptyLine(subPara, 3);
    createTable(subCatPart, info.courseDetails);

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

}

From source file:com.ainfosec.macresponse.report.PdfGenerator.java

License:Open Source License

private static void populateChapter(TreeObject treeObject, Chapter chapter) throws DocumentException {
    // If there are children, don't display this object's data
    if ((treeObject.getChildObjects() == null) || (treeObject.getChildObjects().size() == 0)) {
        // Create the Data Paragraphs (displayObjects)
        if ((treeObject.getDisplayData() != null)
                && (treeObject.getDisplayData().getDisplayObjects() != null)) {
            for (DisplayObject displayObject : treeObject.getDisplayData().getDisplayObjects()) {
                Paragraph paragraph = new Paragraph(displayObject.getTitle(), sectionTitleFont);

                paragraph.add("\n");
                createDataSection(paragraph, displayObject);

                chapter.addSection(paragraph);
            }/*from   ww  w  . ja v  a  2 s . c  o m*/
        }
    }
    // If there are children, display them
    else {
        for (TreeObject childTreeObject : treeObject.getChildObjects()) {
            Paragraph title = new Paragraph(childTreeObject.getTitle(), sectionTitleFont);
            Paragraph content = new Paragraph("\n");

            generateData(content, childTreeObject);

            chapter.addSection(title);
            chapter.add(content);
        }
    }
}

From source file:com.auskeny.ems.print.PdfCreator.java

public 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);//  w w w . j a v a 2 s  .  c o m
    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:com.bazzar.base.service.impl.CreateInvoicePDF.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  w w  .j  a  v  a 2  s.  c o m*/
    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:com.debashubham.dumpy.ChainageCalcActivity.java

private void addContent(Document document) throws DocumentException {
    Anchor anchor = new Anchor("Survey Report", catFont);
    anchor.setName("SurveyReport");

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

    Paragraph subPara = new Paragraph("Entries:", subFont);
    Section subCatPart = catPart.addSection(subPara);

    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 5);//from   www  . jav  a  2 s  . c  om
    subCatPart.add(paragraph);

    // add a table
    createTable(subCatPart);

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

From source file:com.equiworx.util.Main.java

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

    // 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 a  va 2  s  .  c  o m
    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);

}