GWT有显示RTF类型数据的richtextbox吗?

发布于 2024-10-12 13:14:22 字数 227 浏览 4 评论 0原文

我正在使用 GWT Richtextbox,但此小部件显示的值是简单文本或 HTML 格式。 有没有办法在 GWT-Richtext 或 GWT-htmlEditor 小部件中显示 RTF 数据?或者其他 GWT 库中是否有一个小部件可以执行此操作?

I'm using GWT Richtextbox, But this widget shows values which are simple text or HTML formatted.
Is there any way to show RTF data in a GWT-Richtext or GWT-htmlEditor widget? Or is there a widget in other GWT libraries which will do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

牵你的手,一向走下去 2024-10-19 13:14:22

我不这么认为。大约一年前,我们想在客户端开发 rtf 浏览器,但失败了。
没有 GWT-Rtf 库。你可以尝试找到一些用 javascript 编写的东西,然后用 JSNI 包装它,但我还没有看到这样的库。有人告诉我用Activex也许可以,但我们还没有尝试过这种方法。

I don't think so. About year ago we wanted to develop rtf browser on client side and we failed.
There is no GWT-Rtf libraries. You could try to find something written in javascript and then wrap it with JSNI, but I haven't seen such library as well. Someone told me that it might be possible with Activex, but we haven't even tried this method.

﹏雨一样淡蓝的深情 2024-10-19 13:14:22

你想达到什么目的?如果您想与 RTF 编辑器(例如 Microsoft Word)共享文档,您应该检查该编辑器是否也可以使用 HTML。我知道 MS Word 可以编辑 HTML。

或者,您可以考虑将 RTF 转换为 HTML,然后在服务器端再次转换回来。有几个 Java 库可以做到这一点,我相信 Flying Saucer 是其中之一。

What are you trying to achieve? If you want to share documents with an RTF editor like, say, Microsoft Word, you should check to see if that editor can also work with HTML. I know that MS Word can edit HTML.

Alternatively, you might consider transposing RTF into HTML and back again on the server side. There are several Java libraries out there for doing that, and I believe that Flying Saucer is one of them.

静水深流 2024-10-19 13:14:22

您可以将 RTFEditorKit 与 HTMLEditorKit 结合使用,在两个服务器端或小程序中进行转换。这样您就可以使用 GWT 的富文本编辑器并输出或输入 RTF。

public static String getHtmlFromRtf(InputStream fi){
    Writer sOut = new StringWriter();
    DefaultStyledDocument doc = new DefaultStyledDocument();                  
    HTMLEditorKit htmlKit = new HTMLEditorKit();                  
    RTFEditorKit rtf = new RTFEditorKit();

    try
    {
        rtf.read( fi, doc, 0 );
        htmlKit.write(sOut, doc, 0, doc.getLength());
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    catch (BadLocationException e)
    {
        e.printStackTrace();
    }
    return sOut.toString();
}

You could use RTFEditorKit in combination with HTMLEditorKit to convert between the two server-side or in an applet. This way you can use GWT's rich text editor and output or input RTF.

public static String getHtmlFromRtf(InputStream fi){
    Writer sOut = new StringWriter();
    DefaultStyledDocument doc = new DefaultStyledDocument();                  
    HTMLEditorKit htmlKit = new HTMLEditorKit();                  
    RTFEditorKit rtf = new RTFEditorKit();

    try
    {
        rtf.read( fi, doc, 0 );
        htmlKit.write(sOut, doc, 0, doc.getLength());
    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
    catch (BadLocationException e)
    {
        e.printStackTrace();
    }
    return sOut.toString();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文