在 .NET 中将 RTF 转换为 HTML
我已经成功地使用 WebBrowser
和 RichTextBox
完成了相反的操作。
但是如何将 RTF 转换为 HTML 呢?
I've managed to do the reverse using WebBrowser
and RichTextBox
.
But how would I convert RTF to HTML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您弹出 NuGet 并搜索“RTF”,目前最流行的结果如下所示:
RtfPipe
;你可以在那里安装它,或者通过包管理器控制台:然后在你的 C# 中,你可以非常轻松地将 RTF 转换为 HTML:
根据 他们的 GitHub 页面:
我将 RTF 输入到其中,效果非常好。 YYMV。
If you pop-up NuGet and search for "RTF", the most popular result right now looks like
RtfPipe
; you can install it right there, or via the package manager console via:Then in your C#, you can convert RTF to HTML super easily:
According to the readme.md on their GitHub page:
I piped my RTF into it, and it worked amazingly. YYMV.
免责声明:我在这家公司工作。
正如我所见,这个问题很老了,但也许有人也在寻找解决方案。我们的 RTF to HTML 组件允许将 RTF 转换为 HTML。您可以下载一个组件或尝试在线演示。如果您有疑问,请先尝试试用版。 :) 试用是免费的。
以下是在 ASP.NET 中将 RTF 转换为 HTML 的代码示例:
Disclaimer: I'm working for this company.
As I see, the question is old but maybe someone search solution for this too. Our component RTF to HTML allows to convert RTF to HTML. You may download a component or try online-demo. Try the trial version first if you have a doubt. :) Trial is free.
Here's the code sample for the converting from RTF to HTML in ASP.NET:
唯一的问题是,当你在预算范围内工作时,额外的成本意味着更低的利润,所以我开始开发自己的版本。主要问题是,目前它仅支持粗体和斜体,以及某些实体(&、©、®、&trade、& ;欧元和&###)并且缺乏字体和颜色支持,但它仍然是一项正在进行的工作。我正在添加字体和颜色,但令我头疼的是这些可能来自样式表而不是旧式的 html 标签。
上发布了启动代码
我正在 VB.NET 中编写此内容,并已在 CodeProject 启动代码
The only problem is when you work on a budget, additional costs mean lower profit, so I started to develop my own version. The main problem is that at the moment it only supports Bold and Italic, and certain entities (&, ©, ®, &trade, &euro and &###) and lacks both font and color support, but it is still a work in progress. I am adding font and color, but my headache is that these could come from stylesheets rather than the old fashion html tags.
I am writing this in VB.NET and have posted the startup code on CodeProject
Startup Code
如果你想以编程方式执行此操作,你应该解析你的 rtf (是一个简单的基于文本的文件),将 rtf 控制字转换为 html 标签。
在这里您可以找到 rtf 规格
http://www.biblioscape.com/rtf15_spec.htm
或使用现有的转换器:< a href="http://sourceforge.net/projects/rtf2html-lite/" rel="nofollow">http://sourceforge.net/projects/rtf2html-lite/
If you want to do it programattically you should parse your rtf (is a simple text based file), convert rtf control words to html tags.
Here you can find the rtf specs
http://www.biblioscape.com/rtf15_spec.htm
or use an already existing converter: http://sourceforge.net/projects/rtf2html-lite/