Convert Visio to HTML format

导出 Visio 到 HTML

This article explains how to export a Microsoft Visio diagram to HTML using Aspose.Diagram for .NET API.

使用Diagram class constructor to read the diagram files and the Save method to export the diagram to any supported image format. Developers can save resultant HTML in the local storage or directly to a stream instance.

  1. Save resultant HTML in the local storage.
  2. Save resultant HTML in a stream instance.

The image below shows a VSD file about to be saved to PNG format. You can use other diagram formats (VSDX, VSDM, VSTX, VSSX, VSS, VSSM, VDX, VST, VSTX, VDX, VTX or VSX) as well.

输入 diagram。
待办事项:图片_替代_文本
In order to export VSD diagram to HTML, perform the following steps:
  1. 创建 Diagram 类的实例。
  2. Call the Dagram class' Save method and set HTML as the output format.

Save resultant HTML in the local storage

生成的文件可以通过传递完整的路径字符串来保存,包括文件名和扩展名,例如@“c:\temp\MyOutput.html”。

Save Resultant HTML in Local Storage Programming Sample

Save resultant HTML in a stream instance

It is for use case to save the resultant HTML in a database or repository without storing it in the local storage. This feature also embeds other resultant resources of the HTML, e.g. fonts, CSS (containing the style information) and images. Since it saves a single HTML file into the stream instance.

Save Resultant HTML in a Stream Programming Sample

 // Load an existing visio diagram

Diagram diagram = new Diagram("Basic Flowchart.vsd");

// Save resultant HTML directly to a stream

MemoryStream stream = new MemoryStream();

diagram.Save(stream, SaveFileFormat.HTML);