Hi team,
My requirement is to extract the images and save into new document .
In my document some of the images are visio drawing.so, please kindly help me to extract the visio drawing images.
Input: Mssp aspose.zip (1.8 MB)
Expected output: Output.zip (108.7 KB)
Thanks and regards,
Priyanga G
@priyanga,
Thanks for your inquiry. Please use the following code example to extract the visio drawing objects from the document.
Document doc = new Document(MyDir + "Mssp Aspose.docx");
int i = 0;
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>)shapes)
{
if(shape.getOleFormat() != null && shape.getOleFormat().getProgId().equals("Visio.Drawing.11"))
{
Document dstDoc = new Document();
NodeImporter importer = new NodeImporter(doc, dstDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
Node newNode = importer.importNode(shape, true);
dstDoc.getFirstSection().getBody().getFirstParagraph().appendChild(newNode);
dstDoc.save(MyDir + "output"+i+".docx");
i++;
}
}