public class WriterProperties extends Object
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
addUAXmpMetadata |
protected boolean |
addXmpMetadata |
protected int |
compressionLevel |
protected EncryptionProperties |
encryptionProperties |
protected PdfString |
initialDocumentId
The ID entry that represents the initial identifier.
|
protected Boolean |
isFullCompression
Indicates if to use full compression (using object streams).
|
protected PdfString |
modifiedDocumentId
The ID entry that represents a change in a document.
|
protected PdfVersion |
pdfVersion |
protected boolean |
smartMode
Indicates if the writer copy objects in a smart mode.
|
| Constructor and Description |
|---|
WriterProperties() |
| Modifier and Type | Method and Description |
|---|---|
WriterProperties |
addUAXmpMetadata()
This method marks the document as PDF/UA and sets related flags is XMPMetaData.
|
WriterProperties |
addXmpMetadata()
If true, default XMPMetadata based on
PdfDocumentInfo will be added. |
WriterProperties |
setCompressionLevel(int compressionLevel)
Defines the level of compression for the document.
|
WriterProperties |
setFullCompressionMode(boolean fullCompressionMode)
Defines if full compression mode is enabled.
|
WriterProperties |
setInitialDocumentId(PdfString initialDocumentId)
The /ID entry of a document contains an array with two entries.
|
WriterProperties |
setModifiedDocumentId(PdfString modifiedDocumentId)
The /ID entry of a document contains an array with two entries.
|
WriterProperties |
setPdfVersion(PdfVersion version)
Defines pdf version for the created document.
|
WriterProperties |
setPublicKeyEncryption(Certificate[] certs,
int[] permissions,
int encryptionAlgorithm)
Sets the certificate encryption options for the document.
|
WriterProperties |
setStandardEncryption(byte[] userPassword,
byte[] ownerPassword,
int permissions,
int encryptionAlgorithm)
Sets the encryption options for the document.
|
WriterProperties |
useSmartMode()
Enables smart mode.
|
protected int compressionLevel
protected Boolean isFullCompression
protected boolean smartMode
protected boolean addXmpMetadata
protected boolean addUAXmpMetadata
protected PdfVersion pdfVersion
protected EncryptionProperties encryptionProperties
protected PdfString initialDocumentId
protected PdfString modifiedDocumentId
public WriterProperties setPdfVersion(PdfVersion version)
version - version for the document.WriterProperties instancepublic WriterProperties useSmartMode()
WriterProperties instancepublic WriterProperties addXmpMetadata()
PdfDocumentInfo will be added.
For PDF 2.0 documents, metadata will be added in any case.WriterProperties instancepublic WriterProperties setCompressionLevel(int compressionLevel)
CompressionConstantscompressionLevel - CompressionConstants value.WriterProperties instancepublic WriterProperties setFullCompressionMode(boolean fullCompressionMode)
fullCompressionMode - true - to enable full compression mode, false to disable itWriterProperties instancepublic WriterProperties setStandardEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionAlgorithm)
userPassword - the user password. Can be null or of zero length, which is equal to
omitting the user passwordownerPassword - the owner password. If it's null or empty, iText will generate
a random string to be used as the owner passwordpermissions - the user permissions
The open permissions for the document can be
EncryptionConstants.ALLOW_PRINTING,
EncryptionConstants.ALLOW_MODIFY_CONTENTS,
EncryptionConstants.ALLOW_COPY,
EncryptionConstants.ALLOW_MODIFY_ANNOTATIONS,
EncryptionConstants.ALLOW_FILL_IN,
EncryptionConstants.ALLOW_SCREENREADERS,
EncryptionConstants.ALLOW_ASSEMBLY and
EncryptionConstants.ALLOW_DEGRADED_PRINTING.
The permissions can be combined by ORing themencryptionAlgorithm - the type of encryption. It can be one of
EncryptionConstants.STANDARD_ENCRYPTION_40,
EncryptionConstants.STANDARD_ENCRYPTION_128,
EncryptionConstants.ENCRYPTION_AES_128
or EncryptionConstants.ENCRYPTION_AES_256.
Optionally EncryptionConstants.DO_NOT_ENCRYPT_METADATA can be ORed
to output the metadata in cleartext.
EncryptionConstants.EMBEDDED_FILES_ONLY can be ORed as well.
Please be aware that the passed encryption types may override permissions:
EncryptionConstants.STANDARD_ENCRYPTION_40 implicitly sets
EncryptionConstants.DO_NOT_ENCRYPT_METADATA and
EncryptionConstants.EMBEDDED_FILES_ONLY as false;
EncryptionConstants.STANDARD_ENCRYPTION_128 implicitly sets
EncryptionConstants.EMBEDDED_FILES_ONLY as false;WriterProperties instancepublic WriterProperties setPublicKeyEncryption(Certificate[] certs, int[] permissions, int encryptionAlgorithm)
certs - the public certificates to be used for the encryptionpermissions - the user permissions for each of the certificates
The open permissions for the document can be
EncryptionConstants.ALLOW_PRINTING,
EncryptionConstants.ALLOW_MODIFY_CONTENTS,
EncryptionConstants.ALLOW_COPY,
EncryptionConstants.ALLOW_MODIFY_ANNOTATIONS,
EncryptionConstants.ALLOW_FILL_IN,
EncryptionConstants.ALLOW_SCREENREADERS,
EncryptionConstants.ALLOW_ASSEMBLY and
EncryptionConstants.ALLOW_DEGRADED_PRINTING.
The permissions can be combined by ORing themencryptionAlgorithm - the type of encryption. It can be one of
EncryptionConstants.STANDARD_ENCRYPTION_40,
EncryptionConstants.STANDARD_ENCRYPTION_128,
EncryptionConstants.ENCRYPTION_AES_128
or EncryptionConstants.ENCRYPTION_AES_256.
Optionally EncryptionConstants.DO_NOT_ENCRYPT_METADATA can be ORed
to output the metadata in cleartext.
EncryptionConstants.EMBEDDED_FILES_ONLY can be ORed as well.
Please be aware that the passed encryption types may override permissions:
EncryptionConstants.STANDARD_ENCRYPTION_40 implicitly sets
EncryptionConstants.DO_NOT_ENCRYPT_METADATA and
EncryptionConstants.EMBEDDED_FILES_ONLY as false;
EncryptionConstants.STANDARD_ENCRYPTION_128 implicitly sets
EncryptionConstants.EMBEDDED_FILES_ONLY as false;WriterProperties instancepublic WriterProperties setInitialDocumentId(PdfString initialDocumentId)
initialDocumentId - the new initial document idWriterProperties instancepublic WriterProperties setModifiedDocumentId(PdfString modifiedDocumentId)
modifiedDocumentId - the new modified document idWriterProperties instancepublic WriterProperties addUAXmpMetadata()
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.WriterProperties instanceCopyright © 1998–2021 iText Group NV. All rights reserved.