Example usage for com.itextpdf.text Chapter Chapter

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

Introduction

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

Prototype

public Chapter(String title, int number) 

Source Link

Document

Constructs a new Chapter.

Usage

From source file:PDFmaker.java

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

    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 0);
    catPart.add(new Paragraph(
            "Productielijst gegenereerd door: " + System.getProperty("user.name") + ", " + LocalDate.now(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            smallBold));/*from  w  w w  .j a  v  a 2s . c  om*/
    //        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);
    //        Paragraph paragraph = new Paragraph();
    //        addEmptyLine(paragraph, 5);
    //        subCatPart.add(paragraph);

    // add a table
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 1);
    catPart.add(paragraph);
    createTable(catPart);

    // 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 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.ja  v a2s .  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);//from w  w  w.  jav a  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:at.jps.sanction.core.io.file.PDFFileOutputWorker.java

License:Open Source License

@Override
public void handleMessage(final AnalysisResult message) {

    super.handleMessage(message);

    try {//from w  w w .  j  av  a 2 s.c  o m

        logger.info("write Message: " + message.getMessage().getId());

        final Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream(getFilename()));
        document.open();

        final Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD);
        final Font paragraphFont = FontFactory.getFont(FontFactory.HELVETICA, 14, Font.NORMAL);

        Chunk chunk = new Chunk("Message", chapterFont);
        Chapter chapter = new Chapter(new Paragraph(chunk), 1);
        chapter.setNumberDepth(0);
        chapter.add(new Paragraph(message.getMessage().toString(), paragraphFont));
        document.add(chapter);

        getWriter().write(message.getMessage().toString());

        if (message.getHitList() != null) {

            chapter.add(new Paragraph("Hits", paragraphFont));

            for (final HitResult hit : message.getHitList()) {
                final PdfPTable table = new PdfPTable(2);

                table.addCell("Description");
                table.addCell(hit.getHitDescripton());
                table.addCell("Field");
                table.addCell(hit.getHitDescripton());
                table.addCell("Absolute Value");
                table.addCell(hit.getAbsolutHit() + "");
                table.addCell("Relative Value");
                table.addCell(hit.getRelativeHit() + "");
                table.addCell("Phrase Value");
                table.addCell(hit.getPhraseHit() + "");
                table.addCell("HitType");
                table.addCell(hit.getHitType());

                document.add(table);
            }
        } else {
            final String exception = message.getException();
            if (exception != null) {
                chunk = new Chunk("Error:", chapterFont);
                chapter = new Chapter(new Paragraph(chunk), 1);
                chapter.add(new Paragraph(message.getException().toString(), paragraphFont));
                document.add(chapter);
            }
        }
        document.close();
    } catch (final Exception e) {
        logger.error("Error writing to file:" + getFilename());
        logger.debug("Exception: ", e);
    }
}

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 . ja  v 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: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 . ja v a  2 s.  co m*/
    // 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);/*from ww w  .java 2 s . co 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:Business.PDFMaker.java

public PDFMaker(String filename, TicketMap tm, int pr1, int pr2, int pr3) {
    Document doc = new Document();
    try {//from w  ww . j a v  a  2 s.c o  m
        PdfWriter.getInstance(doc, new FileOutputStream(filename));
        doc.open();
        doc.add(new Phrase("Cabaz de Natal, Cl Schindler"));
        doc.add(new Paragraph("As seguintes Rifas foram vendidas:"));
        doc.add(new Paragraph("\n"));
        PdfPTable table = new PdfPTable(5);
        for (Ticket t : tm.getFullTickets()) {

            PdfPCell cell = new PdfPCell(new Paragraph(t.getId() + "-" + t.getName()));
            table.addCell(cell);
        }
        doc.add(table);
        doc.add(new Chapter("Vencedores deste ano:", 1));
        doc.add(new Paragraph("1 Prmio. " + tm.getTicket(pr1)));
        doc.add(new Paragraph("2 Prmio. " + tm.getTicket(pr2)));
        doc.add(new Paragraph("3 Prmio. " + tm.getTicket(pr3)));
        doc.close();
    } catch (Exception e) {

    }
}

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

License:Open Source License

private static void addContent(Document document, TreeObject rootObject) throws DocumentException {
    for (TreeObject treeObject : rootObject.getChildObjects()) {
        if (treeObject.isChecked()) {
            Paragraph title = new Paragraph(treeObject.getTitle(), chapterTitleFont);
            Chapter chapter = new Chapter(title, currentChapter);
            populateChapter(treeObject, chapter);
            document.add(chapter);/* w ww.  j a v  a 2 s . c  o  m*/
            currentChapter++;
        }
    }
}

From source file:com.athena.chameleon.engine.utils.PDFWriterUtil.java

License:Apache License

/**
 * Chapter  ?/*  w w w .  ja va 2 s. co  m*/
 *
 * @param text Chapter title
 * @param chapterNo Chapter Number
 * @return Chapter
 */
public static Chapter getChapter(String text, int chapterNo) {

    Chapter chapter = new Chapter(text, chapterNo);
    String title = chapter.getTitle().getContent();

    Chunk c = new Chunk(text, fnChapter);
    c.setLocalDestination(title);
    Paragraph chapterPh = new Paragraph();
    chapterPh.add(c);
    chapterPh.setSpacingAfter(12);
    chapter.setTitle(chapterPh);
    return chapter;

}