Convert a Visio Shape To Image

Convert a visio shape to image

This topic elaborates how developers can convert a visio shape to image using Aspose.Diagram. The ToImage method exposed by the Shape class can be used to convert to image.

The code below shows how to:

  1. Load a sample diagram.
  2. get a particular page.
  3. get a particular shape.
  4. convert shape to image.

Shape to image Programming Sample

Use the following code in your .net application to convert a visio shape to image.

// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Shapes();
// Call a Diagram class constructor to load the VSDX diagram
Diagram diagram = new Diagram(dataDir + "ShapeToImage.vsdx");
// Get a particular page
Page page = diagram.Pages[0];
// Get a particular shape
Shape shape = page.Shapes[0];
// Shape to Image
Aspose.Diagram.Saving.ImageSaveOptions o = new Aspose.Diagram.Saving.ImageSaveOptions(SaveFileFormat.PNG);
shape.ToImage("out.png", o);