Convert a Visio Shape To Image
Contents
[
Hide
]
**Convert a visio shape to image **
The ToImage method exposed by the Shape class can be used to convert to image.
The code below shows how to:
- Load a sample diagram.
- get a particular page.
- get a particular shape.
- convert shape to image.
Shape to Image
Use the following code in your java application to convert a visio shape to image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ShapeToImage.class); | |
// Call a Diagram class constructor to load the VSDX diagram | |
Diagram diagram = new Diagram(dataDir + "ShapeToImage.vsdx"); | |
// Get a particular page | |
Page page = diagram.getPages().get(0); | |
// Get a particular shape | |
Shape shape = page.getShapes().get(0); | |
// Shape to image | |
com.aspose.diagram.ImageSaveOptions option = new com.aspose.diagram.ImageSaveOptions(SaveFileFormat.PNG); | |
shape.toImage("out.png",option); |