Class WriterProperties
public class WriterProperties
- Inheritance
-
WriterProperties
- Inherited Members
Constructors
WriterProperties()
public WriterProperties()
Fields
addUAXmpMetadata
protected bool addUAXmpMetadata
Field Value
addXmpMetadata
protected bool addXmpMetadata
Field Value
compressionLevel
protected int compressionLevel
Field Value
encryptionProperties
protected EncryptionProperties encryptionProperties
Field Value
initialDocumentId
The ID entry that represents the initial identifier.
protected PdfString initialDocumentId
Field Value
isFullCompression
Indicates if to use full compression (using object streams).
protected bool? isFullCompression
Field Value
- bool?
modifiedDocumentId
The ID entry that represents a change in a document.
protected PdfString modifiedDocumentId
Field Value
pdfVersion
protected PdfVersion pdfVersion
Field Value
smartMode
Indicates if the writer copy objects in a smart mode.
protected bool smartMode
Field Value
Remarks
Indicates if the writer copy objects in a smart mode. If so PdfDictionary and PdfStream will be hashed and reused if there's an object with the same content later.
Methods
AddUAXmpMetadata()
This method marks the document as PDF/UA and sets related flags is XMPMetaData.
public virtual WriterProperties AddUAXmpMetadata()
Returns
- WriterProperties
this WriterProperties instance
Remarks
This method marks the document as PDF/UA and sets related flags is XMPMetaData. This method calls AddXmpMetadata() implicitly. NOTE: iText does not validate PDF/UA, which means we don't check if created PDF meets all PDF/UA requirements. Don't use this method if you are not familiar with PDF/UA specification in order to avoid creation of non-conformant PDF/UA file.
AddXmpMetadata()
If true, default XMPMetadata based on PdfDocumentInfo will be added.
public virtual WriterProperties AddXmpMetadata()
Returns
- WriterProperties
this WriterProperties instance
Remarks
If true, default XMPMetadata based on PdfDocumentInfo will be added. For PDF 2.0 documents, metadata will be added in any case.
SetCompressionLevel(int)
Defines the level of compression for the document.
public virtual WriterProperties SetCompressionLevel(int compressionLevel)
Parameters
compressionLevel
intCompressionConstants value.
Returns
- WriterProperties
this WriterProperties instance
Remarks
Defines the level of compression for the document. See CompressionConstants
SetFullCompressionMode(bool)
Defines if full compression mode is enabled.
public virtual WriterProperties SetFullCompressionMode(bool fullCompressionMode)
Parameters
fullCompressionMode
booltrue - to enable full compression mode, false to disable it
Returns
- WriterProperties
this WriterProperties instance
Remarks
Defines if full compression mode is enabled. If enabled, not only the content of the pdf document will be compressed, but also the pdf document inner structure.
SetInitialDocumentId(PdfString)
The /ID entry of a document contains an array with two entries.
public virtual WriterProperties SetInitialDocumentId(PdfString initialDocumentId)
Parameters
initialDocumentId
PdfStringthe new initial document id
Returns
- WriterProperties
this WriterProperties instance
Remarks
The /ID entry of a document contains an array with two entries. The first one (initial id) represents the initial document id. It's a permanent identifier based on the contents of the file at the time it was originally created and does not change when the file is incrementally updated. To help ensure the uniqueness of file identifiers, it is recommend to be computed by means of a message digest algorithm such as MD5. iText will by default keep the existing initial id. But if you'd like you can set this id yourself using this setter.
SetModifiedDocumentId(PdfString)
The /ID entry of a document contains an array with two entries.
public virtual WriterProperties SetModifiedDocumentId(PdfString modifiedDocumentId)
Parameters
modifiedDocumentId
PdfStringthe new modified document id
Returns
- WriterProperties
this WriterProperties instance
Remarks
The /ID entry of a document contains an array with two entries. The second one (modified id) should be the same entry, unless the document has been modified. iText will by default generate a modified id. But if you'd like you can set this id yourself using this setter.
SetPdfVersion(PdfVersion)
Defines pdf version for the created document.
public virtual WriterProperties SetPdfVersion(PdfVersion version)
Parameters
version
PdfVersionversion for the document.
Returns
- WriterProperties
this WriterProperties instance
Remarks
Defines pdf version for the created document. Default value is PDF_1_7.
SetPublicKeyEncryption(IX509Certificate[], int[], int)
Sets the certificate encryption options for the document.
public virtual WriterProperties SetPublicKeyEncryption(IX509Certificate[] certs, int[] permissions, int encryptionAlgorithm)
Parameters
certs
IX509Certificate[]the public certificates to be used for the encryption
permissions
int[]the user permissions for each of the certificates The open permissions for the document can be ALLOW_PRINTING , ALLOW_MODIFY_CONTENTS , ALLOW_COPY , ALLOW_MODIFY_ANNOTATIONS , ALLOW_FILL_IN , ALLOW_SCREENREADERS , ALLOW_ASSEMBLY and ALLOW_DEGRADED_PRINTING. The permissions can be combined by ORing them
encryptionAlgorithm
intthe type of encryption. It can be one of STANDARD_ENCRYPTION_40 , STANDARD_ENCRYPTION_128 , ENCRYPTION_AES_128 or ENCRYPTION_AES_256. Optionally DO_NOT_ENCRYPT_METADATA can be ORed to output the metadata in cleartext. EMBEDDED_FILES_ONLY can be ORed as well. Please be aware that the passed encryption types may override permissions: STANDARD_ENCRYPTION_40 implicitly sets DO_NOT_ENCRYPT_METADATA and EMBEDDED_FILES_ONLY as false; STANDARD_ENCRYPTION_128 implicitly sets EMBEDDED_FILES_ONLY as false;
Returns
- WriterProperties
this WriterProperties instance
Remarks
Sets the certificate encryption options for the document. An array of one or more public certificates must be provided together with an array of the same size for the permissions for each certificate.
SetStandardEncryption(byte[], byte[], int, int)
Sets the encryption options for the document.
public virtual WriterProperties SetStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm)
Parameters
userPassword
byte[]the user password. Can be null or of zero length, which is equal to omitting the user password
ownerPassword
byte[]the owner password. If it's null or empty, iText will generate a random string to be used as the owner password
permissions
intthe user permissions The open permissions for the document can be ALLOW_PRINTING , ALLOW_MODIFY_CONTENTS , ALLOW_COPY , ALLOW_MODIFY_ANNOTATIONS , ALLOW_FILL_IN , ALLOW_SCREENREADERS , ALLOW_ASSEMBLY and ALLOW_DEGRADED_PRINTING. The permissions can be combined by ORing them
encryptionAlgorithm
intthe type of encryption. It can be one of STANDARD_ENCRYPTION_40 , STANDARD_ENCRYPTION_128 , ENCRYPTION_AES_128 or ENCRYPTION_AES_256. Optionally DO_NOT_ENCRYPT_METADATA can be ORed to output the metadata in cleartext. EMBEDDED_FILES_ONLY can be ORed as well. Please be aware that the passed encryption types may override permissions: STANDARD_ENCRYPTION_40 implicitly sets DO_NOT_ENCRYPT_METADATA and EMBEDDED_FILES_ONLY as false; STANDARD_ENCRYPTION_128 implicitly sets EMBEDDED_FILES_ONLY as false;
Returns
- WriterProperties
this WriterProperties instance
UseSmartMode()
Enables smart mode.
public virtual WriterProperties UseSmartMode()
Returns
- WriterProperties
this WriterProperties instance
Remarks
Enables smart mode.
In smart mode when resources (such as fonts, images,...) are
encountered, a reference to these resources is saved
in a cache, so that they can be reused.
This requires more memory, but reduces the file size
of the resulting PDF document.