This gist contains code snippets related to Encryption and Decryption of PDF files using Aspose.PDF Cloud SDK for Java. For more information, please visit
Last active
June 6, 2021 07:32
-
-
Save aspose-cloud/7d2346be5e4914a1f854cfcbc4ff158b to your computer and use it in GitHub Desktop.
This Gist contains code snippets regarding Encrypting or Decrypting the PDF files using Aspose.PDF Cloud SDK for Java
This file contains 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
This Gist contains code snippets regarding Encrypting or Decrypting the PDF files using Aspose.PDF Cloud SDK for Java |
This file contains 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
// Get ClientID and ClientSecret from https://dashboard.aspose.cloud/ | |
String clientId = "a41d01ef-dfd5-4e02-ad29-bd85fe41e3e4"; | |
String clientSecret = "d87269aade6a46cdc295b711e26809af"; | |
// createPdfApi instance | |
PdfApi pdfApi = new PdfApi(clientSecret,clientId); | |
// input PDF document | |
String name = "PdfWithTable.pdf"; | |
// Load the file from local system | |
File file = new File("/Users/nayyershahbaz/Downloads/" + name); | |
// upload the file to cloud storage | |
FilesUploadResult uploadResponse = pdfApi.uploadFile(name, file, null); | |
// base64 encoded user and owner passwords | |
String userPasswordBase64encoded = "dXNlciAkXlBhc3N3b3JkISY="; //user $^Password!& | |
// call API to Decrypt PDF | |
AsposeResponse response = pdfApi.postDecryptDocumentInStorage(name, userPasswordBase64encoded, null,null); | |
// Print API response in console | |
System.out.println(response); |
This file contains 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
// Get ClientID and ClientSecret from https://dashboard.aspose.cloud/ | |
String clientId = "a41d01ef-dfd5-4e02-ad29-bd85fe41e3e4"; | |
String clientSecret = "d87269aade6a46cdc295b711e26809af"; | |
// createPdfApi instance | |
PdfApi pdfApi = new PdfApi(clientSecret,clientId); | |
// input PDF document | |
String name = "PdfWithTable.pdf"; | |
// Load the file from local system | |
File file = new File("/Users/nayyershahbaz/Downloads/" + name); | |
// upload the file to cloud storage | |
FilesUploadResult uploadResponse = pdfApi.uploadFile(name, file, null); | |
// base64 encoded user and owner passwords | |
String userPasswordBase64encoded = "dXNlciAkXlBhc3N3b3JkISY="; //user $^Password!& | |
String ownerPasswordBase64encoded = "b3duZXJcLy8/ICQxMl5QYXNzd29yZCEm"; //owner\//? $12^Password!& | |
// call API to encrypt PDF | |
AsposeResponse response = pdfApi.postEncryptDocumentInStorage(name, userPasswordBase64encoded, ownerPasswordBase64encoded, | |
CryptoAlgorithm.AESX128.getValue(), null, null, null, null); | |
// Print API response in console | |
System.out.println(response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment