Save Visio document programmatically
Visio Drawing Save Overview
Use the Diagram.Save method to save a Microsoft Visio drawing. There are overloads that allow saving a drawing to file. The drawing can be saved in any save format supported by Aspose.Diagram. For the list of all supported save formats see the SaveFileFormat Enum.
Saving Visio Diagram
The Diagram class of the Aspose.Diagram API represents a Visio drawing and developers can save its Visio diagram object in any supported file format. To save a Microsoft Visio file, simply use the Diagram.Save method, it accepts a file name with a complete path or a file stream object. Aspose.Diagram API infers the save format from the file extension and also offers an additional SaveFileFormat parameter to specify the output file format.
Save a Visio Diagram in any Supported File Format
Using Aspose.Diagram API, developers can save a Visio diagram in any supported file format as listed below: VSDX, VSDM, VSSX, VSSM, VSTX, VSTM, VDX, VSX, VTX, TIFF, PNG, BMP, EMF, JPEG, PDF, XPS, GIF, HTML, SVG, SWF and XAML
Saving Diagram Programming Sample
The example below saves a document to a file.
// Save a Visio diagram
diagram.Save(GetMyDir() + "MyOutput.vsdx", SaveFileFormat.VSDX);
Specifying Visio Save Options
There are several Diagram.Save method overloads that accept a SaveOptions object. This should be an object of a class derived from the SaveOptions class. Each save format has a corresponding class that holds save options for that save format. For example, there is PdfSaveOptions for the SaveFileFormat.PDF save format.
Visio Diagram Save Options
These examples show how to:
- Use Diagram Save Options.
- Use PDF Save Options.
- Use HTML Save Options.
- Use Image Save Options.
- Use SVG Save Options.
- Use SWF Save Options.
Use of the Diagram Save Options
The code below shows how to set save options before saving a document to Visio format.
Use of the PDF Save Options
The code below shows how to set save options before saving a document to a PDF format.
Use of the HTML Save Options
The code below shows how to set save options before saving a document to HTML file format.
Use of the Image Save Options
The code below shows how to set save options before saving a document to image file format.
Use of the SVG Save Options
The code below shows how to set save options before saving a document to SVG format.
Sometimes, developers need to save or export Visio diagrams to different file formats programmatically (like VDX, PDF, JPEG and so on).
Saving VSD File to Other Formats with Aspose.Diagram for Python via .NET
Using Aspose.Diagram, developers don’t need Microsoft Office Visio in the machine, and they can work independently of Microsoft Office Automation.
The code snippets below show how to:
- Load a diagram.
- Save the diagram to VSX, PDF and JPEG.
Saving VSD File with Aspose.Diagram for Python via .NET Programming Sample
Example: