Send the document or data from the originating app to SIGNATUS and expect SIGNATUS to send an info via a result call-back to the originating app, where work with signed document can continue.
Step-by-step:
- Copy a PDF to your app’s private storage.
- Expose the file via a FileProvider.
- Launch SIGNATUS with the Intent below.
- Handle the result in
ActivityResultLauncher
.
Call from originating Application to SIGNATUS:
- After the document is signed in SIGNATUS, the user is automatically returned to the originating application.
- The PDF file remains in the internal storage of originating application throughout the entire process. Once the document is signed, SIGNATUS replaces the original PDF with the signed version.
Integration steps #
1) File-paths descriptor
Create a file_paths.xml descriptor in res/xml
<paths>
<files-path name="pdf_data" path="pdf/"/>
</paths>
2) Declare FileProvider in AndroidManifest.xml:
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.app2app.anasoft.pdfprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
3) Save the PDF document in the internal storage directory according to the configuration done in section 1:
File pdf = new File(getFilesDir()+ "/pdf/Contract123.pdf ");
4) Launch SIGNATUS via intent:
Signatus replaces the original PDF with the signed version of the PDF
private void signPdf(File pdf, @Nullable JSONObject data) {
Log.d("App2App", "Pdf path :" + pdf.getPath());
Uri pdfUri = FileProvider.getUriForFile(this, "com.app2app.anasoft.pdfprovider", pdf);
Log.d("App2App", "Pdf uri :" + pdfUri);
Intent intent = new Intent();
intent.setAction("com.anasoft.signatus.signDocument");
intent.setDataAndType(pdfUri, "application/pdf");
if (data != null) {
intent.putExtra("data", data.toString());
}
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
signLauncher.launch(intent);
}
5) Handle the result using ActivityResultLauncher:
ActivityResultLauncher<Intent> signLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
result -> {
Log.d("App2App", "Result code :" + result.getResultCode());
Log.d("App2App", "Result data :" + result.getData());
});
Data parameter #
The optional data parameter in the sign intent provides a mechanism to configure aspects of the user interface and modify application behavior
Data example :
{
"color": "#230090",
"config": {
"signerInfo": {
"SC_signature": [
"John Smith"
]
},
"method": "write"
},
"allowedFields": {
"SIGNATURE": [
"SC_signature"
],
"TEXT": [
"TO_text",
"TC_text"
]
},
"allowedButtons": [
"action_ok",
"action_canceled"
],
"nativeMenu": [
{
"id": "action_ok",
"title": "SAVE AND CLOSE",
"color": "#ffffff"
},
{
"id": "action_canceled",
"title": "CANCEL",
"icon": "REMOVE",
"color": "#ff0000"
}
]
}
Data description :
Name | Value | Description |
color | Hexadecimal color code | Toolbar color |
config | JSON Object | Additional signature field configuration |
config.signerInfo | JSON Object | Assigning the signer’s name to a signature field. Signer name will appear within the signature. |
config.signerInfo.key | String | Acrofield name |
config.signerInfo.value | String | Signer name |
config.method | String | Specifies the required user interaction with the document. Allowed values : – read : mandatory to read the document and scroll all the way down to the bottom of the document – write : mandatory to sign – optional : optional to read Default : write |
allowedFields | JSON Object | Configuration of which AcroFields will be allowed during signing. |
allowedFields.key | String | Acrofield type. Allowed values : – TEXT – CHECKBOX – SIGNATURE – RADIO – COMBOBOX |
allowedFields.value | JSON Array | AcroField names |
allowedButtons | JSON Array | Toolbar native button IDs that will be displayed. Allowed values: – action_ok – action_discard – action_canceled – action_up – action_down |
nativeMenu | JSON Array | Toolbar native buttons configuration |
nativeMenu.id | String | Button id. Allowed values: – action_ok – action_discard – action_canceled – action_up – action_down |
nativeMenu.title | String | Button text |
nativeMenu.color | Hexadecimal color code | Button text color |
nativeMenu.icon | REMOVE | If “REMOVE” is set, button icon will not be displayed. |
Data example result :
