Free Support Forum -

Visio drawing images

Hi team,

My requirement is to extract the images and save into new document .
In my document some of the images are visio, please kindly help me to extract the visio drawing images.

Input: Mssp (1.8 MB)

Expected output: (108.7 KB)

Thanks and regards,
Priyanga G


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 aspsoe.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);
   + "output"+i+".docx");