开发者

How to programmatically extract and manipulate images from an Office file?

开发者 https://www.devze.com 2022-12-14 00:26 出处:网络
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?Apache has a project called \"POI\

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?


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 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消