In certain cases, you may need to read shape data from Visio diagrams. It is usually helpful when diagrams contain metadata. You can extract this information in Java without Microsoft Visio or Office Interop. It is ideal for reporting, data checks, or automation tools. In this post, we will show you how to read shape data using Java in a clear and simple way.
Java Visio Library to Read Shape Data
In this article, we will use Aspose.Diagram for Java to read shape data from Visio files. The API gives full access to shapes, pages, and custom properties. It works with VSDX, VSD, and other formats.
You can use this library in any Java project. It is easy to set up and supports large diagrams and batch processing. If your app needs to work with Visio files, this SDK is a great tool.
Please download the library from the releases and add the JAR to your project or install via Maven:
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-diagram</artifactId>
<version>25.7</version>
</dependency>
How to Read Visio Shape Data in Java
Follow these steps to read shape data from a Visio file:
- Load the file using the
Diagram
class. - Get a page from the diagram.
- Loop through shapes on the page.
- Print shape ID and name.
Here’s a Java code snippet that demonstrates how to read Visio shape data in Java:
Total Pages: 1
Shape ID: 1
Name: Square
Shape ID: 2
Name: Rectangle
Shape ID: 3
Name: Dynamic connector
Read a Shape Property by Name
You can read a shape’s property by its name. Just follow these steps:
- Load the diagram file.
- Access a page.
- Find the shape by name.
- Use
Props
to read the properties.
Here is the Java code example that demonstrates how to read a shape’s property by using its name:
Read InheritProps of Shape in Java
You can also get inherited shape properties by following the steps below:
- Open the Visio file.
- Get a page and loop through shapes.
- Use
InheritProps
to read inherited values.
The following sample Java code shows how to read InheritProps of Visio shapes in Java:
Get a Free License
Do you want to try Aspose.Diagram without limits? You can get a free temporary license and test the full features of the library.
Open and Read Visio Shape: Free Resources
Explore these free resources to learn more:
Conclusion
In this article, you learned how to read Visio shape data in Java using Aspose.Diagram. You saw how to load files, extract shape properties, and read inherited data. With this powerful API, you can build Java apps that process Visio files with ease.
If you need help, feel free to reach out via our free support forum.