This technical tip shows how .NET developers can export Microsoft Visio diagram to PDF inside their own applications using Aspose.Diagram for .NET. Aspose.Diagram for .NET allows reading and creating diagrams as well as lets developers export diagrams to a variety of formats: XML formats, image formats, HTML, SVG, SWF and PDF. This tip explains how to export a Microsoft Visio diagram to PDF using Aspose.Diagram for .NET. Use the Diagram class' constructor to read the diagram files and the Save method to export the diagram to any supported image format. The image below shows the VSD diagram that the code snippets below export PDF. You can use other diagram formats (VSS, VDX, VST, VDX, VTX or VSX) as well.
Export VSD diagram to PDF:
• Create an instance of the Diagram class.
• Call the Diagram classs Save method and set the output format to PDF.
The Sample code shows how to export Visio diagrams to a VSD formats
'Call the diagram constructor to load diagram from a VSD file
Dim diagram As New Diagram("D:\Drawing1.vsd")
Dim pdfStream As New MemoryStream()
Dim pdfContent() As Byte = pdfStream.GetBuffer()
Me.Response.Charset = "UTF-8"
Me.Response.ContentEncoding = System.Text.Encoding.UTF8
Me.Response.ContentType = "application/pdf"
Me.Response.AppendHeader("Content-Disposition", "attachment; filename=Diagram.pdf")
Overview: Aspose.Diagram for .NET
Aspose.Diagram is a class library for working with MS Visio files & is a pure .NET alternate for MS Visio Object Model. It enables developers to work with VSD & VDX files on ASP.NET web applications, web services & Windows applications. It makes use of the advanced functionality of Visio's services to manipulate Visio docs on a server. Developer can open files & manipulate the elements of the diagram, from lines and fills, to more complex elements, and then export to native Visio formats or XML.
Learn more about Aspose.Diagram for .NET