API Reference

Main API

libvisio_ng.convert(input_path, output_dir=None)

Convert a Visio file to SVG pages.

Returns a list of SVG file paths (one per page). Uses libvisio if available, otherwise built-in .vsdx parser.

Parameters:
  • input_path (str)

  • output_dir (str | None)

Return type:

list[str]

libvisio_ng.convert_page(input_path, page_index, output_dir)

Convert a specific page of a Visio file to SVG. Returns SVG path or None.

Parameters:
  • input_path (str)

  • page_index (int)

  • output_dir (str)

Return type:

str | None

libvisio_ng.get_page_info(input_path)[source]

Get page names and shape data from a Visio file.

Returns list of dicts: [{“name”: “Page-1”, “shapes”: […], “index”: 0}, …]

Parameters:

input_path (str)

Return type:

list[dict]

libvisio_ng.extract_text(input_path)

Extract all text from a Visio file.

Parameters:

input_path (str)

Return type:

str

libvisio_ng.export_to_png(svg_path, output_path, width=1920)[source]

Export an SVG to PNG using rsvg-convert or cairosvg.

Parameters:
  • svg_path (str)

  • output_path (str)

  • width (int)

Return type:

str

libvisio_ng.export_to_pdf(svg_path, output_path)[source]

Export an SVG to PDF using cairosvg.

Parameters:
  • svg_path (str)

  • output_path (str)

Return type:

str

VSD Binary Parser

libvisio_ng.parse_vsd_file(file_path)[source]

Parse a .vsd file and return a VsdDocument.

Parameters:

file_path (str | Path)

Return type:

VsdDocument

libvisio_ng.parse_vsd_to_dicts(file_path)[source]

Parse a .vsd file and return page data compatible with the VSDX SVG renderer.

Returns list of dicts with page_width, page_height, shapes, name.

Parameters:

file_path (str | Path)

Return type:

list[dict]

class libvisio_ng.VsdDocument(pages: 'list' = <factory>, colors: 'list' = <factory>, fonts: 'dict' = <factory>, names: 'dict' = <factory>, stencil_pages: 'list' = <factory>)[source]
Parameters:
class libvisio_ng.VsdPage(page_id: 'int' = 0, name: 'str' = '', width: 'float' = 8.5, height: 'float' = 11.0, shapes: 'list' = <factory>, background: 'bool' = False)[source]
Parameters:
class libvisio_ng.VsdShape(shape_id: 'int' = 0, shape_type: 'str' = 'Shape', parent: 'int' = 0, master_page: 'int' = -1, master_shape: 'int' = -1, xform: 'XForm' = <factory>, text_xform: 'TextXForm | None' = None, xform_1d: 'XForm1D | None' = None, text: 'str' = '', geometry: 'list' = <factory>, char_formats: 'list' = <factory>, para_formats: 'list' = <factory>, line_weight: 'float' = 0.01, line_color: 'str' = '#000000', line_pattern: 'int' = 1, fill_foreground: 'str' = '', fill_background: 'str' = '', fill_pattern: 'int' = 1, shadow_offset_x: 'float' = 0.0, shadow_offset_y: 'float' = 0.0, shadow_color: 'str' = '', shadow_pattern: 'int' = 0, children: 'list' = <factory>, sub_shapes: 'list' = <factory>, layer_member: 'str' = '', foreign_data: 'ForeignData | None' = None, connection_points: 'list' = <factory>, text_block_bg: 'str' = '', text_block_margin_left: 'float' = 0.0, text_block_margin_right: 'float' = 0.0, text_block_margin_top: 'float' = 0.0, text_block_margin_bottom: 'float' = 0.0, text_block_valign: 'int' = 0)[source]
Parameters:
  • shape_id (int)

  • shape_type (str)

  • parent (int)

  • master_page (int)

  • master_shape (int)

  • xform (XForm)

  • text_xform (TextXForm | None)

  • xform_1d (XForm1D | None)

  • text (str)

  • geometry (list)

  • char_formats (list)

  • para_formats (list)

  • line_weight (float)

  • line_color (str)

  • line_pattern (int)

  • fill_foreground (str)

  • fill_background (str)

  • fill_pattern (int)

  • shadow_offset_x (float)

  • shadow_offset_y (float)

  • shadow_color (str)

  • shadow_pattern (int)

  • children (list)

  • sub_shapes (list)

  • layer_member (str)

  • foreign_data (ForeignData | None)

  • connection_points (list)

  • text_block_bg (str)

  • text_block_margin_left (float)

  • text_block_margin_right (float)

  • text_block_margin_top (float)

  • text_block_margin_bottom (float)

  • text_block_valign (int)

class libvisio_ng.TextXForm(txt_pin_x=0.0, txt_pin_y=0.0, txt_width=0.0, txt_height=0.0, txt_loc_pin_x=0.0, txt_loc_pin_y=0.0, txt_angle=0.0)[source]

Text block transform — positions text independently of shape.

Parameters:
class libvisio_ng.XForm1D(begin_x=0.0, begin_y=0.0, end_x=0.0, end_y=0.0)[source]

1D connector endpoints.

Parameters:
class libvisio_ng.ParaFormat(char_count: 'int' = 0, indent_first: 'float' = 0.0, indent_left: 'float' = 0.0, indent_right: 'float' = 0.0, spacing_line: 'float' = -1.2, spacing_before: 'float' = 0.0, spacing_after: 'float' = 0.0, horiz_align: 'int' = 0, bullet: 'int' = 0, bullet_str: 'str' = '')[source]
Parameters:
class libvisio_ng.ForeignData(data_type='', img_format='', data=b'')[source]

Embedded image/OLE data.

Parameters:

Constants

libvisio_ng.VISIO_EXTENSIONS = {'.vsd', '.vsdm', '.vsdx'}

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

libvisio_ng.TEMPLATE_EXTENSIONS = {'.vst', '.vstm', '.vstx'}

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

libvisio_ng.STENCIL_EXTENSIONS = {'.vss', '.vssm', '.vssx'}

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.

libvisio_ng.ALL_EXTENSIONS = {'.vsd', '.vsdm', '.vsdx', '.vss', '.vssm', '.vssx', '.vst', '.vstm', '.vstx'}

set() -> new empty set object set(iterable) -> new set object

Build an unordered collection of unique elements.