Free Python Library to Create & Export Visio Diagrams

Open Source Visio Python Library for Generating, Modifying, Manipulatin and Exporting Visio VSDX Diagrams. It supports Styling, Formatting & Conversion to other File Formats.

What is Vsdx Library?

In today’s world where data is key, it’s essential to present complex information in a way that’s easy to understand for better decision-making. Microsoft Visio is a popular tool for creating diagrams and charts. To make the most of Visio files with Python, the ‘vsdx’ Python library is a valuable resource. This library connects the ease of Visio with the capabilities of Python, giving you a powerful tool at your fingertips for better software development. There are several important features part of the library, such as creating new diagrams from scratch, modifying existing ones, controlling the layout of the diagram, integrating data with diagrams, converting Visio diagrams to other supported file formats, diagram validation, and many more.

The ‘vsdx’ library is a sophisticated Python tool created to help you work with Visio files (in VSDX format) using Python, without having to use Microsoft Visio. It allows you to easily make changes to Visio diagrams, create new ones, and analyze them using code. This feature is particularly valuable for developers looking to automate processes related to Visio files or include diagram creation in their software. The ‘vsdx’ library is open source and user-friendly. It allows you to easily work with Microsoft Visio files. This library enables software developers to automate tasks, merge data, and create interactive diagrams effortlessly. With its simple interface and many features, it revolutionizes the way Python can be used to manage Visio files efficiently. Whether you are designing intricate business process diagrams or straightforward flowcharts, the VSDX library is a valuable tool for your projects.

Previous Next

Getting Started with vsdx

PThe recommend way to install vsdx library is using pypi. Please use the following command for a smooth installation.

Install vsdx Library via pypi

pip install vsdx

Visio Diagram Creation & Editing via Python API

The open source vsdx library has included complete support for generating new Visio diagrams from scratch inside their own Python applications. Software developers can add new shapes and apply various styles, such as colors, fonts, and line types, to enhance the visual appeal of diagrams. Moreover, software developers can programmatically modify existing diagrams. This includes adding or removing shapes, changing their properties (size, color, position), and updating text labels. This feature enables dynamic generation ofM diagrams based on changing data.

Creating a New vsdx File from a Template via Python API

from vsdx import VisioFile

filename = 'my_template_file.vsdx'  # file containing jinja code
context = {'value1': 10, 'list_value': [1,2,3]}  # data for the template
with VisioFile('my_template_file.vsdx') as vis: 
    vis.jinja_render_vsdx(context=context)
    vis.save_vsdx('my_new_file.vsdx')

Visio Diagram Export & Conversion via Python

The open source vsdx library allows software developers to convert Visio diagrams to other supported file formats with just a couple of lines of code inside their own Python applications. The library supports exporting diagrams to various formats, such as PNG, SVG, or PDF. This is valuable for sharing diagrams across different platforms and integrating them into reports or presentations.

Read, Edit & Extract Info from Visio Files via Python API

The open source vsdx library makes it easy for software developers to load and read information from a Visio files inside Python applications. The library allows software developers to parse and extract information from existing Visio files. This capability is immensely useful for analyzing diagrams, extracting data, or generating reports based on the contents of the files. The following example demonstrates how to read a Visio file, find a shape with specific text, remove it, and then save the updated .vsdx file.

How to Read, Find a Shape with Specific Text, Modify it, & Save the .vsdx File?

from vsdx import VisioFile

filename = 'my_file.vsdx'
# open a visio file
with VisioFile(filename) as vis:
  # get page shapes collection
  shapes = vis.pages[0]._shapes
  # get shape to remove by its text value
  s = shapes[0].find_shape_by_text('Shape to remove')  # type: VisioFile.Shape
  # remove the shape if found
  if s:
    s.remove()
    # save a new copy
    vis.save_vsdx('shape_removed.vsdx')

 English