Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Last active July 27, 2022 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conholdate-gists/c22fd5a8a461acd2f046974b5504020b to your computer and use it in GitHub Desktop.
Save conholdate-gists/c22fd5a8a461acd2f046974b5504020b to your computer and use it in GitHub Desktop.
How to Convert Visio to PDF in Java
// Create an object of Diagram class to load diagram from a VSDX file
Diagram diagram = new Diagram( "sample.vsdx");
// Instantiate an instance of PdfSaveOptions class to specify additional options when rendering diagram pages to PDF.
PdfSaveOptions options = new PdfSaveOptions();
// pass a value to the SplitMultiPages method to define whether split diagram to multi pages according to page's setting. option
options.setSplitMultiPages(true);
// Specify the quality of JPEG compression for images by calling the setJpegQuality method
options.setJpegQuality(100);
// Invoke the setPageSize method to sets the page size for the generated images
options.setPageSize(null);
// Call the save method to save in PDF format
diagram.save( "SplitMultiPages.pdf", options);
// Call the diagram constructor to load diagram from a VSD file
Diagram diagram = new Diagram("sample.vsdx");
// Invoke the save method to save as PDF file format
diagram.save( "ExportToPDF_Out.pdf", SaveFileFormat.PDF);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment