Class SignatureCapture

  • public class SignatureCapture
    extends ViewerFeature

    A feature which can be used to capture a handwritten signature on a Smartphone (iPhone, iPad or Android). It is disabled by default.

    When run this feature starts an (extremely) simple webserver and then creates a QR-Code which can be scanned by the smartphone to access that server. On doing so the user is presented with a page with a signature box which they can "write" their signature into, using a finger or stylus. On completion the signature vector data is sent back to the webserver started by this process, and the server is shut down.

    This requires that the computer running the viewer with this feature is accessible to the network the smartphone is on - in practice, this means they're on the same IP network with the smartphone connecting over WiFi. The URL for that computer will be guessed, but it can be specified if necessary with the "host" and "port" features.

    This feature is normally used by the ManageIdentities feature, which will use this to capture the signature and store it in the KeyStore. Doing so requires a PKCS#11 or JCEKS KeyStore - if the the KeyStore is in the default JCE format, the user will be prompted to upgrade it to JCEKS.

    The following initialization parameters can be specified to configure this feature.
    hostThe fully qualified name of the host to use in the URL - specify this if the viewer can't derive it
    portThe port to open the temporary server on - if not specified a random high port will be used
    The name of this feature is SignatureCapture

    This code is copyright the Big Faceless Organization. You're welcome to use, modify and distribute it in any form in your own projects, provided those projects continue to make use of the Big Faceless PDF library.

    • Field Detail


        public static final String PATHSUFFIX
        The suffix recommended to be appended to a KeyStore alias for that entries signature appearance
        See Also:
        Constant Field Values

        public static final String KEYALGORITHM
        The "algorithm" for the signature appearance KeyStore entry - they are stored as secret keys, which require an algorithm.
        See Also:
        Constant Field Values

        public static final char[] SECRETKEYPASSWORD
        The password for the signature appearance KeyStore entry - they are stored as secret keys so must be password protected, although the information is not secret. To avoid prompting we use a standard password each time.
    • Constructor Detail

      • SignatureCapture

        public SignatureCapture()
    • Method Detail

      • setLocalAddress

        public void setLocalAddress​(InetSocketAddress address)
        Set the local address to open the webserver on. By default the server will be opened on the wildcard address on a randomly allocated port.
      • writePath

        public static byte[] writePath​(GeneralPath path)
        A convenience method which will serialize the specified GeneralPath into a byte array.
        See Also:
      • getPathComponent

        public static JComponent getPathComponent​(GeneralPath path)
        A convenience method which will return a JComponent that displays the specified GeneralPath
      • capture

        public GeneralPath capture​(int width,
                                   int height)
      • capture

        public static GeneralPath capture​(InetSocketAddress address,
                                          String submiturl,
                                          int width,
                                          int height)
        Start a webserver, display a QR-Code that can be scanned to access it, and capture the signature entered on that webpage as a GeneralPath. The webserver is closed immediately on capture or cancellation
        address - the local address of the webserver - the port may be null - or null to use the default for this feature.
        submiturl - if not null, the URL that the signature should be submitted to
        width - the width of the desired "signature strip". Will be scaled to fit the device screen
        height - the height of the desired "signature strip".
        a GeneralPath if a signature was submitted, null if the process was cancelled, or a zero-size signature if the delete option was chosen.