com.groupdocs.signature.handler

Class SignatureHandler<T>



  • public class SignatureHandler<T>
    extends Object

    Create instance of SignatureHandler class to sign documents with image and digital signatures

    • Constructor Detail

      • SignatureHandler

        public SignatureHandler()

        Instantiate the SignatureHandler with default SignatureConfig, IInputDataHandler and IOutputDataHandler All files will be loaded from local file system

      • SignatureHandler

        public SignatureHandler(SignatureConfig signatureConfig)

        Instantiate the SignatureHandler with default IInputDataHandler and IOutputDataHandler All files will be loaded from local file system

        Parameters:
        signatureConfig - Instance of SignatureConfig
      • SignatureHandler

        public SignatureHandler(SignatureConfig signatureConfig,
                        IInputDataHandler inputDataHandler)

        Instantiate the SignatureHandler with default IOutputDataHandler and custom IInputDataHandler implementation

        Parameters:
        signatureConfig - Instance of SignatureConfig
        inputDataHandler - Custom implementation of IInputDataHandler interface
      • SignatureHandler

        public SignatureHandler(SignatureConfig signatureConfig,
                        IOutputDataHandler outputDataHandler)

        Instantiate the SignatureHandler with default IInputDataHandler and custom IOutputDataHandler implementation

        Parameters:
        signatureConfig - Instance of SignatureConfig
        outputDataHandler - Custom implementation of IOutputDataHandler interface
      • SignatureHandler

        public SignatureHandler(SignatureConfig signatureConfig,
                        IInputDataHandler inputDataHandler,
                        IOutputDataHandler outputDataHandler)

        Instantiate the SignatureHandler with custom IInputDataHandler and IOutputDataHandler implementation

        Parameters:
        signatureConfig - Instance of SignatureConfig
        inputDataHandler - Custom implementation of IInputDataHandler interface
        outputDataHandler - Custom implementation of IOutputDataHandler interface
    • Method Detail

      • getPageDescriptions

        public static DocumentDescription getPageDescriptions(String guid)
                                                       throws Exception

        Gets information about document pages: their sizes, maximum page height, the width of a page with the maximum height.

        Parameters:
        guid - The file unique identifier, full path for local storage e.g. c:\\storage\\document.txt, relative path e.g document.txt, URL e.g. http://site.com/document.txt.
        Returns:
        An object of the DocumentDescription class
        Throws:
        Exception
      • getDocumentPageImage

        public static byte[] getDocumentPageImage(String guid,
                                  Integer width,
                                  Integer quality,
                                  int pageIndex)
                                           throws Exception

        Returns an image of a specified page.

        Parameters:
        guid - The file unique identifier, full path for local storage e.g. c:\\storage\\document.txt, relative path e.g document.txt, URL e.g. http://site.com/document.txt.
        width - A required width of images.
        quality - A required quality of images.
        pageIndex - The number of a page to get image for.
        Returns:
        An array of bytes representing the output image.
        Throws:
        Exception
      • getPageSize

        public static Dimension getPageSize(String guid,
                            int signaturePageNumber,
                            double signatureLocationX,
                            double signatureLocationY,
                            PositionInCellsDocument positionInCellsDocument)
                                     throws Exception

        Gets the size of a page of a document.

        Parameters:
        guid - The file unique identifier, full path for local storage e.g. c:\\storage\\document.txt, relative path e.g document.txt, URL e.g. http://site.com/document.txt.
        signaturePageNumber - The number of the page.
        signatureLocationX - The X coordinate of a signature for Cells files.
        signatureLocationY - The Y coordinate of a signature for Cells files.
        positionInCellsDocument - The row and column number of the nearest to the signature cell are returned in this object for Cells files.
        Returns:
        The size of a specified page for file types excluding Cells.
        Throws:
        Exception
      • getSignatureConfig

        public SignatureConfig getSignatureConfig()

        Signature Configuration with file location paths options

      • sign

        public T sign(String guid,
             SignOptions signOptions)
               throws Exception

        Sign the document from file quid with SignOptions

        Parameters:
        guid - File guid
        signOptions - Signature Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(String guid,
             SignOptions signOptions,
             LoadOptions loadOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        guid - File guid
        signOptions - Signature Options
        loadOptions - Load Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(String guid,
             SignOptions signOptions,
             SaveOptions saveOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        guid - File guid
        signOptions - Signature Options
        saveOptions - Save Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(String guid,
             SignOptions signOptions,
             LoadOptions loadOptions,
             SaveOptions saveOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        guid - File guid
        signOptions - Signature Options
        loadOptions - Load Options
        saveOptions - Save Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(InputStream stream,
             SignOptions signOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        stream - Input Stream
        signOptions - Signature Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(InputStream stream,
             SignOptions signOptions,
             LoadOptions loadOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        stream - Input Stream
        signOptions - Signature Options
        loadOptions - Load Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(InputStream stream,
             SignOptions signOptions,
             SaveOptions saveOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        stream - Input Stream
        signOptions - Signature Options
        saveOptions - Save Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(InputStream stream,
             SignOptions signOptions,
             LoadOptions loadOptions,
             SaveOptions saveOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        stream - Input Stream
        signOptions - Signature Options
        loadOptions - Load Options
        saveOptions - Save Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(String guid,
             SignatureOptionsCollection collection)
               throws Exception

        Sign the document from file quid with list of SignOptions

        Parameters:
        guid - File guid
        collection - Collection of options. Instance of SignatureOptionsCollection
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(String guid,
             SignatureOptionsCollection collection,
             LoadOptions loadOptions)
               throws Exception

        Sign the document from file quid with List of Signature Options and Load Options

        Parameters:
        guid - File guid
        collection - Collection of options. Instance of SignatureOptionsCollection
        loadOptions - Load Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(String guid,
             SignatureOptionsCollection collection,
             SaveOptions saveOptions)
               throws Exception

        Sign the document from file quid with Signature Options and Save options

        Parameters:
        guid - File guid
        collection - Collection of options. Instance of SignatureOptionsCollection
        saveOptions - Save Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(String guid,
             SignatureOptionsCollection collection,
             LoadOptions loadOptions,
             SaveOptions saveOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        guid - File guid
        collection - Collection of options. Instance of SignatureOptionsCollection
        loadOptions - Load Options
        saveOptions - Save Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(InputStream stream,
             SignatureOptionsCollection collection)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        stream - Input Stream
        collection - Collection of options. Instance of SignatureOptionsCollection
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(InputStream stream,
             SignatureOptionsCollection collection,
             LoadOptions loadOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        stream - Input Stream
        collection - Collection of options. Instance of SignatureOptionsCollection
        loadOptions - Load Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(InputStream stream,
             SignatureOptionsCollection collection,
             SaveOptions saveOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        stream - Input Stream
        collection - Collection of options. Instance of SignatureOptionsCollection
        saveOptions - Save Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • sign

        public T sign(InputStream stream,
             SignatureOptionsCollection collection,
             LoadOptions loadOptions,
             SaveOptions saveOptions)
               throws Exception

        Sign the document from file quid with SignOptions, load and save options

        Parameters:
        stream - Input Stream
        collection - Collection of options. Instance of SignatureOptionsCollection
        loadOptions - Load Options
        saveOptions - Save Options
        Returns:
        Returns Stream of signed document or string as file path to signed file
        Throws:
        Exception
      • verify

        public VerificationResult verify(String guid,
                                VerifyOptions verifyOptions)
                                  throws Exception

        Verify the document from file guid with VerifyOptions

        Parameters:
        guid - File guid
        verifyOptions - Signature Verification Options
        Returns:
        Returns instance of VerificationResult. Property VerificationResult.IsValid returns true if verification process was successful
        Throws:
        Exception
      • verify

        public VerificationResult verify(String guid,
                                VerifyOptions verifyOptions,
                                LoadOptions loadOptions)
                                  throws Exception

        Verify the document from file quid with VerifyOptions and specified Load Options

        Parameters:
        guid - File guid
        verifyOptions - Signature Verification Options
        loadOptions - Load Document Options
        Returns:
        Returns instance of VerificationResult. Property VerificationResult.IsValid returns true if verification process was successful
        Throws:
        Exception
      • verify

        public VerificationResult verify(InputStream stream,
                                VerifyOptions verifyOptions)
                                  throws Exception

        Verify the document from stream with VerifyOptions

        Parameters:
        stream - Input Stream
        verifyOptions - Signature Verification Options
        Returns:
        Returns instance of VerificationResult. Property VerificationResult.IsValid returns true if verification process was successful
        Throws:
        Exception
      • verify

        public VerificationResult verify(InputStream stream,
                                VerifyOptions verifyOptions,
                                LoadOptions loadOptions)
                                  throws Exception

        Verify the document from stream with VerifyOptions

        Parameters:
        stream - Input Stream
        verifyOptions - Signature Verification Options
        loadOptions - Load Document Options
        Returns:
        Returns instance of VerificationResult. Property VerificationResult.IsValid returns true if verification process was successful
        Throws:
        Exception
      • verify

        public VerificationResult verify(String guid,
                                VerifyOptionsCollection collection)
                                  throws Exception

        Verify the document from file quid with list of VerifyOptions

        Parameters:
        guid - File guid
        collection - Collection of Verification Options. Instance of VerifyOptionsCollection
        Returns:
        Returns instance of VerificationResult. Property VerificationResult.IsValid returns true if verification process was successful
        Throws:
        Exception
      • verify

        public VerificationResult verify(String guid,
                                VerifyOptionsCollection collection,
                                LoadOptions loadOptions)
                                  throws Exception

        Verify the document from file quid with list of VerifyOptions

        Parameters:
        guid - File guid
        collection - Collection of Verification Options. Instance of VerifyOptionsCollection
        loadOptions - Load Options
        Returns:
        Returns instance of VerificationResult. Property VerificationResult.IsValid returns true if verification process was successful
        Throws:
        Exception
      • verify

        public VerificationResult verify(InputStream stream,
                                VerifyOptionsCollection collection)
                                  throws Exception

        Verify the document from file quid with list of VerifyOptions

        Parameters:
        stream - Input Stream
        collection - Collection of Verification Options. Instance of VerifyOptionsCollection
        Returns:
        Returns instance of VerificationResult. Property VerificationResult.IsValid returns true if verification process was successful
        Throws:
        Exception
      • verify

        public VerificationResult verify(InputStream stream,
                                VerifyOptionsCollection collection,
                                LoadOptions loadOptions)
                                  throws Exception

        Verify the document from file quid with list of VerifyOptions

        Parameters:
        stream - Input Stream
        collection - Collection of Verification Options. Instance of VerifyOptionsCollection
        loadOptions - Load Options
        Returns:
        Returns instance of VerificationResult. Property VerificationResult.IsValid returns true if verification process was successful
        Throws:
        Exception
      • getDocumentDescription

        public DocumentDescription getDocumentDescription(String guid,
                                                 String password)
                                                   throws Exception

        Gets information about document pages: their sizes, maximum page height, the width of a page with the maximum height.

        Parameters:
        guid - The file unique identifier, full path for local storage e.g. c:\\storage\\document.txt, relative path e.g document.txt, URL e.g. http://site.com/document.txt.
        password - Document password.
        Returns:
        An object of the DocumentDescription class.
        Throws:
        Exception
      • getDocumentDescription

        public DocumentDescription getDocumentDescription(InputStream stream,
                                                 String password)
                                                   throws Exception

        Gets information about document pages: their sizes, maximum page height, the width of a page with the maximum height.

        Parameters:
        stream - Input stream.
        password - Document password.
        Returns:
        An object of the DocumentDescription class.
        Throws:
        Exception
      • getPageImage

        public byte[] getPageImage(String guid,
                          int pageNumber,
                          String password,
                          Integer width,
                          Integer quality)
                            throws Exception

        Returns an image of a specified page.

        Parameters:
        guid - The file unique identifier, full path for local storage e.g. c:\\storage\\document.txt, relative path e.g document.txt, URL e.g. http://site.com/document.txt.
        pageNumber - The number of a page to get image for. Min value is 1.
        password - Document password.
        width - A required width of images.
        quality - A required quality of images.
        Returns:
        An array of bytes representing the output image.
        Throws:
        Exception
      • getPageImage

        public byte[] getPageImage(InputStream stream,
                          int pageNumber,
                          String password,
                          Integer width,
                          Integer quality)
                            throws Exception

        Returns an image of a specified page.

        Parameters:
        stream - Document stream.
        pageNumber - The number of a page to get image for. Min value is 1.
        password - Document password.
        width - A required width of images.
        quality - A required quality of images.
        Returns:
        An array of bytes representing the output image.
        Throws:
        Exception
      • getDocumentPageSize

        public Dimension getDocumentPageSize(String guid,
                                    int pageNumber,
                                    String password,
                                    double signatureLocationXforCells,
                                    double signatureLocationYforCells,
                                    PositionInCellsDocument positionInCellsDocument)
                                      throws Exception

        Gets the size of a page of a document.

        Parameters:
        guid - The file unique identifier, full path for local storage e.g. c:\\storage\\document.txt, relative path e.g document.txt, URL e.g. http://site.com/document.txt.
        pageNumber - The number of a page to get size for. Min value is 1.
        password - Document password.
        signatureLocationXforCells - The X coordinate of a signature for Cells files.
        signatureLocationYforCells - The Y coordinate of a signature for Cells files.
        positionInCellsDocument - The row and column number of the nearest to the signature cell are returned in this object for Cells files.
        Returns:
        The size of a specified page for file types excluding Cells.
        Throws:
        Exception
      • getDocumentPageSize

        public Dimension getDocumentPageSize(InputStream stream,
                                    int pageNumber,
                                    String password,
                                    double signatureLocationXforCells,
                                    double signatureLocationYforCells,
                                    PositionInCellsDocument positionInCellsDocument)
                                      throws Exception

        Gets the size of a page of a document.

        Parameters:
        stream - Document stream.
        pageNumber - The number of a page to get size for. Min value is 1.
        password - Document password.
        signatureLocationXforCells - The X coordinate of a signature for Cells files.
        signatureLocationYforCells - The Y coordinate of a signature for Cells files.
        positionInCellsDocument - The row and column number of the nearest to the signature cell are returned in this object for Cells files.
        Returns:
        The size of a specified page for file types excluding Cells.
        Throws:
        Exception