Export Visio shapes to HTML

Export Visio shapes to HTML

Being an IT professional, engineer, or project manager, you may use MS Visio for Gantt charts or project plans. When your Visio license expires and you need to display a few shapes from existing VSDX files on the web, this article shows how to read and export Visio shapes to HTML using Python.

The article covers:

Installing Python Visio shapes exporter package

To convert Visio shapes to HTML, we use the Python Visio shape exporter package, which is precise and easy to use.

Install the package from PyPI with pip:

pip install aspose-diagram-python 

Retrieve Visio shapes list in Python

If you cannot open a VSDX file in MS Visio, you still need shape details before exporting. Follow these steps to list shapes:

  1. Load the VSDX file using the Diagram class.
  2. Define the page.
  3. Loop through the page’s shapes and print each shape’s ID and name.

The code sample below displays the Visio shapes list.

Sample output for the first page:

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

The VSDX file preview:

Retrieve Visio shapes list

Convert Visio (VSDX) shapes to HTML using Python

After reviewing the shape list, choose the shape you want to export.

Steps:

  1. Load the Visio file with the Diagram class.
  2. Define the page.
  3. Specify the shape.
  4. Create an instance of HTMLSaveOptions.
  5. Call the Shape.to_html method, passing the output path and the HTMLSaveOptions.

The code snippet below exports a Visio shape to HTML.

Resulting HTML preview:

Export Visio shape data to HTML

Get a free license

You can obtain a free temporary license to try the API without evaluation limits.

Summing up

You now know how to export a specific Visio shape to HTML. First, generate the shape data list, then export the chosen shape to an HTML file.

Visit the documentation to learn more about the Python Visio shape converter library.

Stay tuned at conholdate.com for regular updates.

Ask a question

Post your questions or queries on our forum.

FAQs

How do I export a shape in Visio?

This article explains how to export a Visio shape to HTML. See the full guide for other export options.

Can Visio export to SVG?

Yes. You can export Visio documents to SVG and many other formats using various programming languages. Helpful links:

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

Yes. License holders of conholdate.com can use all APIs of Aspose and GroupDocs product families.