Microsoft Visio files can contain different pages, shapes, layers, and other objects of diagrams. You can easily create, edit, or manipulate Microsoft Visio Diagram Files with Java. Likewise, you can protect or unprotect a Visio file or its shapes to avoid any changes to the data. Let us go through the following topics for further details:
- Protect or Unprotect Visio Diagram files and Shapes – Java API Installation
- Protect Visio Diagram File from Changes Programmatically using Java
- Unprotect Visio Diagram File using Java
- Protect Visio Shapes from Changes with Java
- Unprotect Visio Shapes in Java
Protect or Unprotect Visio Diagram files and Shapes – Java API Installation
Aspose.Diagram for Java API lets you work with Microsoft Visio-related formats like VSDX, VSDM, VSD, and several other file formats. You do not need to install any third-party application to work with these files. Furthermore, installing the API is simple as you can quickly download its JAR file from the Downloads section, or with the following details to install it from Aspose Repository:
<repositories> <repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>http://repository.aspose.com/repo/</url> </repository> </repositories>
<dependencies> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-diagram</artifactId> <version>21.2</version> <classifier>jdk16</classifier> </dependency> </dependencies>
Protect Visio Diagram File from Changes using Java
Microsoft Visio files like VSD, VSDX, VSTX, or, VDW can contain a lot of information about diagrams, processes, flow charts, and much more. A Visio diagram file may contain Background, Master, Shapes, Styles, etc. and you can protect these contents to avoid any changes. Please follow the following steps to protect a Visio Diagram file:
- Load input Visio file with Diagram class
- Protect Background, Shapes, Master shapes, and, Styles of Visio file.
- Save protected output diagram file.
The code below shows how to protect a Visio Diagram file using Java:
Unprotect Visio Diagram File with Java
Sometimes you might need to update a protected diagram file. First of all, you need to unprotect such files and then process them further. The below steps elaborate how to unprotect a Visio diagram:
- Load the protected input Visio diagram file.
- Unprotect Background, Shapes, Master shapes, and, Styles with DocumentSettings class.
- Finally, save unprotected output diagram file.
The following code elaborates how to unprotect a Visio Diagram File with Java:
Protect Visio Shapes from Changes using Java
Visio Diagrams consist of different shapes. that are combined to form a diagram or drawing. You can move, rotate, delete, or modify different shapes to achieve results. Furthermore, you can also avoid any changes to Visio shapes by restricting different properties of Shapes. Let us proceed and learn how to protect Visio shapes from any changes, with the steps below:
- Load input diagram.
- Get page by name.
- Get shape by ID.
- Set different shape protections.
- Save protected output Visio diagram.
The code snippet below explains how to protect Visio shapes from changes with Java:
Unprotect Visio Shapes with Java
You may need to unprotect Visio Diagram shapes for changing or updating its contents. The following steps show how to unprotect Visio shapes:
- Load input Visio diagram.
- Access page by name.
- Get shape by ID.
- Unprotect Visio shapes with Bool values.
- Finally, save output Visio diagram.
The code below shows how to unprotect Visio Diagram shapes with Java:
In this article, you have learned how to protect or unprotect Visio Diagram files. Likewise, you have read how to protect and unprotect shapes from changes using Java language. Moreover, you can find many other features of Aspose.Diagram for Java API by visiting the Documentation. In case of any concerns, please feel free to contact us via the Free Support Forum.