Example usage for com.lowagie.text ChapterAutoNumber ChapterAutoNumber

List of usage examples for com.lowagie.text ChapterAutoNumber ChapterAutoNumber

Introduction

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

Prototype

public ChapterAutoNumber(final String title) 

Source Link

Document

Create a new object.

Usage

From source file:net.bull.javamelody.internal.web.pdf.PdfDocumentFactory.java

License:Apache License

Element createParagraphElement(String paragraphTitle, String iconName) throws DocumentException, IOException {
    final Paragraph paragraph = new Paragraph("", paragraphTitleFont);
    paragraph.setSpacingBefore(5);/*  w w  w . j  a v  a2  s.  c  o m*/
    paragraph.setSpacingAfter(5);
    if (iconName != null) {
        paragraph.add(new Chunk(getParagraphImage(iconName), 0, -5));
    }
    final Phrase element = new Phrase(' ' + paragraphTitle, paragraphTitleFont);
    element.setLeading(12);
    paragraph.add(element);
    // chapter pour avoir la liste des signets
    final ChapterAutoNumber chapter = new ChapterAutoNumber(paragraph);
    // sans numro de chapitre
    chapter.setNumberDepth(0);
    chapter.setBookmarkOpen(false);
    chapter.setTriggerNewPage(false);
    return chapter;
}

From source file:org.sonar.report.pdf.DefaultPDFReporter.java

License:Open Source License

@Override
protected void printPdfBody(Document document)
        throws DocumentException, IOException, org.dom4j.DocumentException, ReportException {
    this.document = document;
    // Chapter 1/*from  w ww.  j  a va  2s  . c  om*/
    ChapterAutoNumber chapter1 = new ChapterAutoNumber(
            new Paragraph(getTextProperty("main.chapter1.title"), Style.CHAPTER_FONT));
    chapter1.add(new Paragraph(getTextProperty("main.chapter1.intro"), Style.NORMAL_FONT));
    // Section 1.1
    Section section11 = chapter1
            .addSection(new Paragraph(getTextProperty("main.chapter1.subtitle1"), Style.TITLE_FONT));
    Project project = super.getProject();
    printDashboard(project, section11);
    // Section 1.2
    Section section12 = chapter1
            .addSection(new Paragraph(getTextProperty("main.chapter1.subtitle2"), Style.TITLE_FONT));
    printProjectInfo(project, section12);

    document.add(chapter1);

    // Subprojects Chapters (2, 3, 4, ...)
    Iterator<Project> it = project.getSubprojects().iterator();
    while (it.hasNext()) {
        Project subproject = it.next();
        ChapterAutoNumber subprojectChapter = new ChapterAutoNumber(new Paragraph(
                getTextProperty("general.module") + ": " + subproject.getName(), Style.TITLE_FONT));
        Section sectionX1 = subprojectChapter
                .addSection(new Paragraph(getTextProperty("main.chapter2.subtitle2X1"), Style.TITLE_FONT));
        printDashboard(subproject, sectionX1);
        Section sectionX2 = subprojectChapter
                .addSection(new Paragraph(getTextProperty("main.chapter2.subtitle2X2"), Style.TITLE_FONT));
        printProjectInfo(subproject, sectionX2);
        document.add(subprojectChapter);
    }
}

From source file:org.sonar.report.pdf.ExecutivePDFReporter.java

License:Open Source License

@Override
protected void printPdfBody(Document document)
        throws DocumentException, IOException, org.dom4j.DocumentException, ReportException {
    Project project = super.getProject();
    // Chapter 1: Report Overview (Parent project)
    ChapterAutoNumber chapter1 = new ChapterAutoNumber(new Paragraph(project.getName(), Style.CHAPTER_FONT));
    chapter1.add(new Paragraph(getTextProperty("main.text.misc.overview"), Style.NORMAL_FONT));
    Section section11 = chapter1//from www.  j av  a 2 s  .  c o m
            .addSection(new Paragraph(getTextProperty("general.report_overview"), Style.TITLE_FONT));
    printDashboard(project, section11);
    Section section12 = chapter1
            .addSection(new Paragraph(getTextProperty("general.violations_analysis"), Style.TITLE_FONT));
    printMostViolatedRules(project, section12);
    printMostViolatedFiles(project, section12);
    printMostComplexFiles(project, section12);
    printMostDuplicatedFiles(project, section12);
    document.add(chapter1);

    Iterator<Project> it = project.getSubprojects().iterator();
    while (it.hasNext()) {
        Project subproject = it.next();
        ChapterAutoNumber chapterN = new ChapterAutoNumber(
                new Paragraph(subproject.getName(), Style.CHAPTER_FONT));

        Section sectionN1 = chapterN
                .addSection(new Paragraph(getTextProperty("general.report_overview"), Style.TITLE_FONT));
        printDashboard(subproject, sectionN1);

        Section sectionN2 = chapterN
                .addSection(new Paragraph(getTextProperty("general.violations_analysis"), Style.TITLE_FONT));
        printMostViolatedRules(subproject, sectionN2);
        printMostViolatedFiles(subproject, sectionN2);
        printMostComplexFiles(subproject, sectionN2);
        printMostDuplicatedFiles(subproject, sectionN2);
        document.add(chapterN);
    }
}

From source file:org.sonar.report.pdf.TeamWorkbookPDFReporter.java

License:Open Source License

public void printPdfBody(Document document)
        throws DocumentException, IOException, org.dom4j.DocumentException, ReportException {
    Project project = super.getProject();
    // Chapter 1: Report Overview (Parent project)
    ChapterAutoNumber chapter1 = new ChapterAutoNumber(new Paragraph(project.getName(), Style.CHAPTER_FONT));
    chapter1.add(new Paragraph(getTextProperty("main.text.misc.overview"), Style.NORMAL_FONT));
    Section section11 = chapter1/*from ww w . j  a  v  a  2s  . c  o  m*/
            .addSection(new Paragraph(getTextProperty("general.report_overview"), Style.TITLE_FONT));
    printDashboard(project, section11);
    Section section12 = chapter1
            .addSection(new Paragraph(getTextProperty("general.violations_analysis"), Style.TITLE_FONT));
    printMostViolatedRules(project, section12);
    printMostViolatedFiles(project, section12);
    printMostComplexFiles(project, section12);
    printMostDuplicatedFiles(project, section12);

    Section section13 = chapter1
            .addSection(new Paragraph(getTextProperty("general.violations_details"), Style.TITLE_FONT));
    printMostViolatedRulesDetails(project, section13);

    document.add(chapter1);

    Iterator<Project> it = project.getSubprojects().iterator();
    while (it.hasNext()) {
        Project subproject = it.next();
        ChapterAutoNumber chapterN = new ChapterAutoNumber(
                new Paragraph(subproject.getName(), Style.CHAPTER_FONT));

        Section sectionN1 = chapterN
                .addSection(new Paragraph(getTextProperty("general.report_overview"), Style.TITLE_FONT));
        printDashboard(subproject, sectionN1);

        Section sectionN2 = chapterN
                .addSection(new Paragraph(getTextProperty("general.violations_analysis"), Style.TITLE_FONT));
        printMostViolatedRules(subproject, sectionN2);
        printMostViolatedFiles(subproject, sectionN2);
        printMostComplexFiles(subproject, sectionN2);
        printMostDuplicatedFiles(subproject, sectionN2);
        Section sectionN3 = chapterN
                .addSection(new Paragraph(getTextProperty("general.violations_details"), Style.TITLE_FONT));
        printMostViolatedRulesDetails(subproject, sectionN3);
        document.add(chapterN);
    }
}

From source file:org.sonarqube.report.extendedpdf.OverviewPDFReporter.java

License:Open Source License

private void printChapter(Document document, String chapterName) throws DocumentException, IOException {
    Paragraph title = new Paragraph(getTextProperty("extendedpdf." + chapterName), Style.CHAPTER_FONT);
    ChapterAutoNumber chapter = new ChapterAutoNumber(title);
    chapter.setTriggerNewPage(true);//from   w ww  .ja v  a  2 s  .c  o  m
    chapter.add(new Paragraph(getTextProperty("extendedpdf.misc.text"), Style.NORMAL_FONT));
    chapter.add(Chunk.NEWLINE);
    for (String sectionName : getConfigProperty(chapterName + ".sections").split(",")) {
        printChapterSection(chapter, sectionName);
    }
    document.add(chapter);
}

From source file:questions.objects.ChaptersAndMemory.java

/**
 * Generates a PDF file with autonumbered chapters and an open bookmark tab
 * //www.ja v a  2  s  .  c om
 * @param args
 *            no arguments needed here
 */
public static void main(String[] args) {
    // step 1: creation of a document-object
    Document document = new Document();
    try {
        // step 2:
        // we create a writer
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
        // step 3: we open the document
        document.open();
        // step 4: we add a paragraph to the document
        Phrase text = new Phrase("Quick brown fox jumps over the lazy dog. ");
        ChapterAutoNumber chapter1 = new ChapterAutoNumber("This is a sample sentence:");
        chapter1.setBookmarkTitle("The fox");
        chapter1.setBookmarkOpen(false);
        chapter1.setComplete(false);
        Section section1 = chapter1.addSection("Quick");
        section1.add(text);
        section1.add(text);
        section1.add(text);
        document.add(chapter1);
        Section section2 = chapter1.addSection("Fox");
        section2.add(text);
        section2.setComplete(false);
        document.add(chapter1);
        section2.add(text);
        section2.add(text);
        section2.setComplete(true);
        chapter1.setComplete(true);
        document.add(chapter1);
        ChapterAutoNumber chapter2 = new ChapterAutoNumber("Jumps");
        chapter2.setComplete(false);
        Section section = chapter2.addSection("Over");
        section.setComplete(false);
        section.add(text);
        section.add(text);
        section.add(text);
        Section subsection1 = section.addSection("Lazy");
        subsection1.setIndentationLeft(30);
        subsection1.add(text);
        subsection1.setComplete(false);
        document.add(chapter2);
        subsection1.add(text);
        subsection1.add(text);
        subsection1.add(text);
        subsection1.add(text);
        subsection1.setComplete(true);
        Section subsection2 = section.addSection("Dog");
        subsection2.setIndentationRight(30);
        subsection2.add(text);
        subsection2.add(text);
        subsection2.add(text);
        subsection2.add(text);
        subsection2.add(text);
        Section subsection3 = section.addSection("Did you see it?");
        subsection3.setIndentation(50);
        subsection3.add(text);
        subsection3.add(text);
        subsection3.add(text);
        subsection3.add(text);
        subsection3.add(text);
        section.setComplete(true);
        document.add(chapter2);
    } catch (DocumentException de) {
        System.err.println(de.getMessage());
    } catch (IOException ioe) {
        System.err.println(ioe.getMessage());
    }

    // step 5: we close the document
    document.close();
}