Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Export Microsoft Visio Diagram to PDF

sherazamsherazam Posts: 2Member

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

[C#]

//Call the diagram constructor to load diagram from a VSD file Diagram diagram = new Diagram("D:\Drawing1.vsd");

MemoryStream pdfStream = new MemoryStream(); diagram.Save(pdfStream, SaveFileFormat.PDF);

byte[] pdfContent = pdfStream.GetBuffer(); pdfStream.Close();

this.Response.Clear(); this.Response.ClearHeaders(); this.Response.Charset = "UTF-8"; this.Response.ContentEncoding = System.Text.Encoding.UTF8; this.Response.ContentType = "application/pdf"; this.Response.AppendHeader("Content-Disposition", "attachment; filename=Diagram.pdf"); this.Response.BinaryWrite(pdfContent); this.Response.End();

[VB.NET]

'Call the diagram constructor to load diagram from a VSD file Dim diagram As New Diagram("D:\Drawing1.vsd")

Dim pdfStream As New MemoryStream() diagram.Save(pdfStream, SaveFileFormat.PDF)

Dim pdfContent() As Byte = pdfStream.GetBuffer() pdfStream.Close()

Me.Response.Clear() Me.Response.ClearHeaders() 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") Me.Response.BinaryWrite(pdfContent) Me.Response.End()

Sign In or Register to comment.