Save VSD File to Different File Formats
Contents
[
Hide
]
In this article, we compare the conversion features of Aspose.Diagram for .NET with VSTO. It contains .NET code samples to convert VSD files to VDX, PDF, and JPEG file formats.
VSTO
VSTO lets you program with Microsoft Visio files. To save a file to other formats:
- Create a Visio application object.
- Make the application object invisible.
- Load the diagram.
- Save to VDX, PDF, and JPEG.
- Quit the Visio application object.
//Create Visio Application Object
Visio.Application vsdApp = Application;
//Make Visio Application Invisible
vsdApp.Visible = false;
//Create a document object and load a diagram
Visio.Document vsdDoc = vsdApp.Documents.Open("Drawing.vsd");
//Save the VDX diagram
vsdDoc.SaveAs("Drawing1.vdx");
//Save as PDF file
vsdDoc.ExportAsFixedFormat(Visio.VisFixedFormatTypes.visFixedFormatPDF,
"Drawing1.pdf", Visio.VisDocExIntent.visDocExIntentScreen,
Visio.VisPrintOutRange.visPrintAll, 1, vsdDoc.Pages.Count, false, true,
true, true, true, System.Reflection.Missing.Value);
Visio.Page vsdPage = vsdDoc.Pages[1];
//Save as JPEG Image
vsdPage.Export("Drawing1.jpg");
//Quit Visio Object
vsdApp.Quit();
Aspose.Diagram
When programming with Aspose.Diagram, you do not need Microsoft Visio on the machine, and you can work independently of Microsoft Office Automation. The code snippets below show how to:
- Load a diagram.
- Save the diagram to VDX, PDF, and JPEG.
//Load diagram
Diagram vsdDiagram = new Diagram("Drawing.vsd");
//Save the diagram as VDX
vsdDiagram.Save("Drawing1.vdx", SaveFileFormat.VDX);
//Save as PDF
vsdDiagram.Save("Drawing1.pdf", SaveFileFormat.PDF);
//Save as JPEG
vsdDiagram.Save("Drawing1.jpg", SaveFileFormat.JPEG);