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

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

Introduction

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

Prototype

public void importRtfDocument(InputStream readerIn, RtfDocument rtfDoc) throws IOException 

Source Link

Document

Imports a complete RTF document.

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  ww  w  .ja va 2s .c  o 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);
}