任何.Net工具在保留CSS的同时将HTML转换为RTF? [英] Any .Net utility to covert HTML to RTF while maintaining CSS?

查看:83
本文介绍了任何.Net工具在保留CSS的同时将HTML转换为RTF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何.Net工具可以将HTML转换为RTF,这也将 表示CSS样式?我发现很多肚子都会把所有的风格都去掉,或者做一个糟糕的工作来呈现它们。



有很多HTML到PDF转换器那里有一份体面的工作。我很惊讶,找到某些东西去HTML到RTF是非常困难的。



如果您代表sautinsoft,请不要回复。该产品属于'可怕'类别。

解决方案一个选项是加载一个web浏览器的HTML,选择所有,复制并粘贴到richtextbox。然后使用它的 RTF 属性。

  var webBrowser = new WebBrowser(); 
webBrowser.Navigate(about:blank);
webBrowser.Document.Write(... html ...);
webBrowser.Document.ExecCommand(SelectAll,false,null);
webBrowser.Document.ExecCommand(Copy,false,null);
richTextBox1.Paste();

最好使用 richtextbox v5



如果不够准确,可以使用word interop,然后粘贴并复制临时word文档。如果您需要,我可以从我的应用程序粘贴该代码。


Is there any .Net utility out there that will convert HTML to RTF, which will also honour CSS styles? I've found a lot of tripe that will either strip all the styles away, or do a terrible job of presenting them.

There are plenty of HTML to PDF converters out there that do a decent job. I'm surprised it's so difficult to find something to go HTML to RTF.

Please don't reply if you represent sautinsoft. That product falls into the 'terrible' category.

解决方案

One option is to load a webbrowser with the html, select all, copy and paste into a richtextbox. Then use its RTF property.

var webBrowser = new WebBrowser();
webBrowser.Navigate("about:blank");
webBrowser.Document.Write("... html...");
webBrowser.Document.ExecCommand("SelectAll", false, null);
webBrowser.Document.ExecCommand("Copy", false, null);
richTextBox1.Paste();

It's better to use richtextbox v5.

If it's not accurate enough you can use word interop and then paste and copy from a temp word document. I can paste that code from one of my apps if you need it.

这篇关于任何.Net工具在保留CSS的同时将HTML转换为RTF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆