Package eu.europa.esig.dss.pdf.openpdf
Class ITextPDFSignatureService
java.lang.Object
eu.europa.esig.dss.pdf.AbstractPDFSignatureService
eu.europa.esig.dss.pdf.openpdf.ITextPDFSignatureService
- All Implemented Interfaces:
PDFSignatureService
Implementation of PDFSignatureService using iText
-
Field Summary
Fields inherited from class eu.europa.esig.dss.pdf.AbstractPDFSignatureService
pdfDifferencesFinder, pdfObjectModificationsFinder, pdfPermissionsChecker, pdfSignatureFieldPositionChecker, resourcesHandlerBuilder
-
Constructor Summary
ConstructorDescriptionITextPDFSignatureService
(PDFServiceMode serviceMode, ITextSignatureDrawerFactory signatureDrawerFactory) Constructor for the ITextPDFSignatureService -
Method Summary
Modifier and TypeMethodDescriptionaddDssDictionary
(DSSDocument document, PdfValidationDataContainer validationDataForInclusion, char[] pwd, boolean includeVRIDict) This method adds the DSS dictionary (Baseline-LT) to a password-protected document with a VRI dictionary if defined.addNewSignatureField
(DSSDocument document, SignatureFieldParameters parameters, char[] pwd) This method allows to add a new signature field to an existing encrypted pdf documentprotected DSSMessageDigest
computeDigest
(DSSDocument toSignDocument, PAdESCommonParameters parameters) Computes digest on to be signed data computed on thetoSignDocument
respectively to the givenparameters
getAvailableSignatureFields
(DSSDocument document, char[] pwd) Returns not-signed signature fields from an encrypted documentprotected AnnotationBox
getVisibleSignatureFieldBoxPosition
(PdfDocumentReader reader, SignatureFieldParameters parameters) Checks if the signatureFieldBox overlaps with any existing annotations on the given page and returns the respectful signature field boxprotected AnnotationBox
getVisibleSignatureFieldBoxPosition
(SignatureDrawer signatureDrawer, PdfDocumentReader documentReader, SignatureFieldParameters parameters) Checks validity of the SignatureField position and returns the calculated signature field boxprotected List<PdfModification>
getVisualDifferences
(PdfDocumentReader signedRevisionReader, PdfDocumentReader finalRevisionReader) Returns a list of visual differences between the provided PDF and the signed contentprotected PdfDocumentReader
loadPdfDocumentReader
(DSSDocument dssDocument, char[] passwordProtection) LoadsPdfDocumentReader
instancepreviewPageWithVisualSignature
(DSSDocument toSignDocument, PAdESCommonParameters parameters) Returns a page preview with the visual signaturepreviewSignatureField
(DSSDocument toSignDocument, PAdESCommonParameters parameters) Returns a preview of the signature fieldprotected DSSDocument
signDocument
(DSSDocument toSignDocument, byte[] cmsSignedData, PAdESCommonParameters parameters) This method creates a signed document from the originaltoSignDocument
, incorporating a new revision, enveloping the providedcmsSignedData
Methods inherited from class eu.europa.esig.dss.pdf.AbstractPDFSignatureService
addDssDictionary, addDssDictionary, addDssDictionary, addNewSignatureField, addNewSignatureField, analyzePdfModifications, analyzePdfModifications, analyzePdfModifications, analyzeTimestampPdfModifications, assertSignatureFieldPositionValid, buildSignatureFieldBox, checkPdfPermissions, digest, getAvailableSignatureFields, getAvailableSignatureFields, getRevisions, getRevisions, getType, instantiateResourcesHandler, isDocTimestamp, isDocumentTimestampLayer, isSignature, loadSignatureDrawer, messageDigest, setAlertOnForbiddenSignatureCreation, setAlertOnSignatureFieldOutsidePageDimensions, setAlertOnSignatureFieldOverlap, setPdfDifferencesFinder, setPdfObjectModificationsFinder, setPdfPermissionsChecker, setPdfSignatureFieldPositionChecker, setResourcesHandlerBuilder, sign, toPdfPageCoordinates, validateByteRange
-
Constructor Details
-
ITextPDFSignatureService
public ITextPDFSignatureService(PDFServiceMode serviceMode, ITextSignatureDrawerFactory signatureDrawerFactory) Constructor for the ITextPDFSignatureService- Parameters:
serviceMode
- current instance is used to generate a DocumentTimestamp or Signature signature layersignatureDrawerFactory
- drawer factory implementation to be used
-
-
Method Details
-
computeDigest
protected DSSMessageDigest computeDigest(DSSDocument toSignDocument, PAdESCommonParameters parameters) Description copied from class:AbstractPDFSignatureService
Computes digest on to be signed data computed on thetoSignDocument
respectively to the givenparameters
- Specified by:
computeDigest
in classAbstractPDFSignatureService
- Parameters:
toSignDocument
-DSSDocument
to be signedparameters
-PAdESCommonParameters
- Returns:
DSSMessageDigest
-
signDocument
protected DSSDocument signDocument(DSSDocument toSignDocument, byte[] cmsSignedData, PAdESCommonParameters parameters) Description copied from class:AbstractPDFSignatureService
This method creates a signed document from the originaltoSignDocument
, incorporating a new revision, enveloping the providedcmsSignedData
- Specified by:
signDocument
in classAbstractPDFSignatureService
- Parameters:
toSignDocument
-DSSDocument
to be signedcmsSignedData
- byte array representing the encoded CMS signed data's binariesparameters
-PAdESCommonParameters
- Returns:
DSSDocument
-
addDssDictionary
public DSSDocument addDssDictionary(DSSDocument document, PdfValidationDataContainer validationDataForInclusion, char[] pwd, boolean includeVRIDict) Description copied from interface:PDFSignatureService
This method adds the DSS dictionary (Baseline-LT) to a password-protected document with a VRI dictionary if defined.- Parameters:
document
- the document to be extendedvalidationDataForInclusion
-PdfValidationDataContainer
pwd
- the password protection used to create the encrypted document (optional)includeVRIDict
- defines whether VRI dictionary should be included to the created DSS dictionary- Returns:
- the pdf document with the added dss dictionary
-
getAvailableSignatureFields
Description copied from interface:PDFSignatureService
Returns not-signed signature fields from an encrypted document- Parameters:
document
- the pdf documentpwd
- the password protection phrase used to encrypt the document- Returns:
- the list of not signed signature field names
-
addNewSignatureField
public DSSDocument addNewSignatureField(DSSDocument document, SignatureFieldParameters parameters, char[] pwd) Description copied from interface:PDFSignatureService
This method allows to add a new signature field to an existing encrypted pdf document- Parameters:
document
- the pdf documentparameters
- the parameters with the coordinates,... of the signature fieldpwd
- the password protection used to create the encrypted document (optional)- Returns:
- the pdf document with the new added signature field
-
getVisibleSignatureFieldBoxPosition
protected AnnotationBox getVisibleSignatureFieldBoxPosition(SignatureDrawer signatureDrawer, PdfDocumentReader documentReader, SignatureFieldParameters parameters) throws IOException Description copied from class:AbstractPDFSignatureService
Checks validity of the SignatureField position and returns the calculated signature field box- Overrides:
getVisibleSignatureFieldBoxPosition
in classAbstractPDFSignatureService
- Parameters:
signatureDrawer
-SignatureDrawer
documentReader
-PdfDocumentReader
parameters
-SignatureFieldParameters
- Returns:
AnnotationBox
- Throws:
IOException
- if an exception occurs
-
getVisibleSignatureFieldBoxPosition
protected AnnotationBox getVisibleSignatureFieldBoxPosition(PdfDocumentReader reader, SignatureFieldParameters parameters) throws IOException Description copied from class:AbstractPDFSignatureService
Checks if the signatureFieldBox overlaps with any existing annotations on the given page and returns the respectful signature field box- Overrides:
getVisibleSignatureFieldBoxPosition
in classAbstractPDFSignatureService
- Parameters:
reader
-PdfDocumentReader
to be validatedparameters
-SignatureFieldParameters
- Returns:
AnnotationBox
computed signature field box- Throws:
IOException
- if an exception occurs
-
previewPageWithVisualSignature
public DSSDocument previewPageWithVisualSignature(DSSDocument toSignDocument, PAdESCommonParameters parameters) Description copied from interface:PDFSignatureService
Returns a page preview with the visual signature- Parameters:
toSignDocument
- the document to be signedparameters
- the signature/timestamp parameters- Returns:
- a DSSDocument with the PNG picture
-
previewSignatureField
public DSSDocument previewSignatureField(DSSDocument toSignDocument, PAdESCommonParameters parameters) Description copied from interface:PDFSignatureService
Returns a preview of the signature field- Parameters:
toSignDocument
- the document to be signedparameters
- the signature/timestamp parameters- Returns:
- a DSSDocument with the PNG picture
-
loadPdfDocumentReader
protected PdfDocumentReader loadPdfDocumentReader(DSSDocument dssDocument, char[] passwordProtection) throws IOException Description copied from class:AbstractPDFSignatureService
LoadsPdfDocumentReader
instance- Specified by:
loadPdfDocumentReader
in classAbstractPDFSignatureService
- Parameters:
dssDocument
-DSSDocument
to readpasswordProtection
- the password used to protect the document- Returns:
PdfDocumentReader
- Throws:
IOException
- in case of loading error
-
getVisualDifferences
protected List<PdfModification> getVisualDifferences(PdfDocumentReader signedRevisionReader, PdfDocumentReader finalRevisionReader) Description copied from class:AbstractPDFSignatureService
Returns a list of visual differences between the provided PDF and the signed content- Overrides:
getVisualDifferences
in classAbstractPDFSignatureService
- Parameters:
signedRevisionReader
-PdfDocumentReader
for the signed revision contentfinalRevisionReader
-PdfDocumentReader
for the input PDF document- Returns:
- a list of
PdfModification
s
-