从 Word 中提取方程和图像

发布于 2024-07-09 18:37:42 字数 236 浏览 6 评论 0原文

是否有一种编程方法可以从 MS Word 文档中提取方程(可能还有图像)? 我已经用谷歌搜索遍了,但还没有找到任何可以让我全身心投入并工作的东西。 如果可能的话,我希望能够使用 VB.NET 或 C# 来完成此操作,但我可以选择足够多的任何语言来破解 DLL。 谢谢!

编辑: 现在我正在考虑从 Word 2003 中提取方程式,但如果需要将其转换为 2007/Open XML,那也没关系。

Is there a programmatic way to extract equations (and possibly images) from an MS Word document? I've googled all over, but have yet to find anything that I can sink my teeth into and work from. If possible, I'd like to be able to do this with VB.NET or C#, but I can pick up enough of any language to hack out a DLL. Thanks!

EDIT: Right now I'm looking at extracting the equations from Word 2003, but if converting it to 2007/Open XML is required, that's fine.

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

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

发布评论

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

评论(3

流心雨 2024-07-16 18:37:42

您的文档采用什么 Word 格式? 如果它们是 Open XML(文件扩展名 .docx),您可以使用 Microsoft 提供的开放 XML SDK,用于提取图像和嵌入内容。

Open XML 文件只不过是使用特殊结构的 zip 存档。 您将在 SDK 中找到如何访问该 zip 存档的部分内容的示例。 实际上,您可以使用任何支持 zip 的库来从文档包中提取内容。

如果文档仍然使用旧的二进制格式,事情就会变得更复杂一些。 我认为最简单的方法是将文档转换为 Open XML 格式。 有几种方法可以做到这一点:

  • 从 SourceForge 获取免费且开放的 b2xtranslator,它为您提供 C# dll 文件转换。
  • 安装 Microsoft 的 兼容性打包并使用以下命令行进行转换:

    "C:\Program Files\Microsoft Office\Office12\wordconv.exe" -oice -nme input\_file output_file

其中 input_file 和 output_file 必须是完整路径名。

What Word format are your documents in? If they are in Open XML (file extension .docx) you could use the Open XML SDK available from Microsoft to extract images and embedded content.

An Open XML file is nothing but a zip archive using a special structure. You will find examples in the SDK how to access parts of that zip archive. Actually you could use any zip-capable library to extract the content from the document package.

If the documents still use the older binary format things are a bit more complicated. I think the easiest way would be to convert the documents to the Open XML format. There are several ways to do this:

  • Get the free and open b2xtranslator from SourceForge which offers you C# dlls for file conversion.
  • Install Microsoft's Compatibility Pack and use the following command line for conversion:

    "C:\Program Files\Microsoft Office\Office12\wordconv.exe" -oice -nme input\_file output_file

where input_file and output_file must be full path names.

并安 2024-07-16 18:37:42

我不知道这些是否有帮助,但是 Word 2000/2003 中的对象模型有一个 InlineShapes 集合,作为 Document 对象的一部分,它表示嵌入的图像和可能是类似的对象,例如方程。

一些将第一个项目复制到剪贴板的 VBA 代码,这可能会帮助您提取它们:

ThisDocument.InlineShapes.Items(1).Select
Selection.Copy

它也可以在 .NET 中访问,MSDN 链接

I don't know if any of this will help, but the object model in Word 2000/2003 has an InlineShapes collection as part of the Document object which represents embedded images and possibly similar objects like equations.

Some VBA code to copy the first item onto the clipboard, which might help you extract them:

ThisDocument.InlineShapes.Items(1).Select
Selection.Copy

It's accessible in .NET too, MSDN link.

影子的影子 2024-07-16 18:37:42

尝试查看 Word-to-latex 转换器。 它需要 .Net 框架,尽管源代码尚未公开,但作者确实提出了有关此问题的问题。

Try looking at the Word-to-latex converter. It requires the .Net framework and although the source isn't opened yet the author does invite questions about this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文