How to programmatically extract and manipulate ima

2019-07-05 05:17发布

问题:

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?

回答1:

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/



回答2:

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.



回答3:

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.



回答4:

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.