Aspose.words for java 是否支持viso解析?

我有一个word文档,里面有vsd文件格式。我需要识别这个vsd文件,并提取这个viso中的图片用于界面展示,然后将识别后的这个viso图片重新导出到word中,请问aspose.words for java支持吗?测试文件如下viso file1.zip (86.1 KB)

@chenxf,

您需要以下两个API才能满足此要求:

请检查以下Java代码:

Document doc = new Document("E:\\Temp\\viso file1\\test.docx");

Shape targetShape = null;
for (Shape shape : (Iterable<Shape>) doc.getChildNodes(NodeType.SHAPE, true)) {
    if (shape.getOleFormat() != null) {
        targetShape = shape;
        break;
    }
}
if (targetShape != null) {
    if (targetShape.getOleFormat().isLink()) {
        System.out.println("Object is Linked");
        String fileName = targetShape.getOleFormat().getSourceFullName();
        System.out.println(fileName);
    } else if (targetShape.getOleFormat().getOleIcon()) {
        System.out.println("Object displayed as icon");
        System.out.println(targetShape.getOleFormat().getSuggestedExtension());

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        targetShape.getOleFormat().save(baos);

        com.aspose.diagram.Diagram diagram = new com.aspose.diagram.Diagram(new ByteArrayInputStream(baos.toByteArray()));
        ByteArrayOutputStream baosImage = new ByteArrayOutputStream();
        diagram.save(baosImage, new com.aspose.diagram.ImageSaveOptions(SaveFileFormat.JPEG));

        DocumentBuilder builder = new DocumentBuilder();
        builder.insertImage(baosImage.toByteArray());
        builder.getDocument().save("E:\\Temp\\viso file1\\20.7.docx");

    } else if (!targetShape.getOleFormat().getOleIcon()) {
        System.out.println("Object displayed as Content");
        System.out.println(targetShape.getOleFormat().getSuggestedExtension());
    }
}