Free Python Library to Create & Manage Visio Diagrams

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

In today's data-driven world, effective visualization of complex information is crucial for conveying insights and making informed decisions. Microsoft Visio, a widely used diagramming tool, plays a vital role in creating diagrams, flowcharts, and organizational charts. To harness the potential of Visio files within the Python ecosystem, the 'vsdx' Python library emerges as a powerful tool. This library bridges the gap between the convenience of working with Visio diagrams and the power of Python's scripting capabilities.

The 'vsdx' library is an advanced Python module designed to provide an interface for reading and editing Visio files (VSDX format) without the need for Microsoft Visio itself. It provides an intuitive interface to create, modify, and analyze Visio diagrams programmatically. This functionality is essential for developers who want to automate tasks involving Visio files or integrate diagram creation into their applications. 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 open source and is very easy to handle. The library brings the power of programmatic manipulation to Microsoft Visio files and empowers software developers to automate tasks, integrate data, and generate dynamic diagrams seamlessly. Its intuitive interface and extensive feature set make it a game-changer for those seeking to leverage Python for efficient Visio file manipulation. Whether you're creating complex business process diagrams or simple flowcharts, the VSDX library is a valuable tool in your arsenal.

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')