CSS 2.1兼容HTML到Microsoft Word转换? [英] CSS 2.1 compliant HTML to Microsoft Word conversion?

查看:549
本文介绍了CSS 2.1兼容HTML到Microsoft Word转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Prince XML 中找到了一个精湛的HTML到PDF转换器。现在我正在寻找类似质量的东西从HTML + CSS生成Word文档。这是在PHP / Linux上。

I've found a superb HTML to PDF converter in Prince XML. Now I'm looking for something of similar quality to produce Word documents from HTML + CSS. This is on PHP/Linux.

推荐答案

三个选项取决于你需要做什么:

Three options depending on what you need to do:


  1. 对于简单的情况,您可以将HTML写入.doc文件。 此处示例。

如果您可以要求Word 2007,您可以生成Office Open XML,这基本上是一个zip文件,其中保存XML文档。我还没有找到一个库,可以做到这一点,但你可以开始通过重命名示例.docx文件到.zip文件,看看包含什么,然后从PHP生成。有关此SO问题中的信息。

If you can require Word 2007, you can generate Office Open XML, which is basically a zip file which holds XML documents. I haven't found a library that can do that, but you can get started by renaming a sample .docx file to a .zip file and looking at what's included, then generate that from PHP. Some info on that in this SO question.

如果您需要支持Word 2003,则需要使用Word 2003的XML格式。它不同于2007格式,但至少是向前兼容(因此它也将在2007年工作)。最简单的方法是从Word保存为Word 2003 XML文档,然后在文本编辑器中打开文档,然后开始工作,编写XSLT,将HTML转换为正确的XML。我做了,它的工作,但它是很多工作。有关此处格式的信息。

If you need to support Word 2003, you need to work with Word 2003's XML format. It's different than the 2007 format, but is at least forward compatible (so it'll work on 2007 as well). The simplest way is to save as a Word 2003 XML document from Word, then open the document in a text editor, then get to work writing XSLT that will convert your HTML to the correct XML. I've done it, and it worked, but it was a lot of work. There's info on the format here.

这些都不是那么容易,所以可能值得购买一个为你做转换的软件产品。

None of those are all that easy, so it might be worth buying a software product that does the conversion for you.

有关此问题的更多信息,请参见此SO问题< a>,以及。

More info on this question is available in this SO question, as well.

这篇关于CSS 2.1兼容HTML到Microsoft Word转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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