Skip to content

Instantly share code, notes, and snippets.

@farhan-raza
Created August 4, 2023 17:29
Show Gist options
  • Save farhan-raza/ee558cddc3956beb70da60017606663c to your computer and use it in GitHub Desktop.
Save farhan-raza/ee558cddc3956beb70da60017606663c to your computer and use it in GitHub Desktop.
Convert Image to Visio Online | JPG PNG BMP TIFF to Visio in C# .NET or Java
// Create a new diagram
Diagram diagram = new Diagram();
// Get page object by index
Page page0 = diagram.Pages[0];
// Set pinX, pinY, width and height
double pinX = 1, pinY = 1, width = 4, hieght = 5;
// Import Bitmap image as Visio shape
page0.AddShape(pinX, pinY, width, hieght, new FileStream("C:\\Files\\tower.png", FileMode.OpenOrCreate));
// Save Visio diagram
diagram.Save("C:\\Files\\PNGtoVisio.vsdx", SaveFileFormat.Vsdx);
// Create a new diagram
Diagram diagram = new Diagram();
// Get page object by index
Page page0 = diagram.getPages().get(0);
// Load JPG image to insert into a VSDX
InputStream stream = new FileInputStream("C:\\Files\\person.png");
// Set pinX, pinY, width and height
double pinX = 2, pinY = 2, width = 4, hieght = 5;
// Import Bitmap image as Visio shape
page0.addShape(pinX, pinY, width, hieght, stream);
// Save Visio diagram
diagram.save("C:\\Files\\PNGtoVisio.vsdx", SaveFileFormat.VSDX);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment