Convert Visio to HTML in Python

Microsoft Visio is a popular drawing software that is used to create diagrams, flowcharts and other illustrations. There are many use cases for Visio, from creating simple diagrams to complex engineering drawings. It uses the VSDX as a default file format for saving drawing files. In certain cases, we may need to convert Visio diagrams to HTML webpages. In this article, we will learn how to convert Visio to HTML in Python.

The following topics shall be covered in this article:

  1. Python Visio to HTML Converter – Free Download
  2. Steps to Convert Visio Drawing to HTML Document
  3. Convert Visio to HTML Programmatically
  4. Convert Visio to HTML with Save Options

Python Visio to HTML Converter – Free Download

For converting Visio drawings to HTML webpages, we will be using the Aspose.Diagram for Python. We can create, edit, convert, and process MS Visio diagrams using the API. The API also makes it easier to manipulate the supported Visio file formats with easy-to-use properties and methods.

The Diagram class of the API is the root element of the Visio objects hierarchy. The save(string, SaveFileFormat) method of this class allows saving the diagram data to the file in a specified format. We have the SaveFileFormat enumeration that provides a saving diagram format selection. We can specify additional save options when rendering diagram pages to HTML using the HTMLSaveOptions class.

Please either download the package or install the API from PyPI using the following pip command in the console:

pip install aspose-diagram-python 

How to Convert Visio Drawing to HTML using Python

We can easily convert a Visio drawing to an HTML document using Aspose.Diagram for Python by following the steps given below:

  • Load a Visio drawing file.
  • Save as HTML.

Now, let’s see how to transform these steps in Python to convert a Visio file to an HTML webpage.

Convert Visio to HTML Programmatically in Python

Please follow the steps given below to convert a Visio file to HTML:

  1. Load an input Visio file using the Diagram class.
  2. Call the save() method to save it as an HTML. It takes the output HTML file path and SaveFileFormat as arguments.

The following code sample shows how to convert a Visio diagram to an HTML webpage using Python.

Convert-Visio-to-HTML-using-Python

Convert Visio to HTML using Python.

Convert Visio to HTML with Save Options in Python

We can specify HTML save options while converting a Visio file to HTML webpage by following the steps given below:

  1. Firstly, load an input Visio file using the Diagram class.
  2. Next, create an instance of the HTMLSaveOptions class.
  3. After that, specify save options such as default_font, page_size, page_index, etc.
  4. Finally, call the save() method to save it as an HTML. It takes the output HTML file path and HTMLSaveOptions as arguments.

The following code sample shows how to convert a Visio to an HTML document with options using Python.

Get Free Temporary License

You can get a free temporary license to try the library without evaluation limitations.

Conclusion

In this article, we have learned how to:

  • load an existing Visio drawing file;
  • define HTML save options;
  • specify page size;
  • specify default font;
  • save Visio drawing as HTML in Python.

Besides converting Visio to HTML in Python, you can learn more about Aspose.Diagram for Python API using the documentation. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also