Class Signer
- java.lang.Object
-
- com.pdftools.internal.NativeBase
-
- com.pdftools.internal.NativeObject
-
- com.pdftools.sign.Signer
-
public class Signer extends NativeObject
Process signatures and signature fields
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSigner.WarningEvent for non-critical errors occurring during signature processingstatic interfaceSigner.WarningListenerListener interface for theSigner.Warningevent.
-
Constructor Summary
Constructors Constructor Description Signer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PreparedDocumentaddPreparedSignature(Document document, SignatureConfiguration configuration, Stream stream)Add a prepared signaturePreparedDocumentaddPreparedSignature(Document document, SignatureConfiguration configuration, Stream stream, OutputOptions outputOptions)Add a prepared signatureDocumentaddSignatureField(Document document, SignatureFieldOptions options, Stream stream)Add an unsigned signature fieldDocumentaddSignatureField(Document document, SignatureFieldOptions options, Stream stream, OutputOptions outputOptions)Add an unsigned signature fieldDocumentaddTimestamp(Document document, TimestampConfiguration configuration, Stream stream)Add a document time-stampDocumentaddTimestamp(Document document, TimestampConfiguration configuration, Stream stream, OutputOptions outputOptions)Add a document time-stampvoidaddWarningListener(Signer.WarningListener listener)Add a listener for theSigner.Warningevent.Documentcertify(Document document, SignatureConfiguration configuration, Stream stream)Add a document certification signatureDocumentcertify(Document document, SignatureConfiguration configuration, Stream stream, MdpPermissionOptions permissions)Add a document certification signatureDocumentcertify(Document document, SignatureConfiguration configuration, Stream stream, MdpPermissionOptions permissions, OutputOptions outputOptions)Add a document certification signatureDocumentprocess(Document document, Stream stream)Process a documentDocumentprocess(Document document, Stream stream, OutputOptions outputOptions)Process a documentDocumentprocess(Document document, Stream stream, OutputOptions outputOptions, Provider provider)Process a documentvoidremoveWarningListener(Signer.WarningListener listener)Remove registered listener for theSigner.Warningevent.Documentsign(Document document, SignatureConfiguration configuration, Stream stream)Add a document signatureDocumentsign(Document document, SignatureConfiguration configuration, Stream stream, OutputOptions outputOptions)Add a document signatureDocumentsignPreparedSignature(Document document, SignatureConfiguration configuration, Stream stream)Sign a prepared signature-
Methods inherited from class com.pdftools.internal.NativeObject
equals, hashCode
-
-
-
-
Method Detail
-
addWarningListener
public void addWarningListener(Signer.WarningListener listener)
Add a listener for theSigner.Warningevent.- Parameters:
listener- Listener for theSigner.Warningevent. If a listener is added that is already registered, it is ignored.
-
removeWarningListener
public void removeWarningListener(Signer.WarningListener listener)
Remove registered listener for theSigner.Warningevent.- Parameters:
listener- Listener for theSigner.Warningevent that should be removed. If the listener is not registered, it is ignored.
-
sign
public Document sign(Document document, SignatureConfiguration configuration, Stream stream) throws java.io.IOException, NotFoundException, LicenseException, UnsupportedFeatureException, PermissionException, HttpException, RetryException
Add a document signature
Document signatures are sometimes also called approval signatures. This type of signature lets you verify the integrity of the signed part of the document and authenticate the signer’s identity.
The features and format of the signature are defined by the
pdftools.crypto.providers.Providerand theconfiguration.Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to signconfiguration- The signature configurationstream- The stream where the signed document is written- Returns:
- The signed document
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because the creating provider has been closed.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because it has been revoked.NotFoundException- If theSignatureConfiguration.getFieldName()does not exist indocument.NotFoundException- If an image, a PDF or a font file for the visual appearance could not be found.RetryException- If an unexpected error occurs that can be resolved by retrying the operation. For example, if a signature service returns an unexpectedly large signature.RetryException- If a resource required by the cryptographic provider is temporarily unavailable.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL) or a time-stamp.UnsupportedFeatureException- If the cryptographic provider does not support the requested signing algorithm.PermissionException- If the cryptographic provider does not allow the signing operation.java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifconfigurationisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
sign
public Document sign(Document document, SignatureConfiguration configuration, Stream stream, OutputOptions outputOptions) throws java.io.IOException, NotFoundException, LicenseException, UnsupportedFeatureException, PermissionException, HttpException, RetryException
Add a document signature
Document signatures are sometimes also called approval signatures. This type of signature lets you verify the integrity of the signed part of the document and authenticate the signer’s identity.
The features and format of the signature are defined by the
pdftools.crypto.providers.Providerand theconfiguration.Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to signconfiguration- The signature configurationstream- The stream where the signed document is writtenoutputOptions- Document-level output options not directly related to the signature- Returns:
- The signed document
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because the creating provider has been closed.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because it has been revoked.NotFoundException- If theSignatureConfiguration.getFieldName()does not exist indocument.NotFoundException- If an image, a PDF or a font file for the visual appearance could not be found.RetryException- If an unexpected error occurs that can be resolved by retrying the operation. For example, if a signature service returns an unexpectedly large signature.RetryException- If a resource required by the cryptographic provider is temporarily unavailable.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL) or a time-stamp.UnsupportedFeatureException- If the cryptographic provider does not support the requested signing algorithm.PermissionException- If the cryptographic provider does not allow the signing operation.java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifconfigurationisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
certify
public Document certify(Document document, SignatureConfiguration configuration, Stream stream) throws java.io.IOException, NotFoundException, LicenseException, UnsupportedFeatureException, PermissionException, HttpException, RetryException
Add a document certification signature
This type of signature lets you detect rejected changes specified by the author. These signatures are also called Modification Detection and Prevention (MDP) signatures. The allowed permissions are defined by
permissions.The features and format of the signature are defined by the
pdftools.crypto.providers.Providerand theconfiguration.Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to certifyconfiguration- The signature configurationstream- The stream where the certified document is written- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because the creating provider has been closed.NotFoundException- If theSignatureConfiguration.getFieldName()does not exist indocument.RetryException- If an unexpected error occurs that can be resolved by retrying the operation. For example, if a signature service returns an unexpectedly large signature.RetryException- If a resource required by the cryptographic provider is temporarily unavailable.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL) or a time-stamp.UnsupportedFeatureException- If the cryptographic provider does not support the requested signing algorithm.PermissionException- If the cryptographic provider does not allow the signing operation.java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifconfigurationisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
certify
public Document certify(Document document, SignatureConfiguration configuration, Stream stream, MdpPermissionOptions permissions) throws java.io.IOException, NotFoundException, LicenseException, UnsupportedFeatureException, PermissionException, HttpException, RetryException
Add a document certification signature
This type of signature lets you detect rejected changes specified by the author. These signatures are also called Modification Detection and Prevention (MDP) signatures. The allowed permissions are defined by
permissions.The features and format of the signature are defined by the
pdftools.crypto.providers.Providerand theconfiguration.Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to certifyconfiguration- The signature configurationstream- The stream where the certified document is writtenpermissions- The permissions allowed. The default ispdftools.pdf.MdpPermissions.NO_CHANGES.- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because the creating provider has been closed.NotFoundException- If theSignatureConfiguration.getFieldName()does not exist indocument.RetryException- If an unexpected error occurs that can be resolved by retrying the operation. For example, if a signature service returns an unexpectedly large signature.RetryException- If a resource required by the cryptographic provider is temporarily unavailable.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL) or a time-stamp.UnsupportedFeatureException- If the cryptographic provider does not support the requested signing algorithm.PermissionException- If the cryptographic provider does not allow the signing operation.java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifconfigurationisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
certify
public Document certify(Document document, SignatureConfiguration configuration, Stream stream, MdpPermissionOptions permissions, OutputOptions outputOptions) throws java.io.IOException, NotFoundException, LicenseException, UnsupportedFeatureException, PermissionException, HttpException, RetryException
Add a document certification signature
This type of signature lets you detect rejected changes specified by the author. These signatures are also called Modification Detection and Prevention (MDP) signatures. The allowed permissions are defined by
permissions.The features and format of the signature are defined by the
pdftools.crypto.providers.Providerand theconfiguration.Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to certifyconfiguration- The signature configurationstream- The stream where the certified document is writtenpermissions- The permissions allowed. The default ispdftools.pdf.MdpPermissions.NO_CHANGES.outputOptions- Document-level output options not directly related to the document certification- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because the creating provider has been closed.NotFoundException- If theSignatureConfiguration.getFieldName()does not exist indocument.RetryException- If an unexpected error occurs that can be resolved by retrying the operation. For example, if a signature service returns an unexpectedly large signature.RetryException- If a resource required by the cryptographic provider is temporarily unavailable.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL) or a time-stamp.UnsupportedFeatureException- If the cryptographic provider does not support the requested signing algorithm.PermissionException- If the cryptographic provider does not allow the signing operation.java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifconfigurationisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
addTimestamp
public Document addTimestamp(Document document, TimestampConfiguration configuration, Stream stream) throws java.io.IOException, NotFoundException, LicenseException, UnsupportedFeatureException, PermissionException, HttpException, RetryException
Add a document time-stamp
This type of signature provides evidence that the document existed at a specific time and protects the document’s integrity.
The features and format of the signature are defined by the
pdftools.crypto.providers.Providerand theconfiguration.Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to add a time-stamp toconfiguration- The time-stamp configurationstream- The stream where the output document is written- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because the creating provider has been closed.NotFoundException- If theSignatureConfiguration.getFieldName()does not exist indocument.RetryException- If an unexpected error occurs that can be resolved by retrying the operation. For example, if a signature service returns an unexpectedly large signature.RetryException- If a resource required by the cryptographic provider is temporarily unavailable.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL) or a time-stamp.UnsupportedFeatureException- If the cryptographic provider does not support the requested signing algorithm.PermissionException- If the cryptographic provider does not allow the signing operation.java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifconfigurationisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
addTimestamp
public Document addTimestamp(Document document, TimestampConfiguration configuration, Stream stream, OutputOptions outputOptions) throws java.io.IOException, NotFoundException, LicenseException, UnsupportedFeatureException, PermissionException, HttpException, RetryException
Add a document time-stamp
This type of signature provides evidence that the document existed at a specific time and protects the document’s integrity.
The features and format of the signature are defined by the
pdftools.crypto.providers.Providerand theconfiguration.Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to add a time-stamp toconfiguration- The time-stamp configurationstream- The stream where the output document is writtenoutputOptions- Document-level output options not directly related to the document time-stamp- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because the creating provider has been closed.NotFoundException- If theSignatureConfiguration.getFieldName()does not exist indocument.RetryException- If an unexpected error occurs that can be resolved by retrying the operation. For example, if a signature service returns an unexpectedly large signature.RetryException- If a resource required by the cryptographic provider is temporarily unavailable.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL) or a time-stamp.UnsupportedFeatureException- If the cryptographic provider does not support the requested signing algorithm.PermissionException- If the cryptographic provider does not allow the signing operation.java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifconfigurationisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
addSignatureField
public Document addSignatureField(Document document, SignatureFieldOptions options, Stream stream) throws java.io.IOException, LicenseException, UnsupportedFeatureException, ExistsException
Add an unsigned signature field
Add an unsigned signature field that can later be signed (see
pdftools.pdf.UnsignedSignatureField).Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to add the signature field tooptions- The options for the unsigned signature fieldstream- The stream where the output document is written- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.ExistsException- TheSignatureFieldOptions.getFieldName()exists already in the input document.java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifoptionsisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
addSignatureField
public Document addSignatureField(Document document, SignatureFieldOptions options, Stream stream, OutputOptions outputOptions) throws java.io.IOException, LicenseException, UnsupportedFeatureException, ExistsException
Add an unsigned signature field
Add an unsigned signature field that can later be signed (see
pdftools.pdf.UnsignedSignatureField).Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to add the signature field tooptions- The options for the unsigned signature fieldstream- The stream where the output document is writtenoutputOptions- Document-level output options not directly related to the signature field- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.ExistsException- TheSignatureFieldOptions.getFieldName()exists already in the input document.java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifoptionsisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
addPreparedSignature
public PreparedDocument addPreparedSignature(Document document, SignatureConfiguration configuration, Stream stream) throws java.io.IOException, NotFoundException, LicenseException, UnsupportedFeatureException, HttpException
Add a prepared signature
Adding a prepared signature is only required in very particular or specialized use cases. This method is the same as
sign(com.pdftools.pdf.Document, com.pdftools.sign.SignatureConfiguration, com.pdftools.sys.Stream), but without actually creating the cryptographic signature. The cryptographic signature can be inserted later usingsignPreparedSignature(com.pdftools.pdf.Document, com.pdftools.sign.SignatureConfiguration, com.pdftools.sys.Stream).While the
configurationcan be created by anypdftools.crypto.providers.Provider, it is typically created bypdftools.crypto.providers.builtin.Provider.createPreparedSignature.- Parameters:
document- The input document to add the prepared signatureconfiguration- The signature configurationstream- The stream where the output document is written- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because the creating provider has been closedNotFoundException- If theSignatureConfiguration.getFieldName()does not exist indocument.UnsupportedFeatureException- If the cryptographic provider does not support the requested signing algorithm.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL).java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifconfigurationisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
addPreparedSignature
public PreparedDocument addPreparedSignature(Document document, SignatureConfiguration configuration, Stream stream, OutputOptions outputOptions) throws java.io.IOException, NotFoundException, LicenseException, UnsupportedFeatureException, HttpException
Add a prepared signature
Adding a prepared signature is only required in very particular or specialized use cases. This method is the same as
sign(com.pdftools.pdf.Document, com.pdftools.sign.SignatureConfiguration, com.pdftools.sys.Stream), but without actually creating the cryptographic signature. The cryptographic signature can be inserted later usingsignPreparedSignature(com.pdftools.pdf.Document, com.pdftools.sign.SignatureConfiguration, com.pdftools.sys.Stream).While the
configurationcan be created by anypdftools.crypto.providers.Provider, it is typically created bypdftools.crypto.providers.builtin.Provider.createPreparedSignature.- Parameters:
document- The input document to add the prepared signatureconfiguration- The signature configurationstream- The stream where the output document is writtenoutputOptions- Document-level output options not directly related to preparing the signature- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because the creating provider has been closedNotFoundException- If theSignatureConfiguration.getFieldName()does not exist indocument.UnsupportedFeatureException- If the cryptographic provider does not support the requested signing algorithm.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL).java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifconfigurationisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
signPreparedSignature
public Document signPreparedSignature(Document document, SignatureConfiguration configuration, Stream stream) throws java.io.IOException, LicenseException, UnsupportedFeatureException, PermissionException, HttpException, RetryException
Sign a prepared signature
Sign a document that contains a prepared signature created usingaddPreparedSignature(com.pdftools.pdf.Document, com.pdftools.sign.SignatureConfiguration, com.pdftools.sys.Stream). Note that theconfigurationmust be compatible to the configuration used when preparing the signature.- Parameters:
document- The input document to signconfiguration- The signature configurationstream- The stream where the signed document is written- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.java.lang.IllegalArgumentException- If thedocumentdoes not contain a prepared signature created byaddPreparedSignature(com.pdftools.pdf.Document, com.pdftools.sign.SignatureConfiguration, com.pdftools.sys.Stream)java.lang.IllegalArgumentException- If theconfigurationis invalid, e.g. because the creating provider has been closed.RetryException- If an unexpected error occurs that can be resolved by retrying the operation. For example, if a signature service returns an unexpectedly large signature.RetryException- If a resource required by the cryptographic provider is temporarily unavailable.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL) or a time-stamp.UnsupportedFeatureException- If the cryptographic provider does not support the requested signing algorithm.PermissionException- If the cryptographic provider does not allow the signing operation.java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifconfigurationisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
process
public Document process(Document document, Stream stream) throws java.io.IOException, LicenseException, UnsupportedFeatureException, HttpException
Process a document
Apply document-level processing options without any signature operation. For example:
- To encrypt or decrypt PDF documents that may be signed (see the samples "Encrypt" and "Decrypt").
-
To remove signatures and unsigned signature fields (see
OutputOptions.getRemoveSignatures()). -
To add validation information to existing signatures (see
OutputOptions.getAddValidationInformation()).
Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to processstream- The stream where the output document is written- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL).java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
process
public Document process(Document document, Stream stream, OutputOptions outputOptions) throws java.io.IOException, LicenseException, UnsupportedFeatureException, HttpException
Process a document
Apply document-level processing options without any signature operation. For example:
- To encrypt or decrypt PDF documents that may be signed (see the samples "Encrypt" and "Decrypt").
-
To remove signatures and unsigned signature fields (see
OutputOptions.getRemoveSignatures()). -
To add validation information to existing signatures (see
OutputOptions.getAddValidationInformation()).
Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to processstream- The stream where the output document is writtenoutputOptions- The document-level processing options- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL).java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
process
public Document process(Document document, Stream stream, OutputOptions outputOptions, Provider provider) throws java.io.IOException, LicenseException, UnsupportedFeatureException, HttpException
Process a document
Apply document-level processing options without any signature operation. For example:
- To encrypt or decrypt PDF documents that may be signed (see the samples "Encrypt" and "Decrypt").
-
To remove signatures and unsigned signature fields (see
OutputOptions.getRemoveSignatures()). -
To add validation information to existing signatures (see
OutputOptions.getAddValidationInformation()).
Non-critical processing errors raise a
Signer.WarningListener. It is recommended to review theWarningCategoryand handle them if necessary for the application.- Parameters:
document- The input document to processstream- The stream where the output document is writtenoutputOptions- The document-level processing optionsprovider- The cryptographic provider to use to add validation information to existing signatures of input document (seeOutputOptions.getAddValidationInformation()). Can benullif no validation information is added or to use the default provider.- Returns:
- Throws:
LicenseException- The license check has failed.java.io.IOException- Writing to thestreamfailed.UnsupportedFeatureException- The input PDF contains unrendered XFA form fields. Seepdftools.pdf.Document.getXfafor more information on how to detect and handle XFA documents.HttpException- If a network error occurs, e.g. downloading revocation information (OCSP, CRL).java.lang.IllegalArgumentException- ifdocumentisnulljava.lang.IllegalArgumentException- ifstreamisnull
-
-