public class PdfEncryptionAlgorithm
Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Hello world!");
PdfEncryptionDetails encryptionDetails =
new PdfEncryptionDetails("password", "", PdfEncryptionAlgorithm.RC_4_128);
// Start by disallowing all permissions.
encryptionDetails.setPermissions(PdfPermissions.DISALLOW_ALL);
// Extend permissions to allow the editing of annotations.
encryptionDetails.setPermissions(PdfPermissions.MODIFY_ANNOTATIONS | PdfPermissions.DOCUMENT_ASSEMBLY);
// Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
// to modify how that method converts the document to .PDF.
PdfSaveOptions saveOptions = new PdfSaveOptions();
// Enable encryption via the "EncryptionDetails" property.
saveOptions.setEncryptionDetails(encryptionDetails);
// When we open this document, we will need to provide the password before accessing its contents.
doc.save(getArtifactsDir() + "PdfSaveOptions.EncryptionPermissions.pdf", saveOptions);
Field Summary | ||
---|---|---|
static final int | RC_4_40 | |
RC4 encryption, key length of 40 bits.
|
||
static final int | RC_4_128 | |
RC4 encryption, key length of 128 bits.
|