Package javax.swing.text.rtf

Examples of javax.swing.text.rtf.RTFEditorKit


              reader = new InputStreamReader(is);
              file = File.createTempFile("extract_rtf", ".tmp");
              indexInfo.addDeleteFile(file);
              writer = new FileWriter(file);
              DefaultStyledDocument doc = new DefaultStyledDocument();
              new RTFEditorKit().read(reader, doc, 0);
              writer.write(doc.getText(0, doc.getLength()));
          } catch (Throwable ioe) {
              throw new ExtractionException("failed to parse rtf document", ioe,logger);
          } finally {
              if (reader != null) {
View Full Code Here


       
        String bodyText = "";
        DefaultStyledDocument styledDoc = new DefaultStyledDocument();
        try
        {
            new RTFEditorKit().read(part.getInputStream(), styledDoc, 0);
            bodyText = styledDoc.getText(0, styledDoc.getLength());
        }
        catch( BadLocationException e)
        {
            LOG.debug("Cannot extract text from a RTF document", e);
View Full Code Here

                        JViewerPanel jviewer = new JViewerPanel();
                        String text = FileUtils.readFileToString(file);
                        jviewer.update(text);
                        dialog.add(jviewer);
                } else if (verifier.isRTF(path)) {
                        RTFEditorKit rtf = new RTFEditorKit();
                        JEditorPane editor = new JEditorPane();
                        editor.setEditable(false);
                        editor.setEditorKit(rtf);
                        // This text could be big so add a scroll pane.
                        JScrollPane scroller = new JScrollPane();
                        scroller.getViewport().add(editor);
                        dialog.add(scroller);
                        // Load an RTF file into the editor.
                        try {
                                FileInputStream fi = new FileInputStream(file);
                                rtf.read(fi, editor.getDocument(), 0);
                        } catch (Exception exception) {
                                exception.printStackTrace();
                        }
                } else if (verifier.isPicture(path)) {
                        AlphalinePanel viewer = new AlphalinePanel();
View Full Code Here

    */
  public void writeOutRTF(StyledDocument doc, File rtfFile)
  throws IOException, BadLocationException
  {
    FileOutputStream fos = new FileOutputStream(rtfFile);
    RTFEditorKit rtfKit = new RTFEditorKit();
    rtfKit.write(fos, doc, 0, doc.getLength());
    fos.flush();
    fos.close();
    refreshOnUpdate();
  }
View Full Code Here

  public String getRTFDocument()
  throws IOException, BadLocationException
  {
    StyledDocument doc = (StyledDocument)(jtpMain.getStyledDocument());
    StringWriter strwriter = new StringWriter();
    RTFEditorKit rtfKit = new RTFEditorKit();
    rtfKit.write(strwriter, doc, 0, doc.getLength());
    return strwriter.toString();
  }
View Full Code Here

            throws Parser.Failure, InterruptedException {

        try
            final DefaultStyledDocument doc = new DefaultStyledDocument();
           
            final RTFEditorKit theRtfEditorKit = new RTFEditorKit();              
            theRtfEditorKit.read(source, doc, 0);           
           
            final String bodyText = doc.getText(0, doc.getLength());
           
            return new Document[]{new Document(
                    location,
View Full Code Here

        try {
            tempFile = createUnicodeRtfTempFile(stream);
            in = new FileInputStream(tempFile);

            Document sd = new CustomStyledDocument();
            new RTFEditorKit().read(in, sd, 0);

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

    }
    else if (fileExt.equals(".rtf")) {
      try {
        DefaultStyledDocument dsd = new DefaultStyledDocument();

        RTFEditorKit rtfEditorKit = new RTFEditorKit();
        rtfEditorKit.read(reader, dsd, 0);

        text = dsd.getText(0, dsd.getLength());
      }
      catch (Exception e) {
        _log.error(e.getMessage());
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.