如何以编程方式从 Office 文件中提取和操作图像?
如何从 PowerPoint 和 Word 文档中提取一些图像,以便对其进行操作,然后将图像放回 MS Office 文件中?
How to extract some images from PowerPoint and Word documents, in order to manipulate them, and after that, put the images back in the MS Office files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Apache 有一个名为“POI”的项目,专门用于与 Java 中的 MS Office 格式进行交互。希望这对你有用!
http://poi.apache.org/
Apache has a project called "POI" explicitly made for interacting with MS Office formats from Java. Hopefully that does it for you!
http://poi.apache.org/
Apache POI 可以通过其 HWPF 模块,并从中提取或插入图像。尽管没有详细记录,但请查看 用于在 Word 中进行图像处理的 POI 单元测试(单元测试似乎是该模块的最佳文档)。
否则,可以通过(例如)JACOB 访问 COM 接口。这可能需要更多工作,但会提供不通过 POI 公开的可用 API。
Apache POI can handle Word documents via its HWPF module, and extract or insert images from these. Although it's not well documented, check out the POI unit tests for image manipulation within Word (the unit tests seem to be the best documentation for this module).
Failing that, the COM interface is accessible via (say) JACOB. That's probably more work, but will make available APIs not exposed via POI.
就C++而言,Word公开了COM API以允许您操作其文档格式,因此只要您的计算机上安装了Word,您就可以在C++中非常轻松地执行此操作。 Word 不是开源的,但您可能已经拥有许可证。
In terms of C++, Word exposes a COM API to allow you to manipulate its document format, so as long as you have Word installed on the machine, you can do this in C++ quite easily. Word isn't open source, but you probably have the license anyway.
我工作的公司 SoftArtisans 有一款名为 OfficeWriter 的产品,除其他外,它还允许您执行以下操作:适用于 Word 和 Excel(计划将来添加 PowerPoint)。但它不是免费或开源的。
另一方面,如果您严格使用 2007 格式(基于 XML),您可能可以使用 OpenXML。
The company I work for, SoftArtisans, has a product called OfficeWriter that allows you do that, among other things, for Word and Excel (PowerPoint is planned to be added in the future). It is not free or open sourced though.
On the other hand, if you are working strictly with 2007 format (XML based) you can probably use OpenXML.