You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
861 B

package UnitTest;
import com.aspose.words.Document;
import com.aspose.words.NodeCollection;
import com.aspose.words.NodeType;
import com.aspose.words.Shape;
public class SaveImageByAspose {
public static void main(String[] args) throws Exception {
String MyDir="C:\\Users\\Administrator\\Documents\\WeChat Files\\wxid_wutao583xh1j22\\FileStorage\\File\\2023-06\\";
Document doc = new Document(MyDir + "少儿B2.docx");
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
int imageIndex = 0;
for (Shape shape : (Iterable<Shape>) shapes) {
if (shape.hasImage()) {
String imageFileName = String.format("c:\\Qiao\\%s.png", imageIndex);
shape.getImageData().save(imageFileName);
imageIndex++;
}
}
}
}