Headless APIs
The SDK offers several APIs that can be used without instantiating a PdfViewer android view.
Those APIs are available through the class HeadlessSignatureController.
The WYSIWYS SDK must be initialized prior using the Headless mode using the PdfViewer.initialize method.
Store a document
The SDK provides an API to store a document in the WYSIWYS secured storage for a later use.
HeadlessSignatureController.storeDocument(inputStream, documentId);Retrieving document's state
Headless APIs have introduced the notion of states for a document. A document can be in one or more of the following states :
NOT_EXIST: The document is not present in the secured storageSTORED: The document has been stored in the secured storagePREPARED: The document has been preparedSIGNED: The document has been signed
A document in state PREPARED is necessarily also in state STORED, as well as a document in state SIGNED is necessarily in states PREPARED and STORED.
It's possible to know the state of a document using one of the following methods :
HeadlessSignatureController.getDocumentState(documentId);
HeadlessSignatureController.isDocumentInState(documentId, expectedState);Signing a document
The signature flow for a document is similar to the standard signature, except that no user interaction is possible.
The user interactions are replaced with the following pre-defined behaviour :
- If the handwritten signature is enabled but no signature are stored, handwritten signature will be disabled and the signature will be generated.
- If the handwritten signature is enabled but user has multiple signature stored, the first signature created will be automatically selected.
- If no signature field is available, the document will be signed with an invisible signature
- If multiple signature fields are available, the dedicated field(s) for the user (see previous section) are automatically selected. If the field names do not match any pattern, the first field in PDF dictionnary (not necessarily the first visible field) is automatically selected.
The document can be accepted or refused once an instance of the HeadlessSignatureController for a given document is created.
HeadlessSignatureController controller = HeadlessSignatureController.newInstance(androidContext, documentId, signatureConfiguration);
controller.acceptDocument();
controller.refuseDocument();Once the event SignatureEventListener#onConfirmationRequired() is emitted by the SDK, the app must confirm the signature using the method confirmSignature() on the controller.
controller.confirmDocument();Retrieving signature info
Once a document is prepared, it's possible to retrieve the signature information, which consist of
- documentDigest : The document digest of the prepared document
- reason : The reason of the signature (
acceptedif document was accepted,refusedif document was refused)
HeadlessSignatureController.getSignatureInfo(documentId);Dispose document
When a document is not needed anymore, the app must explicitly dispose the document.
HeadlessSignatureController.disposeDocument(documentId);This call will delete all data related to the given document ID, including prepared and signed file.
If the signature process is canceled or aborted, it's possible to dispose only prepared and signed documents.
HeadlessSignatureController.disposeDocument(documentId, documentState);Disposing the prepared file will also dispose the signed file.