Package javax.swing.text.rtf

Examples of javax.swing.text.rtf.RTFEditorKit


    public Reader extractText(InputStream stream,
                              String type,
                              String encoding) throws IOException {

        try {
            RTFEditorKit rek = new RTFEditorKit();
            DefaultStyledDocument doc = new DefaultStyledDocument();
            rek.read(stream, doc, 0);
            String text = doc.getText(0, doc.getLength());
            return new StringReader(text);
        } catch (Throwable t) {
            logger.warn("Failed to extract RTF text content", t);
            return new StringReader("");
View Full Code Here


    public Reader extractText(InputStream stream,
                              String type,
                              String encoding) throws IOException {

        try {
            RTFEditorKit rek = new RTFEditorKit();
            DefaultStyledDocument doc = new DefaultStyledDocument();
            rek.read(stream, doc, 0);
            String text = doc.getText(0, doc.getLength());
            return new StringReader(text);
        } catch (Throwable t) {
            logger.warn("Failed to extract RTF text content", t);
            return new StringReader("");
View Full Code Here

              reader = new InputStreamReader(is);
              file = File.createTempFile("extract", ".tmp");
              tempFiles.markForDeletion(file);
              writer = new FileWriter(file);
              DefaultStyledDocument doc = new DefaultStyledDocument();
              new RTFEditorKit().read(reader, doc, 0);
              writer.write(doc.getText(0, doc.getLength()));
          } catch (Exception ioe) {
              throw new ExtractionException("failed to parse rtf document", ioe,logger);
          }
          finally {
View Full Code Here

    String bodyText = null;

    DefaultStyledDocument styledDoc = new DefaultStyledDocument();
    try {
      new RTFEditorKit().read(is, styledDoc, 0);
      bodyText = styledDoc.getText(0, styledDoc.getLength());
    } catch (IOException e) {
      throw new DocumentHandlerException(
          "Cannot extract text from a RTF document", e);
    } catch (BadLocationException e) {
View Full Code Here

      }
    }
  }

  private String convert(InputStream rtfDocumentInputStream) throws IOException {
    RTFEditorKit aRtfEditorkit = new RTFEditorKit();

    StyledDocument styledDoc = new DefaultStyledDocument();

    String textDocument;

    try {
      aRtfEditorkit.read(rtfDocumentInputStream, styledDoc, 0);

      textDocument = styledDoc.getText(0, styledDoc.getLength());
    } catch (BadLocationException e) {
      throw new IOException("Error during parsing");
    }
View Full Code Here

    public void parse(
            InputStream stream, ContentHandler handler, Metadata metadata)
            throws IOException, SAXException, TikaException {
        try {
            DefaultStyledDocument sd = new DefaultStyledDocument();
            new RTFEditorKit().read(stream, sd, 0);

            XHTMLContentHandler xhtml =
                new XHTMLContentHandler(handler, metadata);
            xhtml.startDocument();
            xhtml.element("p", sd.getText(0, sd.getLength()));
View Full Code Here

            throw new IllegalStateException("HtmlTransferable: Error encountered in string conversion: " + e);
        }
       
        // Get the RTF version of the string
       
        RTFEditorKit rtfKit = new RTFEditorKit();
        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        try {
            rtfKit.write(byteStream, doc, 0, doc.getLength());
        catch (Exception e) {
            throw new IllegalStateException("HtmlTransferable: Error encountered in string conversion: " + e);
        }
        this.rtfString = new String(byteStream.toByteArray());
       
View Full Code Here

              reader = new InputStreamReader(is);
              file = File.createTempFile("extract", ".tmp");
              tempFiles.markForDeletion(file);
              writer = new FileWriter(file);
              DefaultStyledDocument doc = new DefaultStyledDocument();
              new RTFEditorKit().read(reader, doc, 0);
              writer.write(doc.getText(0, doc.getLength()));
          } catch (Exception ioe) {
              throw new ExtractionException("failed to parse rtf document", ioe,logger);
          }
          finally {
View Full Code Here

              reader = new InputStreamReader(is);
              file = File.createTempFile("extract", ".tmp");
              tempFiles.markForDeletion(file);
              writer = new FileWriter(file);
              DefaultStyledDocument doc = new DefaultStyledDocument();
              new RTFEditorKit().read(reader, doc, 0);
              writer.write(doc.getText(0, doc.getLength()));
          } catch (Exception ioe) {
              throw new ExtractionException("failed to parse rtf document", ioe,logger);
          }
          finally {
View Full Code Here

              reader = new InputStreamReader(is);
              file = File.createTempFile("extract", ".tmp");
              tempFiles.markForDeletion(file);
              writer = new FileWriter(file);
              DefaultStyledDocument doc = new DefaultStyledDocument();
              new RTFEditorKit().read(reader, doc, 0);
              writer.write(doc.getText(0, doc.getLength()));
          } catch (Exception ioe) {
              throw new ExtractionException("failed to parse rtf document", ioe,logger);
          }
          finally {
View Full Code Here

TOP

Related Classes of javax.swing.text.rtf.RTFEditorKit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.