Example usage for com.lowagie.text.rtf.parser RtfParser addListener

List of usage examples for com.lowagie.text.rtf.parser RtfParser addListener

Introduction

In this page you can find the example usage for com.lowagie.text.rtf.parser RtfParser addListener.

Prototype

public void addListener(EventListener listener) 

Source Link

Document

Adds a EventListener to the RtfCtrlWordMgr.

Usage

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.itext.PatchRtfWriter2.java

License:Open Source License

/**
 * Adds the complete RTF document to the current RTF document being generated. It will parse the font and color tables
 * and correct the font and color references so that the imported RTF document retains its formattings. Uses new
 * RtfParser object./*from w ww .  ja va 2s.  co  m*/
 * <p/>
 * (author: Howard Shank)
 *
 * @param documentSource
 *          The InputStream to read the RTF document from.
 * @param events
 *          The array of event listeners. May be null
 * @throws IOException
 * @throws DocumentException
 * @see RtfParser
 * @see RtfParser#importRtfDocument(InputStream, com.lowagie.text.rtf.document.RtfDocument)
 * @since 2.0.8
 */
public void importRtfDocument(InputStream documentSource, EventListener[] events)
        throws IOException, DocumentException {
    if (!this.open) {
        throw new DocumentException("The document must be open to import RTF documents.");
    }
    RtfParser rtfImport = new RtfParser(this.document);
    if (events != null) {
        for (int idx = 0; idx < events.length; idx++) {
            rtfImport.addListener(events[idx]);
        }
    }
    rtfImport.importRtfDocument(documentSource, this.rtfDoc);
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.itext.PatchRtfWriter2.java

License:Open Source License

/**
 * Adds a fragment of an RTF document to the current RTF document being generated. Since this fragment doesn't contain
 * font or color tables, all fonts and colors are mapped to the default font and color. If the font and color mappings
 * are known, they can be specified via the mappings parameter. Uses new RtfParser object.
 * <p/>//w w w  . ja v  a  2s .  c  om
 * (author: Howard Shank)
 *
 * @param documentSource
 *          The InputStream to read the RTF fragment from.
 * @param mappings
 *          The RtfImportMappings that contain font and color mappings to apply to the fragment.
 * @param events
 *          The array of event listeners. May be null
 * @throws IOException
 *           On errors reading the RTF fragment.
 * @throws DocumentException
 *           On errors adding to this RTF fragment.
 * @see RtfImportMappings
 * @see RtfParser
 * @see RtfParser#importRtfFragment(InputStream, com.lowagie.text.rtf.document.RtfDocument, RtfImportMappings)
 * @since 2.0.8
 */
public void importRtfFragment(InputStream documentSource, RtfImportMappings mappings, EventListener[] events)
        throws IOException, DocumentException {
    if (!this.open) {
        throw new DocumentException("The document must be open to import RTF fragments.");
    }
    RtfParser rtfImport = new RtfParser(this.document);
    if (events != null) {
        for (int idx = 0; idx < events.length; idx++) {
            rtfImport.addListener(events[idx]);
        }
    }
    rtfImport.importRtfFragment(documentSource, this.rtfDoc, mappings);
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.itext.PatchRtfWriter2.java

License:Open Source License

/**
 * Adds the complete RTF document to the current RTF element being generated. It will parse the font and color tables
 * and correct the font and color references so that the imported RTF document retains its formattings.
 *
 * @param elem// ww w  . j a  v  a 2s  . com
 *          The Element the RTF document is to be imported into.
 * @param documentSource
 *          The Reader to read the RTF document from.
 * @param events
 *          The event array for listeners.
 * @throws IOException
 *           On errors reading the RTF document.
 * @throws DocumentException
 *           On errors adding to this RTF document.
 * @since 2.1.4
 */
public void importRtfDocumentIntoElement(Element elem, FileInputStream documentSource, EventListener[] events)
        throws IOException, DocumentException {

    RtfParser rtfImport = new RtfParser(this.document);
    if (events != null) {
        for (int idx = 0; idx < events.length; idx++) {
            rtfImport.addListener(events[idx]);
        }
    }
    rtfImport.importRtfDocumentIntoElement(elem, documentSource, rtfDoc);
}