word选择性粘贴html和rtf,Html To Doc(Word) Or RTF Format

该问题探讨了如何将包含CSS、表格和图片的HTML页面转换为Word或RTF格式。答案提到使用Word2003或2007通过XSLT将HTML转换为XML文档,以及使用如DocFrac等工具将HTML转换为RTF。转换的关键挑战在于下载并嵌入图片,以便离线查看。对于转换为DOC格式,由于难度较大,建议使用COM互操作与MSOffice进行转换。
摘要由CSDN通过智能技术生成

问题

What would the best possible way to convert a html page (with css, tables, images etc.) to be converted to word or rtf format. I already know about adding the

content-type = application/word

header and that's not an option because we need the images embedded in the document so that it can be viewed without an active internet connection.

I need either a free (preferably) or commercial .NET library or a command line utility as I need to do this on a hosted ASP.NET application on a shared server :|.

回答1:

If you are using Word 2003 or 2007 you can convert xhtml documents to Word Xml documents using xslt. If you google for html to docx xsl you will find many examples of the opposite (converting docx to html) so you might one of those examples as a basis for a conversion. The only challenge would be downloading and embedding the images in the document, but that is also possible.

回答2:

There are several possibilities for converting HTML to RTF. These links should get you started:

DocFrac, conversion between HTML, RTF and text. Free, runs on Windows.

XHTML2RTF: An HTML to RTF conversion tool based on XSL

Writing an RTF to HTML converter

Converting to MS Word .doc is much harder and probably not worthwhile for you. For the reasons this is such a pain, read Joel's interesting article on .doc. If you have to write .doc for some reason, COM interop with MSOffice is probably your best bet.

来源:https://stackoverflow.com/questions/1026281/html-to-docword-or-rtf-format

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值