Lock unlock shapes in PowerPoint PPT in Java

This article provides you with a comprehensive guide to lock shapes in PowerPoint PPT in Java. Thus, enabling you to protect the content of your PowerPoint presentations. Locking shapes could be useful for various reasons including prevention from accidental changes, protection of brand identity, maintaining layout integrity, and so on. So let’s proceed and see how to lock or unlock shapes in a presentation in Java.

Java Library to Lock Shapes in PowerPoint PPT

To lock and unlock PowerPoint presentations, we will use Aspose.Slides for Java. It is a feature-rich Java library to create and manipulate presentation documents. You can either download the library or install it using the following dependency in pom.xml.

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>23.7</version>
    <classifier>jdk16</classifier>
</dependency>

Lock Shapes in PowerPoint PPT in Java

PowerPoint presentations are composed of a variety of elements such as text, images, audio, etc. Aspose.Slides for Java takes each element as a Shape or an abject derived from Shape. So if you lock all the shapes in a presentation, you can protect PPT from being modified.

Aspose.Slides for Java classifies PowerPoint shapes into the following types:

  • Auto Shape
  • Group Shape
  • Connector
  • Picture Frame
  • Graphical Objects

Let’s now have a look at how to lock shapes in a PowerPoint PPT in Java.

  • First, load the PPT/PPTX file using Presentation class.
  • Then, get slides in the presentation using Presentation.getSlides() method.
  • For each slide, access its shapes using ISlide.getShapes() method.
  • For each shape in the collection, perform the following steps:
    • Check the type of the shape.
    • Use appropriate lock according to the type of the shape.
  • Finally, save the presentation using Presentation.save(String, SaveFormat) method.

The following code sample shows how to lock shapes in a PowerPoint PPT using Java.

Unlock PowerPoint Shapes in Java

To unlock the locked shapes in a PowerPoint PPT, you only need to turn off the locks by setting their values to false. It is worth noting that the shapes that are locked using Aspose.Slides for Java can not be unlocked using any other library.

The following code sample shows how to unlock shapes in a PPTX file in Java.

Lock PPT Shapes for Free

Use Aspose.Slides for Java and lock PPT shapes without evaluation limitations by getting a free temporary license.

Online Tool to Lock PowerPoint Presentations

Use our free online tool to lock PowerPoint presentations. No need to register yourself or provide any other information.

Conclusion

In this article, you have learned how to lock shapes in a PowerPoint PPT in Java. Also, you have seen how to unlock the PPT shapes programmatically. You can easily use this shape locking mechanism to protect your PowerPoint presentations.

Apart from that, you can explore more about Aspose.Slides for Java by visiting the documentation. Also, you can post your queries to our forum.

See Also