Method from org.apache.pdfbox.pdmodel.encryption.PDEncryptionDictionary Detail: |
public COSDictionary getCOSDictionary() {
return encryptionDictionary;
}
This will get the dictionary associated with this encryption dictionary. |
public String getFilter() {
return encryptionDictionary.getNameAsString( COSName.FILTER );
}
Get the name of the filter. |
public int getLength() {
return encryptionDictionary.getInt( "Length", 40 );
}
This will return the Length entry of the encryption dictionary.
The length in bits for the encryption algorithm. This will return a multiple of 8. |
public byte[] getOwnerKey() throws IOException {
byte[] o = null;
COSString owner = (COSString)encryptionDictionary.getDictionaryObject( COSName.getPDFName( "O" ) );
if( owner != null )
{
o = owner.getBytes();
}
return o;
}
This will get the O entry in the standard encryption dictionary. |
public int getPermissions() {
return encryptionDictionary.getInt( "P", 0 );
}
This will get the permissions bit mask. |
public COSString getRecipientStringAt(int i) {
COSArray array = (COSArray)encryptionDictionary.getItem(COSName.getPDFName("Recipients"));
return (COSString)array.get(i);
}
returns the COSString contained in the Recipients field at position i. |
public int getRecipientsLength() {
COSArray array = (COSArray)encryptionDictionary.getItem(COSName.getPDFName("Recipients"));
return array.size();
}
Returns the number of recipients contained in the Recipients field of the dictionary. |
public int getRevision() {
return encryptionDictionary.getInt( "R", DEFAULT_VERSION );
}
This will return the R entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.14. |
public byte[] getUserKey() throws IOException {
byte[] u = null;
COSString user = (COSString)encryptionDictionary.getDictionaryObject( COSName.getPDFName( "U" ) );
if( user != null )
{
u = user.getBytes();
}
return u;
}
This will get the U entry in the standard encryption dictionary. |
public int getVersion() {
return encryptionDictionary.getInt( "V", 0 );
}
This will return the V entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.13. |
public void setFilter(String filter) {
encryptionDictionary.setItem( COSName.FILTER, COSName.getPDFName( filter ) );
}
Sets the filter entry of the encryption dictionary. |
public void setLength(int length) {
encryptionDictionary.setInt("Length", length);
}
This will set the number of bits to use for the encryption algorithm. |
public void setOwnerKey(byte[] o) throws IOException {
COSString owner = new COSString();
owner.append( o );
encryptionDictionary.setItem( COSName.getPDFName( "O" ), owner );
}
This will set the O entry in the standard encryption dictionary. |
public void setPermissions(int permissions) {
encryptionDictionary.setInt( "P", permissions );
}
This will set the permissions bit mask. |
public void setRecipients(byte[][] recipients) throws IOException {
COSArray array = new COSArray();
for(int i=0; i< recipients.length; i++)
{
COSString recip = new COSString();
recip.append(recipients[i]);
recip.setForceLiteralForm(true);
array.add(recip);
}
encryptionDictionary.setItem(COSName.getPDFName("Recipients"), array);
}
This will set the Recipients field of the dictionary. This field contains an array
of string. |
public void setRevision(int revision) {
encryptionDictionary.setInt( "R", revision );
}
This will set the R entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.14.
Note: This value is used to decrypt the pdf document. If you change this when
the document is encrypted then decryption will fail!. |
public void setSubFilter(String subfilter) {
encryptionDictionary.setName( "SubFilter", subfilter );
}
Set the subfilter entry of the encryption dictionary. |
public void setUserKey(byte[] u) throws IOException {
COSString user = new COSString();
user.append( u );
encryptionDictionary.setItem( COSName.getPDFName( "U" ), user );
}
This will set the U entry in the standard encryption dictionary. |
public void setVersion(int version) {
encryptionDictionary.setInt( "V", version );
}
This will set the V entry of the encryption dictionary.
See PDF Reference 1.4 Table 3.13.
Note: This value is used to decrypt the pdf document. If you change this when
the document is encrypted then decryption will fail!. |