parent
c7a5daa2f2
commit
00bb91a508
@ -0,0 +1,22 @@
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue