Capture a signature image, create a HTML with signature image, convert HTML to PDF file, and send an email with PDF file.
The title might give you headache from the starting point but once you know each details as my instruction, it will be simple and easy to implement it.
The requirements from my client was quite a simple as below;
1. have customer read agreement contents and sign it on any digital equipment or device.
2. get a copy of signature and create a PDF.
3. Send this PDF file to customer through email.
As you can see above requirements, it sounds not that complicate.
So, I have designed a simple application to fulfill these requirements through following technologies.
1. AngularJS
2. RESTful API in Java using JAX-RS and Jersey.
3.Itext with Flying source + rendering tool
4. Sendgrid email
First, The Angular JS framework is providing lots of breathing room without worrying about structuring whole project. It is simple and easy to start.
Second. the Jersey restful webservice is another simple set to connect to database and utilize the JSON type of data. If you would like to design Backend service, this will be the simple and quick answer to everybody.
Third, Itext with flying source is providing good library to convert from HTML to PDF. It was bit picky to make right format of HTML in order to be converted properly.
Finally, the sendgrid library is providing many headache to configure the mail server and simple to use too.
The below are details and should know for implementing this.
5. For the signautre it will need jSignature.js library. The code example is below;
– ex.) HTML code;
<!– This will be the area of sign –>
<div id=”signature”></div>
</div>
<div id=”tools”></div>
– ex.) controller.js;
function SignCtrl($rootScope,$scope,CashSignature,Signature) {
console.log(” SignCtrl is invoked”);
$scope.signature =CashSignature.getSign();
(function($) {
var topics = {};
$.publish = function(topic, args) {
if (topics[topic]) {
var currentTopic = topics[topic],
args = args || {};
for (var i = 0, j = currentTopic.length; i < j; i++) {
currentTopic[i].call($, args);
}
}
};
$.subscribe = function(topic, callback) {
if (!topics[topic]) {
topics[topic] = [];
}
topics[topic].push(callback);
return {
“topic”: topic,
“callback”: callback
};
};
$.unsubscribe = function(handle) {
var topic = handle.topic;
if (topics[topic]) {
var currentTopic = topics[topic];
for (var i = 0, j = currentTopic.length; i < j; i++) {
if (currentTopic[i] === handle.callback) {
currentTopic.splice(i, 1);
}
}
}
};
})(jQuery);
$(document).ready(function() {
// This is the part where jSignature is initialized.
var $sigdiv = $(“#signature”).jSignature({‘UndoButton’:false})
// All the code below is just code driving the demo.
, $tools = $(‘#tools’)
, $extraarea = $(‘#displayarea’)
, pubsubprefix = ‘jSignature.demo.’
$(‘<span><b>Please confirm your sign by clicking this Sign button: </b></span><input type=”button” value=”SIGN NOW” >’).bind(‘click’, function(e){
var data = $sigdiv.jSignature(‘getData’,’image’)
var signature = CashSignature.getSign();
signature.signString=data;
console.log(“signature is processing ” );
//updateSignature($rootScope,$scope,signature,CashSignature.getSign().customerid);
signature.$update({ customerid: signature.customerid});
console.log(” SignCtrl is invoked and will save data :”)
window.location = “#/search”;
//}
}).appendTo($tools)
OutputStream os = null;
try{
os = new FileOutputStream(Utils.getTempPDFPath()+ “/”+sig.getName().trim().replaceAll(” “, “_”)+ “_”+sig.getBarcode() +”_signed.pdf”);
Sharing Http Session State between Web applications in weblogic is not that simple case you can resolve. It will need lots of configuration in weblogic and need to in one EAR file too.
Configuration of sharing Http Session
•Should be deployed in one EAR file.
•Build script(ANT) should be modified to move war files to one place and manual construction for weblogic-application.xml
If you would like to read a blob data from JAVA, there would be many ways. However, if the data is XML format of properties, then you can follow below simple coding to excise in your programming. First, you have to make blob data into byte array stream. Then, it should be load as a properties by using loadFromXML that will simplify your whole process to get your XML format of BLOB data.