
Aspose.Diagram for Java
Java API to Generate & Convert Visio Diagrams
Microsoft Visio Document Processing Java API to Generate, Modify, Manipulate, & Convert Visio Diagrams to PDF, HTML, XPS & Images File Formats.
What is Aspose.Diagram for Java?
Aspose.Diagram for Java is a handy tool for software developers. It allows you to create and handle Microsoft Visio Diagrams without needing Microsoft Office Visio. With this Java library, you can work with Visio diagrams in a more flexible way. You can print them accurately, secure them, view properties, link with different systems, and edit Visio diagrams in various ways. Imagine having the power to change Visio diagrams into various formats effortlessly. With Aspose.Diagram for Java, you can do just that. By using this tool, you can easily convert your Visio diagrams into formats like PDF, XPS, HTML, JPEG, and more with just a few lines of Java code. This streamlined conversion process allows you to share your Visio diagrams with others who might not have MS Visio or incorporate them into different systems.
Aspose.Diagram for Java lets software developers build fresh Visio diagrams or edit existing ones by adding, deleting, or adjusting shapes, lines, text, and more. This feature helps programmers automate key diagram-related tasks, like creating new diagrams, updating them with fresh data, or tweaking their look right within their Java applications. The library also includes handy functions such as linking shapes with hyperlinks, grouping various shapes, inserting comments to drawings, parsing Visio diagrams, and many more. The library is set up to work effectively on both the server and client sides. If you want to make new diagrams, change current ones, or automate tasks, Aspose.Diagram is here for you. Packed with strong capabilities and a user-friendly API, it is the ideal solution for any Java developer dealing with Visio diagrams.
Getting Started with Aspose.Diagram for Java
The recommend way to install Aspose.Diagram for Java is via Maven repository. You can easily use Aspose.Diagram for Java API directly in your Maven Projects with simple configurations.
Maven repository for Aspose.Diagram for Java
//First you need to specify Aspose Repository configuration / location in your Maven pom.xml as follows:
<repositories>
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://releases.aspose.com/java/repo/</url>
</repository>
</repositories>
//Then define Aspose.Diagram for Java API dependency in your pom.xml as follows:
<dependencies>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-diagram</artifactId>
<version>19.9</version>
<classifier>jdk16</classifier>
</dependency>
</dependencies>
You can download the library directly from Aspose.Diagram product page
Visio Diagrams Generation via Java API
Aspose.Diagram for Java has included complete supports for generating Microsoft Visio diagrams inside Java applications without Microsoft Office Automation. To create a new diagram from the scratch you need to create a new Visio documents and add shapes as well as connectors to build up the diagram. The library supports various Layout approaches helping developers to quickly and smoothly create the diagrams. The library fully support working with VBA projects and allows developers to modify their VBA module code automatically with just a couple of lines of java code. Developers can also easily retrieve Visio connectors and font information. The library also gives users the control to stop conversion or loading of diagrams using InterruptMonitor when it is taking too long.
How to Create New Visio Drawing via Java API?
string dataDir = RunExamples.GetDataDir_LoadSaveConvert();
// Initialize a Diagram class
Diagram diagram = new Diagram();
// Save diagram in the VSDX format
diagram.Save(dataDir + "CreateNewVisio_out.vsdx", SaveFileFormat.VSDX);
Visio Diagrams Conversion inside Java Apps
Aspose.Diagram for Java has included complete support for loading and converting Microsoft Visio diagrams to a wide range of file formats, including PDF, XPS HTML, EMF, SWF, XAML, JPEG, PNG, BMP, TIFF, SVG, EMF, and many more. The conversion process is simple and straightforward, and you can use the same code to convert multiple diagrams in batch mode. The library also supports the conversion of other file formats to Visio diagrams. You can easily control the appearance and behavior of the converted diagrams. The library supports setting options such as page size, margins, and more, to ensure that your converted diagrams look exactly the way you want them to.
How to Export Visio Drawing to PDF via Java Library?
String dataDir = Utils.getDataDir(ExportToPDF.class);
// Call the diagram constructor to load diagram from a VSD file
Diagram diagram = new Diagram(dataDir + "ExportToPDF.vsd");
// Save as PDF file format
diagram.save(dataDir + "ExportToPDF_Out.pdf", SaveFileFormat.PDF);
Work with Pages in Visio Diagrams via Java API/h2>
Pages are the building blocks of a Visio diagram and are used to organize the shapes, lines, and other elements that make up a diagram. Aspose.Diagram for Java library enables software developers to easily create new pages, access existing pages, and manipulate the elements on a page. It allows accessing the shapes and elements on a page, and modifying their properties, such as size, position, and appearance. You can also add new shapes and elements to a page, and delete existing ones. It is also very easy to access and work with layers. The library allows users to easily create new layers, access existing layers, and modify the properties of layers, such as visibility and printing behavior.
How to Get a Page Object by Name from Visio Drawing via Java API?
String dataDir = Utils.getDataDir(GetVisioPagebyName.class);
// Call the diagram constructor to load diagram from a VSDX file
Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");
// Set page name
String pageName = "Flow 2";
// Get page object by name
Page page2 = diagram.getPages().getPage(pageName);
Manage Masters in Visio Diagrams via Java API
Aspose.Diagram for Java makes it easy for software developers to work with masters and retrieve information like ID and names of masters inside Java applications. Masters are pre-designed shapes that can be reused multiple times in a Visio diagram. By using masters, you can ensure that your diagrams are consistent and standardized, which can make it easier to maintain and update your diagrams over time. The library allows creating new masters, modify existing ones, or delete masters that you no longer need. It is also possible to access the shapes and elements within a master, which makes it possible to manipulate the master's appearance and behavior. The library also allows controlling the behavior of the shapes in a master, such as how they respond to events such as resizing, rotating, and moving.
How to Get a Master from the Visio File via Java API?
String dataDir = Utils.getDataDir(GetMasterbyID.class);
// Call the diagram constructor to load diagram from a VDX file
Diagram diagram = new Diagram(dataDir + "RetrieveMasterInfo.vdx");
// Set master id
int masterid = 2;
// Get master object by id
Master master = diagram.getMasters().getMaster(masterid);
System.out.println("Master ID : " + master.getID());
System.out.println("Master Name : " + master.getName());
System.out.println("Master Name : " + master.getUniqueID());