DEV Community

AsposeDiagram
AsposeDiagram

Posted on • Edited on

3 3

Convert Microsoft Visio Document to PDF in Java

Developers can convert any Microsoft Visio document to PDF (Portable Document Format) in Java using Aspose.Diagram which is a light-weight, extensible, easy to use API, that helps developers to create, manipulate and convert Microsoft Visio files to various formats on client side and server-side without any need to install Microsoft Visio or using any sort of Microsoft Office automation.

Supported Platforms

Aspose.Diagram supports both Java and .NET platforms. Please see Aspose.Diagram for Java and Aspose.Diagram for .NET for your reference.

Sample Microsoft Visio Document - VSDX

For demonstration purpose, we will convert the following sample Microsoft Visio document to PDF in Java using Aspose.Diagram for Java. However, you can use any Microsoft Visio document of your choice inside the sample code and it will also be converted to PDF fine.

Sample Microsoft Visio Document to be converted to PDF using Aspose.Diagram API.

Licensing

Please note, if you will execute the code without prior setting the Aspose.Diagram license, you will get Evaluation Watermark in your output documents. For more information, please go through Licensing.

Sample Code

The following sample code converts the Microsoft Visio document to PDF by performing these steps.

  • Load Microsoft Visio document to com.aspose.diagram.Diagram object.
  • Save the com.aspose.diagram.Diagram object into PDF format.
// Path for input and output documents directory.
String dirPath = "D:/Download/";
// Load the sample Microsoft Visio document inside the com.aspose.diagram.Diagram object.
com.aspose.diagram.Diagram dg = new Diagram(dirPath + "sampleConvertMicrosoftVisioDocumentToPDF.vsdx");
// Save the com.aspose.diagram.Diagram object into PDF format.
dg.save(dirPath + "outputConvertMicrosoftVisioDocumentToPDF.pdf", SaveFileFormat.PDF);

Output PDF by Aspose.Diagram

The following snapshot shows the Output PDF generated by Aspose.Diagram with the code given above. As you can see, the PDF looks exactly same as Microsoft Visio document.

Output PDF generated by Aspose.Diagram from Microsoft Visio document.

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay