public class PdfEncryptor
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
private |
PdfEncryptor() |
Modifier and Type | Method and Description |
---|---|
static void |
encrypt(PdfReader reader,
java.io.OutputStream os,
boolean strength,
java.lang.String userPassword,
java.lang.String ownerPassword,
int permissions)
Entry point to encrypt a PDF document.
|
static void |
encrypt(PdfReader reader,
java.io.OutputStream os,
boolean strength,
java.lang.String userPassword,
java.lang.String ownerPassword,
int permissions,
java.util.HashMap newInfo)
Entry point to encrypt a PDF document.
|
static void |
encrypt(PdfReader reader,
java.io.OutputStream os,
byte[] userPassword,
byte[] ownerPassword,
int permissions,
boolean strength128Bits)
Entry point to encrypt a PDF document.
|
static void |
encrypt(PdfReader reader,
java.io.OutputStream os,
byte[] userPassword,
byte[] ownerPassword,
int permissions,
boolean strength128Bits,
java.util.HashMap newInfo)
Entry point to encrypt a PDF document.
|
static java.lang.String |
getPermissionsVerbose(int permissions)
Give you a verbose analysis of the permissions.
|
public static void encrypt(PdfReader reader, java.io.OutputStream os, byte[] userPassword, byte[] ownerPassword, int permissions, boolean strength128Bits) throws DocumentException, java.io.IOException
PdfWriter
. The userPassword and the
ownerPassword can be null or have zero length. In this case the ownerPassword
is replaced by a random string. The open permissions for the document can be
AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
The permissions can be combined by ORing them.reader
- the read PDFos
- the output destinationuserPassword
- the user password. Can be null or emptyownerPassword
- the owner password. Can be null or emptypermissions
- the user permissionsstrength128Bits
- true
for 128 bit key length, false
for 40 bit key lengthDocumentException
- on errorjava.io.IOException
- on errorpublic static void encrypt(PdfReader reader, java.io.OutputStream os, byte[] userPassword, byte[] ownerPassword, int permissions, boolean strength128Bits, java.util.HashMap newInfo) throws DocumentException, java.io.IOException
PdfWriter
. The userPassword and the
ownerPassword can be null or have zero length. In this case the ownerPassword
is replaced by a random string. The open permissions for the document can be
AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
The permissions can be combined by ORing them.reader
- the read PDFos
- the output destinationuserPassword
- the user password. Can be null or emptyownerPassword
- the owner password. Can be null or emptypermissions
- the user permissionsstrength128Bits
- true
for 128 bit key length, false
for 40 bit key lengthnewInfo
- an optional String
map to add or change
the info dictionary. Entries with null
values delete the key in the original info dictionaryDocumentException
- on errorjava.io.IOException
- on errorpublic static void encrypt(PdfReader reader, java.io.OutputStream os, boolean strength, java.lang.String userPassword, java.lang.String ownerPassword, int permissions) throws DocumentException, java.io.IOException
PdfWriter
. The userPassword and the
ownerPassword can be null or have zero length. In this case the ownerPassword
is replaced by a random string. The open permissions for the document can be
AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
The permissions can be combined by ORing them.reader
- the read PDFos
- the output destinationstrength
- true
for 128 bit key length, false
for 40 bit key lengthuserPassword
- the user password. Can be null or emptyownerPassword
- the owner password. Can be null or emptypermissions
- the user permissionsDocumentException
- on errorjava.io.IOException
- on errorpublic static void encrypt(PdfReader reader, java.io.OutputStream os, boolean strength, java.lang.String userPassword, java.lang.String ownerPassword, int permissions, java.util.HashMap newInfo) throws DocumentException, java.io.IOException
PdfWriter
. The userPassword and the
ownerPassword can be null or have zero length. In this case the ownerPassword
is replaced by a random string. The open permissions for the document can be
AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
The permissions can be combined by ORing them.reader
- the read PDFos
- the output destinationstrength
- true
for 128 bit key length, false
for 40 bit key lengthuserPassword
- the user password. Can be null or emptyownerPassword
- the owner password. Can be null or emptypermissions
- the user permissionsnewInfo
- an optional String
map to add or change
the info dictionary. Entries with null
values delete the key in the original info dictionaryDocumentException
- on errorjava.io.IOException
- on errorpublic static java.lang.String getPermissionsVerbose(int permissions)
permissions
- the permissions value of a PDF file