Download Document

Upon complete signing document, user is allow to download the document. The download document will be in PDF format.

Sequence for calling API to download document

Source Code Sample

long result = (long) jsonObj.get("result");
data = jsonObj.get("data").toString();
mac = jsonObj.get("mac").toString();
macCheck = Utils.SHA256(new StringBuilder(data).append(apiSecret).toString().getBytes());
if (result == 0) {
	if(mac.equals(macCheck)) {
		byte[] jsonData = Utils.aesEcbPkcs5PaddingDecrypt(Utils.hexString2Bytes(data), apiSecret);
		plainData = new String(jsonData).toString();
		JSONParser parser = new JSONParser();
	        retJson = (JSONObject) parser.parse(plainData);
		
	        //download file
	        String hexdata= (String) retJson.get("pdfdata");
	        byte[] bytedate=Utils.hexString2Bytes(hexdata);
		
	        File file = new File(targetPath); 
	        try { 
                       OutputStream os = new FileOutputStream(file); 
                       os.write(bytedate); 
                       os.close(); 
                     } 
                catch (Exception e) { 
                      System.out.println("Exception: " + e); 
                     } 
            }
}
Sample code to convert response data to file

Request Body Creation

{
	"contractnum": "D5CFEE6865AC4C15929A3E3AB11AE95A"
} 

Example of Request

https://<domain>/signserver/v1/contract/file?accesstoken=1f710ee6-b2ba-4aa4-b07b-538f472e3ff9-000027ed&data=d7319e81cf&mac=c36ac72d5d845a86a06d24d8548a802b3016d8fedc9e

Expected Response

{
  "pdfdata":"fa970522cc40f33d8a56d1af5e5435952216938325cdfd249a2f85cc534"
}

API reference guide : Download Document

How can we help?