Convert Visio to SVG or Visio to HTML in Node.js

Convert Visio to SVG or Visio to HTML in Node.js

In our previous blog post, we went through how to convert VSDX files to PDF and PNG programmatically in the Node.js application. However, this article will go through the steps and the code snippet to convert Visio to SVG or Visio to HTML in Node.js. This Visio Node.js library enables you to edit, create and convert VSDX files to another file format easily and quickly. Further, you may save your diagram as a web page to embed in your business websites.

The following points shall be covered in this blog post:

Convert Visio to SVG using Node.js

In this section, we will learn how to convert VSDX or VSD file to SVG programmatically by writing a few lines of source code. You may visit this article to know about the installation of this API.

The following steps will be performed:

  1. Invoke the Diagram() constructor to load a VSDX file.
  2. Initialize a new instance of SVGSaveOptions() to specify additional options.
  3. Call setSVGFitToViewPort(true) method that will make the generated SVG fit to viewport.
  4. Use this setExportElementAsRectTag(true) method to set export element as Rectangle.
  5. save(filename, format) method to save the file in SVG format.

Copy and paste the following code snippet into your file.

VSDX to SVG in Node.js

VSDX to SVG in Node.js

Node.js library to convert VSDX or Visio to HTML

We will follow the steps mentioned below to convert the VSDX file to a web page:

  1. Initialize the Diagram() constructor to load a VSDX file.
  2. Instantiate a new instance of HTMLSaveOptions() to define additional options.
  3. Call this setTitle(string) method to set the title of the HTML document.
  4. setSaveToolBar(true) will specify whether to include the toolbar or not.
  5. Invoke setDefaultFont(string) method to set the font.
  6. save(filename, format) method to save the file in HTML format.

The following code snippet converts a Visio diagram to a HTML file.

Convert VSDX to HTML in Node.js

VSDX to HTML in Node.js

Convert Visio to SVG or Visio to HTML in Node.js - advance options

In addition, this Node.js Diagram library also provides many features related to HTML and SVG file formats. However, you may find the code snippets also that demonstrate the usage of the methods.

Get a Free License

Please try the API beyond evaluation limitations by requesting a free temporary license.

Summing up

This brings us to end this blog post. We have gone through some interesting points that include converting Visio to SVG and Visio to HTML in Node.js application. This blog post will really help you if you are looking to integrate Aspose.Diagram library to convert VSDX files to other popular file formats. In addition, you may explore the documentation for further features. Moreover, conholdate.com is continuously writing new articles. Therefore, please stay connected for the latest updates.

Ask a question

You can share your questions or queries on our forum.

See Also