Class SignatureCapture
- java.lang.Object
-
- org.faceless.pdf2.viewer2.ViewerFeature
-
- org.faceless.pdf2.viewer2.feature.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.The name of this feature is SignatureCapturehost The fully qualified name of the host to use in the URL - specify this if the viewer can't derive it port The port to open the temporary server on - if not specified a random high port will be used 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.
- Since:
- 2.11.25
-
-
Field Summary
Fields Modifier and Type Field Description static String
KEYALGORITHM
The "algorithm" for the signature appearance KeyStore entry - they are stored as secret keys, which require an algorithm.static String
PATHSUFFIX
The suffix recommended to be appended to a KeyStore alias for that entries signature appearancestatic 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.
-
Constructor Summary
Constructors Constructor Description SignatureCapture()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
action(ViewerEvent event)
GeneralPath
capture(int width, int height)
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.static JComponent
getPathComponent(GeneralPath path)
A convenience method which will return a JComponent that displays the specifiedGeneralPath
void
initialize(PDFViewer viewer)
Called when the feature is first added to a viewerboolean
isEnabledByDefault()
Return true if this feature is enabled by default (the default).static GeneralPath
readPath(byte[] data)
A convenience method which will deserialize the specified GeneralPath into a byte array.void
setLocalAddress(InetSocketAddress address)
Set the local address to open the webserver on.static byte[]
writePath(GeneralPath path)
A convenience method which will serialize the specified GeneralPath into a byte array.-
Methods inherited from class org.faceless.pdf2.viewer2.ViewerFeature
getAllEnabledFeatures, getAllFeatures, getCustomJavaScript, getFeatureProperty, getFeatureURLProperty, getName, setFeatureName, teardown, toString
-
-
-
-
Field Detail
-
PATHSUFFIX
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
-
KEYALGORITHM
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
-
SECRETKEYPASSWORD
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.
-
-
Method Detail
-
initialize
public void initialize(PDFViewer viewer)
Description copied from class:ViewerFeature
Called when the feature is first added to a viewer- Overrides:
initialize
in classViewerFeature
-
isEnabledByDefault
public boolean isEnabledByDefault()
Description copied from class:ViewerFeature
Return true if this feature is enabled by default (the default). Disabled features are excluded from the list returned byViewerFeature.getAllEnabledFeatures()
and byPDFTool
- Overrides:
isEnabledByDefault
in classViewerFeature
-
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:
readPath(byte[])
-
readPath
public static GeneralPath readPath(byte[] data)
A convenience method which will deserialize the specified GeneralPath into a byte array.- See Also:
writePath(java.awt.geom.GeneralPath)
-
getPathComponent
public static JComponent getPathComponent(GeneralPath path)
A convenience method which will return a JComponent that displays the specifiedGeneralPath
-
action
public void action(ViewerEvent event)
-
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- Parameters:
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 towidth
- the width of the desired "signature strip". Will be scaled to fit the device screenheight
- the height of the desired "signature strip".- Returns:
- a GeneralPath if a signature was submitted, null if the process was cancelled, or a zero-size signature if the delete option was chosen.
-
-