I noticed that in Aspose.pdf for .NET there is functionality for checking if the file has been password protected.
Hi Tammy,
Yes, this feature is available in all of Java APIs. Please check http://www.aspose.com/docs/display/pdfjava/How+to+-+determine+if+the+source+PDF+is+password+protected for PDF. You can use the following code for Words, Cells and Slides respectively.
For Words:
com.aspose.words.FileFormatInfo wordInfo = com.aspose.words.FileFormatUtil.detectFileFormat("PasswordProtected.docx");
boolean isWordFileProtected = wordInfo.isEncrypted();
System.out.println(isWordFileProtected);
For Cells
com.aspose.cells.FileFormatInfo excelInfo = com.aspose.cells.FileFormatUtil.detectFileFormat("PasswordProtected.xlsx");
boolean isExcelFileProtected = excelInfo.isEncrypted();
System.out.println(isExcelFileProtected);
For Slides
try{
PresentationEx pres = new PresentationEx("PasswordProtected.pptx");
} catch (com.aspose.slides.InvalidPasswordException e) {
// TODO Auto-generated catch block
System.out.println("Document is password protected");
}
Best Regards,
Thank you for the response. That was exactly what I was looking for.
Hi Tammy,
Yes, you are right. That code is outdated now. This feature is available in the latest versions and you can use the following code for Aspose.Slides.
IPresentationInfo info = null;
info =com.aspose.slides.PresentationFactory.getInstance().getPresentationInfo("PasswordProtected.pptx");
System.out.println(info.isEncrypted());
Best Regards,