Export Visio shapes to HTML

Export Visio shapes to HTML

Being an IT professional, engineer, or project manager, you may use the MS Visio diagramming tool for your Gantt charts or project plans. At some stage, if your MS Visio expires and you need to display a few shapes on the web from the existing VSDX files, this article may solve your problem. So, let’s discuss how to read and export Visio shapes to HTML using Python.

The following points will be covered in this article:

Installing Python Visio shapes exporter package

To export/convert the Visio shapes to an HTML form, we will use a Python Visio shape exporter package, which is precise and easy to use.

Please download or install the package from PyPI using the pip command given below:

pip install aspose-diagram-python 

Retrieve Visio shapes list in Python

Without MS Visio, when you can’t open and see the existing shapes of a VSDX file, you may need to know the details of those shapes before exporting the desired one to HTML. So, let’s get the shapes data list using the steps below:

  1. Load the VSDX file using Diagram class.
  2. Define the page.
  3. Loop through the shapes of the defined page and print the shape id and name.

The following code sample shows how to display the Visio shapes list using Python.

Below is the data about existing shapes on the first page of the VSDX file.

Shape ID - 7
Name - FAS62xx rear empty

Shape ID - 494
Name - FAS62xx Controller Module

Shape ID - 743
Name - Sheet.743

Shape ID - 779
Name - DS14 mk2 FC.70

Shape ID - 795
Name - Sheet.795

Shape ID - 796
Name - Rectangle

Whereas the VSDX file looks like this:

Retrieve Visio shapes list

Convert Visio (VSDX) shapes to HTML using Python

After retrieving the list, we got an idea about the existing shapes and their positions. So, we can now choose the desired shape to export.

Please follow the steps given below:

  1. Load Visio file using Diagram class.
  2. Define the page.
  3. Specify the shape.
  4. Create an instance of HTMLSaveOptions class.
  5. Call Shape.to_html method to export the shape. It will take the output file path and HTMLSaveOptions as arguments.

The following code snippet shows how to export Visio shape to HTML in Python.

You will see the resultant HTML as follows.

Export Visio shape data to HTML

Get a free license

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

Summing up

To sum up, we hope you have learned how to export a specific Visio shape to HTML. Initially, we generated the shape data list and then exported a single shape to an HTML file.

You may visit the documentation to learn more about the Python Visio shape converter library.

Finally, we suggest you stay tuned at conholdate.com for regular updates.

Ask a question

You can let us know your questions or queries on our forum.

FAQs

How do I export a shape in Visio?

In this article, we have discussed how to export a Visio shape to HTML. Please follow this link to explore other exporting options.

Can Visio export to SVG?

You can export your Visio documents to SVG or many other formats using various programming languages. Just follow the links below:

Can I use Aspose.Diagram for Python as a customer of conholdate.com?

Yes, the license holder of conholdate.com is eligible to use all APIs of Aspose and GroupDocs product families.