Convert Visio to PDF in Java

Convert Visio to PDF in Java

Are you looking to convert Visio to PDF in Java programmatically? This blog post will teach you how to manipulate and convert VSD/VSDX files to PDF file format using a few lines of code in Java. Visio diagrams are widely used to generate various designs of business processes and workflows. However, you need to transform your Visio diagrams to other popular file formats such as PDF, PNG and more. This Java Visio API offers a wide range of classes and methods to achieve this functionality.

We will cover the following points in this article:

Java Visio Converter API - Installation

This library is easy to install and offers comprehensive documentation where you can find a huge stack of methods and installation instructions. However, you can enable this API by either downloading the JAR files or the Maven configurations mentioned below:

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository> 

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-diagram</artifactId>
    <version>22.7</version>
</dependency>

How to convert Visio to PDF in Java

Visio diagrams offer rich modeling features for creating process diagrams. In this section, we are going to go through the steps and the code snippets to convert VSD to PDF programmatically.

You may follow the steps mentioned below:

  1. Call the Diagram constructor to load the diagram from a VSD file.
  2. Invoke the save method to save as PDF file format.

The sample code below demonstrates how to convert Visio diagram file in VSD or VSDX format to PDF in Java:

You can see the output in the image below:

VSDX to PDF in Java

VSDX to PDF in Java

Visio to PDF Conversion in Java - Advanced Options

You can also configure the API calls as per your business requirements.

We will explore some key features by following the steps and the code snippets:

  1. Create an object of the Diagram class to load the diagram from a VSDX file.
  2. Instantiate an instance of PdfSaveOptions class to specify additional options when rendering diagram pages to PDF.
  3. Pass a value to the SplitMultiPages method to define whether split diagram to multi-pages according to the page setting option.
  4. Specify the quality of JPEG compression for images by calling the setJpegQuality method.
  5. Invoke the setPageSize method to set the page size for the generated images.
  6. Call the save method to save in PDF format.

The following code snippet shows how to convert Visio VSDX to PDF using Java:

Get a Free License

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

Summing up

This brings us to the end of this article. Hope you have learned how to convert Visio to PDF in Java programmatically. In addition, we also have explored some advanced options that offer enterprise-level Visio to PDF conversion features. Moreover, you may visit documentation of this Java Visio Converter API to know about other methods. Furthermore, conholdate.com is writing new blog posts on new topics. Therefore, please stay in touch for regular updates.

Ask a question

You can let us know about your questions or queries on our forum.

FAQs

How do I convert a Visio file to PDF?

You can convert VSD/VSDX to PDF using this Java Visio API. It is rich-featured and offers a wide range of methods to convert Visio to PDF in Java.

How do I save a large Visio file as a PDF?

You can invoke the save method of this library to equip your Java application with a Visio to PDF converter. In addition, you can check the list here to learn about other methods.

See Also