Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created November 11, 2024 19:31
Show Gist options
  • Save conholdate-gists/f97d0cb86776761c3f9f1c207169564f to your computer and use it in GitHub Desktop.
Save conholdate-gists/f97d0cb86776761c3f9f1c207169564f to your computer and use it in GitHub Desktop.
Password Protect PowerPoint Presentation in Java
com.aspose.slides.Presentation presentation = new com.aspose.slides.Presentation("pres.pptx");
try {
presentation.getProtectionManager().encrypt("123123");
presentation.save("encrypted-pres.pptx", com.aspose.slides.SaveFormat.Pptx);
} finally {
if (presentation != null) presentation.dispose();
}
com.aspose.slides.Presentation pres = new com.aspose.slides.Presentation();
try {
pres.getProtectionManager().setReadOnlyRecommended(true);
pres.save(dataDir + "ReadOnlyPresentation.pptx", com.aspose.slides.SaveFormat.Pptx);
} finally {
if (pres != null) pres.dispose();
}
com.aspose.slides.Presentation presentation = new com.aspose.slides.Presentation();
try {
presentation.getProtectionManager().setWriteProtection("123123");
presentation.save(dataDir + "write-protected-pres.pptx", com.aspose.slides.SaveFormat.Pptx);
} finally {
if (presentation != null) presentation.dispose();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment