Example usage for com.lowagie.text Section addSection

List of usage examples for com.lowagie.text Section addSection

Introduction

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

Prototype

public Section addSection(String title) 

Source Link

Document

Adds a Section to this Section and returns it.

Usage

From source file:it.govpay.web.console.pagamenti.gde.exporter.PdfExporter.java

License:Open Source License

private static void addContent(Document document, List<EventoBean> eventi, IEventiService eventiService)
        throws UtilsException, DocumentException {
    Anchor anchor = new Anchor("Eventi Selezionati", catFont);
    anchor.setName("Eventi Selezionati");

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

    for (EventoBean eventoBean : eventi) {

        Evento evento = eventoBean.getDTO();
        Paragraph subPara = new Paragraph("Evento Id[" + evento.getId() + "]", subFont);

        Section subCatPart = catPart.addSection(subPara);

        addEmptyLine(subCatPart, 1);/*  w  w  w.j ava 2 s  . c  o m*/

        createEventoTable(subCatPart, evento);

        addEmptyLine(subCatPart, 1);

        Infospcoop infospcoop = eventoBean.getInfospcoop() != null ? eventoBean.getInfospcoop().getDTO() : null;
        if (infospcoop != null) {
            //         if(evento.getCategoria().equals(Categoria.INTERFACCIA) && evento.getIdEgov()!= null){

            //            Infospcoop infospcoop = eventiService.getInfospcoopByIdEgov(evento.getIdEgov());

            Paragraph infoParg = new Paragraph("Infospcoop", subFont);

            subCatPart.addSection(infoParg);

            addEmptyLine(subCatPart, 1);

            createInfospcoopTable(subCatPart, infospcoop);

            //subCatPart.add(new Paragraph(infospcoop.toXml()));
        }

        addEmptyLine(subCatPart, 1);

        catPart.newPage();
    }

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

}

From source file:questions.objects.ChaptersAndMemory.java

/**
 * Generates a PDF file with autonumbered chapters and an open bookmark tab
 * /*w w  w.j a va 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();
}