We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug I am not able to password protect the pdf file, I just want owner password protected.
Here is the sample snippet of code that I wrote to password protect existing pdf file.
PDFBoxResourceLoader.init(context); AccessPermission permission = new AccessPermission(); permission.setCanExtractContent(false); permission.setCanModify(false); permission.setCanModifyAnnotations(false); permission.setCanPrint(true); permission.setReadOnly(); StandardProtectionPolicy spp = new StandardProtectionPolicy("password" , "" , permission); spp.setEncryptionKeyLength(128); spp.setPermissions(permission); BouncyCastleProvider provider = new BouncyCastleProvider(); Security.addProvider(provider); try { PDDocument pdfDoc = PDDocument.load(pdfFile); pdfDoc.protect(spp); pdfDoc.save(pdfFile); pdfDoc.close(); } catch (IOException e) { Log.e(Nimbus.TAG, "Exception while loading pdf file ", e); }
Not sure why the pdf is not getting encrypted, let me know if anything is wrong in the above code snippet. Any help is much appreciated.
Environment details:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Describe the bug
I am not able to password protect the pdf file, I just want owner password protected.
Here is the sample snippet of code that I wrote to password protect existing pdf file.
PDFBoxResourceLoader.init(context);
AccessPermission permission = new AccessPermission();
permission.setCanExtractContent(false);
permission.setCanModify(false);
permission.setCanModifyAnnotations(false);
permission.setCanPrint(true);
permission.setReadOnly();
StandardProtectionPolicy spp = new StandardProtectionPolicy("password" , "" , permission);
spp.setEncryptionKeyLength(128);
spp.setPermissions(permission);
BouncyCastleProvider provider = new BouncyCastleProvider();
Security.addProvider(provider);
try {
PDDocument pdfDoc = PDDocument.load(pdfFile);
pdfDoc.protect(spp);
pdfDoc.save(pdfFile);
pdfDoc.close();
} catch (IOException e) {
Log.e(Nimbus.TAG, "Exception while loading pdf file ", e);
}
Not sure why the pdf is not getting encrypted, let me know if anything is wrong in the above code snippet. Any help is much appreciated.
Environment details:
The text was updated successfully, but these errors were encountered: