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:
- Python Visio to HTML Converter – Free Download
- Steps to Convert Visio Drawing to HTML Document
- Convert Visio to HTML Programmatically
- 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.
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:
- Load an input Visio file using the Diagram class.
- 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 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:
- Firstly, load an input Visio file using the Diagram class.
- Next, create an instance of the HTMLSaveOptions class.
- After that, specify save options such as default_font, page_size, page_index, etc.
- 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.
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.