Remove Password Protection from Microsoft Word , Excel Spreadsheets, Powerpoint Presentations and PDF files using Java
Last active
June 19, 2025 19:17
-
-
Save aspose-com-gists/0e5a45839a6a8a82a098aeead8c4e2f6 to your computer and use it in GitHub Desktop.
Remove Password Protection from Documents using Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Presentation pres = new Presentation("write-protected-presentation.pptx"); | |
| try { | |
| pres.getProtectionManager().removeWriteProtection(); | |
| pres.save("write-protection-removed.pptx", SaveFormat.Pptx); | |
| } finally { | |
| if (pres != null) pres.dispose(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LoadOptions lOp = new LoadOptions(); | |
| lOp.setPassword("321321"); | |
| Presentation pres = new Presentation("presntation.pptx", lOp); | |
| try { | |
| pres.getProtectionManager().removeEncryption(); | |
| pres.save("encryption-removed.pptx", SaveFormat.Pptx); | |
| } finally { | |
| if (pres != null) pres.dispose(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Workbook wkb = new Workbook("workbook.xlsx"); | |
| WorksheetCollection worksheets = wkb.getWorksheets(); | |
| Worksheet wks = worksheets.get(0); | |
| wks.unprotect("12345"); | |
| wkb.save("workbook_updated.xlsx"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Document pdfDoc = new Document(_dataDir + "Decrypt.pdf", "password"); | |
| pdfDoc.decrypt(); | |
| pdfDoc.save(_dataDir + "password-removed.pdf"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Document doc = new Document("password-protected-file.docx"); | |
| doc.unprotect(); | |
| doc.save("password-removed.docx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment