Example usage for com.lowagie.text ElementTags CHAPTER

List of usage examples for com.lowagie.text ElementTags CHAPTER

Introduction

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

Prototype

String CHAPTER

To view the source code for com.lowagie.text ElementTags CHAPTER.

Click Source Link

Document

the chapter tag

Usage

From source file:org.apache.maven.doxia.docrenderer.itext.AbstractITextRender.java

License:Apache License

/**
 * Merge all iTextFiles to a single one/*from   ww w . j  av  a 2 s  .  c o m*/
 *
 * @param iTextFiles
 * @return a document
 * @throws org.apache.maven.doxia.docrenderer.DocumentRendererException if any
 * @throws java.io.IOException if any
 */
private Document generateDocument(List<File> iTextFiles) throws DocumentRendererException, IOException {
    Document document;
    try {
        document = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder().newDocument();
    } catch (ParserConfigurationException e) {
        throw new DocumentRendererException("Error building document :" + e.getMessage());
    }
    document.appendChild(document.createElement(ElementTags.ITEXT)); // Used only to set a root

    for (File iTextFile : iTextFiles) {
        Document iTextDocument;
        try {
            iTextDocument = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder().parse(iTextFile);
        } catch (SAXException e) {
            throw new DocumentRendererException("SAX Error : " + e.getMessage());
        } catch (ParserConfigurationException e) {
            throw new DocumentRendererException("Error parsing configuration : " + e.getMessage());
        }

        // Only one chapter per doc
        Node chapter = iTextDocument.getElementsByTagName(ElementTags.CHAPTER).item(0);
        try {
            document.getDocumentElement().appendChild(document.importNode(chapter, true));
        } catch (DOMException e) {
            throw new DocumentRendererException(
                    "Error appending chapter for " + iTextFile + " : " + e.getMessage());
        }
    }

    return document;
}

From source file:org.apache.maven.doxia.docrenderer.pdf.itext.ITextPdfRenderer.java

License:Apache License

/**
 * Merge all iTextFiles to a single one.
 *
 * @param iTextFiles list of iText xml files.
 * @return Document.//from   w w  w .  jav  a 2s  .c o  m
 * @throws DocumentRendererException if any.
 * @throws IOException if any.
 */
private Document generateDocument(List<File> iTextFiles) throws DocumentRendererException, IOException {
    Document document = DOCUMENT_BUILDER.newDocument();
    document.appendChild(document.createElement(ElementTags.ITEXT)); // Used only to set a root

    for (File iTextFile : iTextFiles) {
        Document iTextDocument;

        try {
            iTextDocument = DOCUMENT_BUILDER.parse(iTextFile);
        } catch (SAXException e) {
            throw new DocumentRendererException("SAX Error : " + e.getMessage());
        }

        // Only one chapter per doc
        Node chapter = iTextDocument.getElementsByTagName(ElementTags.CHAPTER).item(0);

        try {
            document.getDocumentElement().appendChild(document.importNode(chapter, true));
        } catch (DOMException e) {
            throw new DocumentRendererException(
                    "Error appending chapter for " + iTextFile + " : " + e.getMessage());
        }
    }

    return document;
}

From source file:org.apache.maven.doxia.module.itext.ITextSink.java

License:Apache License

/** {@inheritDoc} */
public void body() {
    if (writeStart) {
        writeStartElement(ElementTags.ITEXT);
        writeAddAttribute(ElementTags.TITLE, header.getTitle());
        writeAddAttribute(ElementTags.AUTHOR, header.getAuthors());
        writeAddAttribute(ElementTags.CREATIONDATE, header.getDate());
        writeAddAttribute(ElementTags.SUBJECT, header.getTitle());
        writeAddAttribute(ElementTags.KEYWORDS, "");
        writeAddAttribute(ElementTags.PRODUCER, "Generated with Doxia by " + System.getProperty("user.name"));
        writeAddAttribute(ElementTags.PAGE_SIZE, ITextUtil.getPageSize(ITextUtil.getDefaultPageSize()));

        writeStartElement(ElementTags.CHAPTER);
        writeAddAttribute(ElementTags.NUMBERDEPTH, numberDepth);
        writeAddAttribute(ElementTags.DEPTH, depth);
        writeAddAttribute(ElementTags.INDENT, "0.0");

        writeStartElement(ElementTags.TITLE);
        writeAddAttribute(ElementTags.LEADING, DEFAULT_CHAPTER_TITLE_LEADING);
        writeAddAttribute(ElementTags.FONT, ITextFont.DEFAULT_FONT_NAME);
        writeAddAttribute(ElementTags.SIZE, ITextFont.getSectionFontSize(0));
        writeAddAttribute(ElementTags.STYLE, ITextFont.BOLD);
        writeAddAttribute(ElementTags.BLUE, ITextFont.DEFAULT_FONT_COLOR_BLUE);
        writeAddAttribute(ElementTags.GREEN, ITextFont.DEFAULT_FONT_COLOR_GREEN);
        writeAddAttribute(ElementTags.RED, ITextFont.DEFAULT_FONT_COLOR_RED);
        writeAddAttribute(ElementTags.ALIGN, ElementTags.ALIGN_CENTER);

        //            startChunk( ITextFont.DEFAULT_FONT_NAME, ITextFont.getSectionFontSize( 0 ),
        //                    ITextFont.BOLD, ITextFont.DEFAULT_FONT_COLOR_BLUE, ITextFont.DEFAULT_FONT_COLOR_GREEN,
        //                    ITextFont.DEFAULT_FONT_COLOR_RED, "top" );

        writeStartElement(ElementTags.CHUNK);
        writeAddAttribute(ElementTags.FONT, ITextFont.DEFAULT_FONT_NAME);
        writeAddAttribute(ElementTags.SIZE, ITextFont.getSectionFontSize(0));
        writeAddAttribute(ElementTags.STYLE, ITextFont.BOLD);
        writeAddAttribute(ElementTags.BLUE, ITextFont.DEFAULT_FONT_COLOR_BLUE);
        writeAddAttribute(ElementTags.GREEN, ITextFont.DEFAULT_FONT_COLOR_GREEN);
        writeAddAttribute(ElementTags.RED, ITextFont.DEFAULT_FONT_COLOR_RED);
        //            writeAddAttribute( ElementTags.LOCALDESTINATION, "top" );

        write(header.getTitle());/*from  ww  w.  java  2 s .  co m*/

        writeEndElement(); // ElementTags.CHUNK

        writeEndElement(); // ElementTags.TITLE
    }

    actionContext.setAction(SinkActionContext.BODY);
}