HiraokaHyperTools.iTextSharp-LGPL  0.2.5
iTextSharp.text.pdf.PdfEncryptor Class Reference

Static Public Member Functions

static void Encrypt (PdfReader reader, Stream os, byte[] userPassword, byte[] ownerPassword, int permissions, bool strength128Bits)
 
static void Encrypt (PdfReader reader, Stream os, byte[] userPassword, byte[] ownerPassword, int permissions, bool strength128Bits, Hashtable newInfo)
 
static void Encrypt (PdfReader reader, Stream os, bool strength, String userPassword, String ownerPassword, int permissions)
 
static void Encrypt (PdfReader reader, Stream os, bool strength, String userPassword, String ownerPassword, int permissions, Hashtable newInfo)
 
static void Encrypt (PdfReader reader, Stream os, int type, String userPassword, String ownerPassword, int permissions, Hashtable newInfo)
 
static void Encrypt (PdfReader reader, Stream os, int type, String userPassword, String ownerPassword, int permissions)
 
static String GetPermissionsVerbose (int permissions)
 
static bool IsPrintingAllowed (int permissions)
 
static bool IsModifyContentsAllowed (int permissions)
 
static bool IsCopyAllowed (int permissions)
 
static bool IsModifyAnnotationsAllowed (int permissions)
 
static bool IsFillInAllowed (int permissions)
 
static bool IsScreenReadersAllowed (int permissions)
 
static bool IsAssemblyAllowed (int permissions)
 
static bool IsDegradedPrintingAllowed (int permissions)
 

Detailed Description

This class takes any PDF and returns exactly the same but encrypted. All the content, links, outlines, etc, are kept. It is also possible to change the info dictionary.

Member Function Documentation

◆ Encrypt() [1/6]

static void iTextSharp.text.pdf.PdfEncryptor.Encrypt ( PdfReader  reader,
Stream  os,
bool  strength,
String  userPassword,
String  ownerPassword,
int  permissions 
)
static

Entry point to encrypt a PDF document. The encryption parameters are the same as in 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.

Parameters
readerthe read PDF
osthe output destination
strengthtrue for 128 bit key length, false for 40 bit key length
userPasswordthe user password. Can be null or empty
ownerPasswordthe owner password. Can be null or empty
permissionsthe user permissions
Exceptions
DocumentExceptionon error
IOExceptionon error

◆ Encrypt() [2/6]

static void iTextSharp.text.pdf.PdfEncryptor.Encrypt ( PdfReader  reader,
Stream  os,
bool  strength,
String  userPassword,
String  ownerPassword,
int  permissions,
Hashtable  newInfo 
)
static

Entry point to encrypt a PDF document. The encryption parameters are the same as in 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.

Parameters
readerthe read PDF
osthe output destination
strengthtrue for 128 bit key length, false for 40 bit key length
userPasswordthe user password. Can be null or empty
ownerPasswordthe owner password. Can be null or empty
permissionsthe user permissions
newInfoan optional String map to add or change the info dictionary. Entries with null values delete the key in the original info dictionary
Exceptions
DocumentExceptionon error
IOExceptionon error

◆ Encrypt() [3/6]

static void iTextSharp.text.pdf.PdfEncryptor.Encrypt ( PdfReader  reader,
Stream  os,
byte[]  userPassword,
byte[]  ownerPassword,
int  permissions,
bool  strength128Bits 
)
static

Entry point to encrypt a PDF document. The encryption parameters are the same as in 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.

Parameters
readerthe read PDF
osthe output destination
userPasswordthe user password. Can be null or empty
ownerPasswordthe owner password. Can be null or empty
permissionsthe user permissions
strength128Bitstrue for 128 bit key length, false for 40 bit key length
Exceptions
DocumentExceptionon error
IOExceptionon error

◆ Encrypt() [4/6]

static void iTextSharp.text.pdf.PdfEncryptor.Encrypt ( PdfReader  reader,
Stream  os,
byte[]  userPassword,
byte[]  ownerPassword,
int  permissions,
bool  strength128Bits,
Hashtable  newInfo 
)
static

Entry point to encrypt a PDF document. The encryption parameters are the same as in 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.

Parameters
readerthe read PDF
osthe output destination
userPasswordthe user password. Can be null or empty
ownerPasswordthe owner password. Can be null or empty
permissionsthe user permissions
strength128Bitstrue for 128 bit key length, false for 40 bit key length
newInfoan optional String map to add or change the info dictionary. Entries with null values delete the key in the original info dictionary
Exceptions
DocumentExceptionon error
IOExceptionon error

◆ Encrypt() [5/6]

static void iTextSharp.text.pdf.PdfEncryptor.Encrypt ( PdfReader  reader,
Stream  os,
int  type,
String  userPassword,
String  ownerPassword,
int  permissions 
)
static

Entry point to encrypt a PDF document. The encryption parameters are the same as in 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.

Parameters
readerthe read PDF
osthe output destination
typethe type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
userPasswordthe user password. Can be null or empty
ownerPasswordthe owner password. Can be null or empty
permissionsthe user permissions values delete the key in the original info dictionary
Exceptions
DocumentExceptionon error
IOExceptionon error

◆ Encrypt() [6/6]

static void iTextSharp.text.pdf.PdfEncryptor.Encrypt ( PdfReader  reader,
Stream  os,
int  type,
String  userPassword,
String  ownerPassword,
int  permissions,
Hashtable  newInfo 
)
static

Entry point to encrypt a PDF document. The encryption parameters are the same as in 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.

Parameters
readerthe read PDF
osthe output destination
typethe type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128. Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
userPasswordthe user password. Can be null or empty
ownerPasswordthe owner password. Can be null or empty
permissionsthe user permissions
newInfoan optional String map to add or change the info dictionary. Entries with null values delete the key in the original info dictionary
Exceptions
DocumentExceptionon error
IOExceptionon error

◆ GetPermissionsVerbose()

static String iTextSharp.text.pdf.PdfEncryptor.GetPermissionsVerbose ( int  permissions)
static

Give you a verbose analysis of the permissions.

Parameters
permissionsthe permissions value of a PDF file
Returns
a String that explains the meaning of the permissions value

◆ IsAssemblyAllowed()

static bool iTextSharp.text.pdf.PdfEncryptor.IsAssemblyAllowed ( int  permissions)
static

Tells you if document assembly is allowed.

Parameters
permissionsthe permissions value of a PDF file
Returns
true if document assembly is allowed
Since
2.0.7

◆ IsCopyAllowed()

static bool iTextSharp.text.pdf.PdfEncryptor.IsCopyAllowed ( int  permissions)
static

Tells you if copying is allowed.

Parameters
permissionsthe permissions value of a PDF file
Returns
true if copying is allowed
Since
2.0.7

◆ IsDegradedPrintingAllowed()

static bool iTextSharp.text.pdf.PdfEncryptor.IsDegradedPrintingAllowed ( int  permissions)
static

Tells you if degraded printing is allowed.

Parameters
permissionsthe permissions value of a PDF file
Returns
true if degraded printing is allowed
Since
2.0.7

◆ IsFillInAllowed()

static bool iTextSharp.text.pdf.PdfEncryptor.IsFillInAllowed ( int  permissions)
static

Tells you if filling in fields is allowed.

Parameters
permissionsthe permissions value of a PDF file
Returns
true if filling in fields is allowed
Since
2.0.7

◆ IsModifyAnnotationsAllowed()

static bool iTextSharp.text.pdf.PdfEncryptor.IsModifyAnnotationsAllowed ( int  permissions)
static

Tells you if modifying annotations is allowed.

Parameters
permissionsthe permissions value of a PDF file
Returns
true if modifying annotations is allowed
Since
2.0.7

◆ IsModifyContentsAllowed()

static bool iTextSharp.text.pdf.PdfEncryptor.IsModifyContentsAllowed ( int  permissions)
static

Tells you if modifying content is allowed.

Parameters
permissionsthe permissions value of a PDF file
Returns
true if modifying content is allowed
Since
2.0.7

◆ IsPrintingAllowed()

static bool iTextSharp.text.pdf.PdfEncryptor.IsPrintingAllowed ( int  permissions)
static

Tells you if printing is allowed.

Parameters
permissionsthe permissions value of a PDF file
Returns
true if printing is allowed
Since
2.0.7

◆ IsScreenReadersAllowed()

static bool iTextSharp.text.pdf.PdfEncryptor.IsScreenReadersAllowed ( int  permissions)
static

Tells you if repurposing for screenreaders is allowed.

Parameters
permissionsthe permissions value of a PDF file
Returns
true if repurposing for screenreaders is allowed
Since
2.0.7

The documentation for this class was generated from the following file: