Java 类com.lowagie.text.Chapter 实例源码

项目:api-resolver    文件:SimplePdfDocInstaller.java   
@Override
public void installApiDocs(List<ApiDoc> apiDocs) throws Exception {
    for (Chapter chapter : categoryChapters.keySet()) {
        ApiCategory apiCategory = categoryChapters.get(chapter);
        for (ApiDoc apiDoc : DocContainer.get().getApiDocQuery().queryByCategory(apiCategory.getCid())) {
            Section section = chapter.addSection(new Paragraph(secFont.process(apiDoc.getName())));
            section.setIndentation(10);
            section.setIndentationLeft(10);
            section.setBookmarkOpen(false);
            section.setNumberStyle(Section.NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT);
            //desc
            section.add(new Paragraph(textFont.process(apiDoc.getDesc())));
            //summary
            addSummary(section, apiDoc);
            //parameters
            addParameters(section, apiDoc);
            //Result
            addResult(section, apiDoc);
            //ResultExample
            addResultExample(section, apiDoc);
        }
        document.add(chapter);
    }
}
项目:api-resolver    文件:SimplePdfDocInstaller.java   
@Override
public void installApiTypeDocs(List<ApiTypeDoc> apiTypeDocs) throws Exception {
    Paragraph paRefType = new Paragraph(chFont.process("引用类型参考\n"));
    Chapter chapter = new Chapter(paRefType, categoryChapters.size()+1);

    for (ApiTypeDoc apiTypeDoc : apiTypeDocs) {
        Phrase chunk = secFont.process(apiTypeDoc.getName());
        ItextUtil.setLocalDestination(chunk, REFTYPE_LINK_PREFIX + apiTypeDoc.getName());
        Section section = chapter.addSection(new Paragraph(chunk));
        section.setIndentation(10);
        section.setIndentationLeft(10);
        section.setBookmarkOpen(false);
        section.setNumberStyle(Section.NUMBERSTYLE_DOTTED_WITHOUT_FINAL_DOT);
        //desc
        section.add(new Paragraph(textFont.process(apiTypeDoc.getDesc())));
        //属性
        addTypeAttrs(section, apiTypeDoc.getAttrs());
    }

    document.add(chapter);
}
项目:itext2    文件:SAXiTextHandler.java   
protected void addImage(Image img) throws EmptyStackException {
    // if there is an element on the stack...
    Object current = stack.pop();
    // ...and it's a Chapter or a Section, the Image can be
    // added directly
    if (current instanceof Chapter
            || current instanceof Section
            || current instanceof Cell) {
        ((TextElementArray) current).add(img);
        stack.push(current);
        return;
    }
    // ...if not, we need to to a lot of stuff
    else {
        Stack newStack = new Stack();
        while (!(current instanceof Chapter
                || current instanceof Section || current instanceof Cell)) {
            newStack.push(current);
            if (current instanceof Anchor) {
                img.setAnnotation(new Annotation(0, 0, 0,
                        0, ((Anchor) current).getReference()));
            }
            current = stack.pop();
        }
        ((TextElementArray) current).add(img);
        stack.push(current);
        while (!newStack.empty()) {
            stack.push(newStack.pop());
        }
        return;
    }
}
项目:api-resolver    文件:SimplePdfDocInstaller.java   
@Override
public void installCategorys(List<ApiCategory> apiCategorys) throws Exception {
       int ch = 1;
       for (ApiCategory apiCategory : apiCategorys) {
        Paragraph paApiCategory = new Paragraph(chFont.process(apiCategory.getName() + "\n"));
        Chapter chapter = new Chapter(paApiCategory, ch++);
        Paragraph paragraph = new Paragraph(textFont.process(apiCategory.getDesc()));
        paragraph.setSpacingAfter(10f);
        paragraph.setIndentationLeft(8f);
        chapter.add(paragraph);

        categoryChapters.put(chapter, apiCategory);
    }
}
项目:DroidText    文件:SAXiTextHandler.java   
protected void addImage(Image img) throws EmptyStackException {
    // if there is an element on the stack...
    Object current = stack.pop();
    // ...and it's a Chapter or a Section, the Image can be
    // added directly
    if (current instanceof Chapter
            || current instanceof Section
            || current instanceof Cell) {
        ((TextElementArray) current).add(img);
        stack.push(current);
        return;
    }
    // ...if not, we need to to a lot of stuff
    else {
        Stack newStack = new Stack();
        while (!(current instanceof Chapter
                || current instanceof Section || current instanceof Cell)) {
            newStack.push(current);
            if (current instanceof Anchor) {
                img.setAnnotation(new Annotation(0, 0, 0,
                        0, ((Anchor) current).getReference()));
            }
            current = stack.pop();
        }
        ((TextElementArray) current).add(img);
        stack.push(current);
        while (!newStack.empty()) {
            stack.push(newStack.pop());
        }
        return;
    }
}
项目:itext2    文件:RtfTOCandCellbordersTest.java   
/**
 * Creates an RTF document with a TOC and Table with special Cellborders.
 * 
 * 
 */
@Test
public void main() throws Exception {
    Document document = new Document();
    RtfWriter2 writer2 = RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("toc.rtf"));

    writer2.setAutogenerateTOCEntries(true);

    document.open();

    Paragraph para = new Paragraph();
    para.add(new RtfTableOfContents("RIGHT CLICK AND HERE AND SELECT \"UPDATE FIELD\" TO UPDATE."));
    document.add(para);

    Paragraph par = new Paragraph("This is some sample content.");
    Chapter chap1 = new Chapter("Chapter 1", 1);
    chap1.add(par);
    Chapter chap2 = new Chapter("Chapter 2", 2);
    chap2.add(par);
    document.add(chap1);
    document.add(chap2);

    for (int i = 0; i < 300; i++) {
        if (i == 158) {
            document.add(new RtfTOCEntry("This is line 158."));
        }
        document.add(new Paragraph("Line " + i));
    }

    document.add(new RtfTOCEntry("Cell border demonstration"));

    Table table = new Table(3);

    RtfCell cellDotted = new RtfCell("Dotted border");
    cellDotted.setBorders(new RtfBorderGroup(Rectangle.BOX, RtfBorder.BORDER_DOTTED, 1, new Color(0, 0, 0)));
    RtfCell cellEmbossed = new RtfCell("Embossed border");
    cellEmbossed.setBorders(new RtfBorderGroup(Rectangle.BOX, RtfBorder.BORDER_EMBOSS, 1, new Color(0, 0, 0)));
    RtfCell cellNoBorder = new RtfCell("No border");
    cellNoBorder.setBorders(new RtfBorderGroup());

    table.addCell(cellDotted);
    table.addCell(cellEmbossed);
    table.addCell(cellNoBorder);

    document.add(table);
    document.close();
}
项目:Tourney    文件:PDFDocument.java   
/**
 * Add all registered players to the document
 * 
 * @throws DocumentException
 *             When the data can not be added to the document
 */
public void addRegisteredPlayers() throws DocumentException {
    /* Add a section for the players */
    Anchor playerAnchor = new Anchor(PreferencesManager.getInstance()
            .localizeString("pdfoutput.players.title"),
            PDFExporter.BIG_HEADER_FONT);
    playerAnchor.setName(PreferencesManager.getInstance().localizeString(
            "pdfoutput.players.title"));
    Chapter playerChapter = new Chapter(new Paragraph(playerAnchor),
            this.chapterNumber);
    playerChapter.add(Chunk.NEWLINE);

    for (Player player : this.event.getRegisteredPlayers()) {
        String[][] playerAttributes = {
                { "Name",
                        player.getFirstName() + " " + player.getLastName() },
                { "Nickname", player.getNickName() },
                { "Mail", player.getMailAddress() },
                { "Starting number", player.getStartingNumber() } };

        for (String[] attribute : playerAttributes) {
            if (attribute[1].equals("")) {
                if (attribute[0].equals("Starting number")) {
                    playerChapter.add(new Paragraph(PreferencesManager
                            .getInstance().localizeString(
                                    "pdfoutput.players.nostartingnumber"),
                            PDFExporter.TEXT_FONT));
                } else if (attribute[0].equals("Name")) {
                    playerChapter.add(new Paragraph(PreferencesManager
                            .getInstance().localizeString(
                                    "pdfoutput.players.noname"),
                            PDFExporter.SMALL_BOLD));
                }
            } else {
                if (attribute[0].equals("Name")) {
                    playerChapter.add(new Paragraph(attribute[1],
                            PDFExporter.SMALL_BOLD));
                } else if (attribute[0].equals("Starting number")) {
                    playerChapter.add(new Paragraph(PreferencesManager
                            .getInstance().localizeString(
                                    "pdfoutput.players.startingnumber")
                            + " " + attribute[1], PDFExporter.TEXT_FONT));
                } else {
                    playerChapter.add(new Paragraph(attribute[1],
                            PDFExporter.TEXT_FONT));
                }
            }
        }

        if (player.hasPayed()) {
            playerChapter.add(new Paragraph(PreferencesManager
                    .getInstance().localizeString(
                            "pdfoutput.players.payed.true"),
                    PDFExporter.TEXT_FONT));
        } else {
            playerChapter.add(new Paragraph(PreferencesManager
                    .getInstance().localizeString(
                            "pdfoutput.players.payed.false"),
                    PDFExporter.TEXT_FONT));
        }

        if (player.isDisqualified()) {
            playerChapter.add(new Paragraph(PreferencesManager
                    .getInstance().localizeString(
                            "pdfoutput.players.disqualified.true"),
                    PDFExporter.TEXT_FONT));
        }

        playerChapter.add(Chunk.NEWLINE);
    }

    this.chapterNumber++;
    this.document.add(playerChapter);
}
项目:api-resolver    文件:SimplePdfDocInstaller.java   
public SimplePdfDocInstaller(DocInstallArgs docInstallArgs) throws Exception {
    super(docInstallArgs);
    categoryChapters = new LinkedHashMap<Chapter, ApiCategory>();
}
项目:itext2    文件:RtfChapter.java   
/**
 * Constructs a RtfChapter for a given Chapter
 * 
 * @param doc The RtfDocument this RtfChapter belongs to
 * @param chapter The Chapter this RtfChapter is based on
 */
public RtfChapter(RtfDocument doc, Chapter chapter) {
    super(doc, chapter);
}