Render Visio Files using Java

Microsoft Visio is a popular vector graphics tool that helps you visualize data-connected business process flows. It can be used to draw a variety of diagrams such as flowcharts, organization charts, building plans, floor plans, data flow diagrams, process flow diagrams, business process modeling, swimlane diagrams, 3D maps, and many more. As a Java developer, you can easily render Visio diagrams in HTML, PDF, and other popular image formats programmatically. In this article, you will learn how to render Visio diagrams in HTML, PDF, and Image using Java.

The following topics are discussed/covered in this article:

Java API to View Visio Files

I will be using GroupDocs.Viewer for Java API for the rendering of Visio files. It provides a most flexible document viewing solution to render and display widely used file formats anywhere. Using this API, you can create powerful document and image rendering applications in Java without installing any external software. It enables you to quickly view PDF, HTML, XML, Microsoft Office Word, Excel worksheets, PowerPoint presentations, Outlook emails, Visio diagrams, Project, metafiles, images, and various other file formats with ease and fewer programming hazards.

Download and Configure

Get the library from downloads or just add the following pom.xml configuration in your Maven-based Java applications to try the below-mentioned examples.

<repository>
	<id>GroupDocsArtifactRepository</id>
	<name>GroupDocs Artifact Repository</name>
	<url>https://repository.groupdocs.com/repo/</url>
</repository>
<dependency>
        <groupId>com.groupdocs</groupId>
        <artifactId>groupdocs-viewer</artifactId>
        <version>21.2</version> 
</dependency>

Render Visio VSSX in HTML

You can render the Visio VSSX file in HTML by following the simple steps given below:

  1. Create an instance of the Viewer class
  2. Provide the input file path
  3. Create an instance of HtmlViewOptions class
  4. Provide output file path
  5. Call the View method and pass HtmlViewOptions

The following code sample shows how to render the VSSX file in HTML using Java.

Render VSSX in HTML

Render VSSX in HTML

The **HtmlViewOptions **class provides options for rendering documents into HTML format. The ForEmbeddedResources constructor creates a new instance of HtmlViewOptions class for rendering into HTML with embedded resources. It provides certain options for various file formats such as VisioRenderingOptions for Visio files, Watermark options to set text watermark, security options, rendering options to render hidden pages, notes, and comments, etc.

You can find more details about “Document HTML Viewer” in the documentation.

Render Visio VSTX in PDF

You can render the Visio VSTX file in PDF format by following the simple steps given below:

  1. Create an instance of the Viewer class
  2. Provide the input file path
  3. Create an instance of PdfViewOptions class
  4. Provide output file path
  5. Call the View method and pass PdfViewOptions

The following code sample shows how to render the VSTX file in PDF using Java.

Render VSTX in PDF

Render VSTX in PDF

The **PdfViewOptions **class provides options for rendering documents into PDF format. It also allows setting separate options for different file formats including text watermark, security options, and rendering of hidden pages, notes, and comments, etc.

You can find more details about “Document PDF Viewer” in the documentation.

Render Visio VSDX as Image

You can render the Visio VSDX file in JPG or PNG format by following the simple steps given below:

  1. Create an instance of the Viewer class
  2. Provide the input file path
  3. Create an instance of PngViewOptions class
  4. Provide output file path
  5. Call the View method and pass PngViewOptions

The following code sample shows how to render the VSDX file in PNG using Java.

Render VSDX as PNG

Render VSDX as PNG

You may also render the Visio files in JPG using Java as shown below:

Render VSDX as JPG

Render VSDX as JPG

The **PngViewOptions **class provides options for rendering documents into PNG format. Similarly, the **JpgViewOptions **class provides options for rendering documents into JPG format. Both of the classes also provide setting options for other formats along with text watermark, security options, and rendering of hidden pages, notes, and comments, etc.

You can find more details about “Document Image Viewer” in the documentation.

Get a Free License

You can try the API without evaluation limitations by requesting a free temporary license.

Conclusion

In this article, you have learned how to render Visio (.vsdx, .vstx, .vssx) files in HTML, PDF, PNG, and Jpg using Java. You can learn even more about GroupDocs.Viewer Java API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.

See Also