Convert Visio to PDF in Python

Microsoft Visio is a popular vector graphics application. It allows drawing a variety of simple or complicated professional diagrams, flowcharts, timelines, etc. It uses the VSDX as a default file format for saving drawing files. In certain cases, we may need to convert Visio diagrams to PDF documents. Such conversion can help keep records or share Visio files in a portable form. In this article, we will learn how to convert Visio to PDF in Python.

The following topics shall be covered in this article:

  1. Python Visio to PDF Converter – Free Download
  2. Steps to Convert Visio Drawing to PDF Document
  3. Convert Visio to PDF Programmatically
  4. Convert Visio to PDF with Save Options

Python Visio to PDF Converter – Free Download

To convert a Visio drawing to a PDF document, we will be using the Aspose.Diagram for Python. It allows creating, editing, converting, and processing MS Visio diagrams. The API makes it easier for you to manipulate the supported Visio file formats with easy-to-use properties and methods.

The Diagram class of the API is the root element of Visio objects hierarchy. It provides save(string, SaveFileFormat) method to save the diagram data to the file in a specified format. The SaveFileFormat enumeration provides saving diagram format selection. We have PdfSaveOptions class that allows specifying additional options when rendering diagram pages to PDF.

Please either download the package or install the API from PyPI using the following pip command in the console:.

pip install aspose-diagram-python 

How to Convert Visio Drawing to PDF using Python

We can easily convert a Visio drawing to a PDF document using Aspose.Diagram for Python by following the steps given below:

  • Load a Visio drawing file.
  • Save Visio as PDF.

Now, let’s see how to perform these steps in Python to convert a Visio file to a PDF document.

Convert Visio to PDF Programmatically in Python

Please follow the steps given below to convert a Visio to a PDF:

  1. Load an input Visio file using the Diagram class.
  2. Call the save() method to save it as a PDF. It takes the output PDF file path as an argument.

The following code sample shows how to convert a Visio drawing to a PDF document using Python.

Convert-Visio-to-PDF-using-Python

Convert Visio to PDF using Python.

Convert Visio to PDF with Save Options in Python

We can specify PDF save options while converting a Visio file to a PDF document by following the steps given below:

  1. Firstly, load an input Visio file using the Diagram class.
  2. Next, create an instance of the PdfSaveOptions class.
  3. After that, specify save options such as page_size, page_index, etc.
  4. Finally, call the save() method to save it as a PDF. It takes the output PDF file path and PdfSaveOptions as arguments.

The following code sample shows how to convert a Visio to a PDF document with options using Python.

Get Free Temporary License

You can get a free temporary license to try the library without evaluation limitations.

Conclusion

In this article, we have learned how to:

  • load an existing Visio drawing file;
  • specify page size;
  • define PDF save options;
  • save Visio drawing file as a PDF in Python.

Besides converting Visio to PDF in Python, you can learn more about Aspose.Diagram for Python API using the documentation. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also