This article is written to help you understand the process of how to convert Visio to JPG in Java. It includes the sample code and the step-by-step guide to convert a VSD or VSDX to JPG in Java. You will also learn to customize the conversion process and generate output images as per the requirements.
Steps to Convert Visio to JPG in Java
- Install the Aspose.Diagram library to export the Visio diagrams to JPG
- Load the source Visio file with the Diagram class object
- Set different properties of the output image with ImageSaveOptions class
- Convert the VSD/VSDX file to JPG format with the save() method
These steps precisely explain the algorithm to convert Visio to JPG in Java. First of all, load the source Visio diagram with an object of the Diagram class. In the next step, set the output image preferences and call any of the available overloads of the save method which let you export the output data to a file or a stream as per your needs.
Code to Convert Visio to JPG in Java
The sample code above is sufficient to embed the feature to convert VSDX to JPG in Java into your projects as it contains all the information to load the source diagram along with the option to set the page index from which the source file is to be loaded. Similarly, you can set an interrupt monitor in case of any abnormality while loading the source file. The image properties can also be set like the zoom, font, scale, dimensions, etc. to name a few.
This tutorial has presented all the relevant information to help you understand how to convert VSD to JPG in Java. Similarly, the other variation of Visio diagrams, the VSDX files, can also be processed with the same approach. If you want to learn Visio to SVG image conversion, refer to the article on how to convert Visio to SVG in Java.