Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<zk>
<window id="patientscan" border="none"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.product.webapp.patient.PatientScanVM')">
<script type="text/javascript">
<![CDATA[
var directoryPath = "C:\\CSSNDemoImages\\"; //set path to root folder for web app. to hold all images generated by this app.
var filePathFront = directoryPath + "scannedImage.jpg"; //name of front scanned image
var filePathBack = directoryPath + "scannedImage-back.jpg"; //name of back scanned image
function getCSSNLibJObj()
{
console.log("getCSSNLibJObj");
var CSSNLibJ = zk.Widget.$("$CSSNLibJ").$n();
return CSSNLibJ;
}
function InitLibrary() {
var CSSNLibJ = getCSSNLibJObj();
var result = CSSNLibJ.InitScanLib("8NDANMAE6W8CZ5D5");
var lblconn = zk.Widget.$("$scannerconnect");
console.log("Scanner connection status " + result);
if (result < 1 && result != -13)
{
lblconn.setValue("Not Connected - " + result);
}
else
{
scannerName = CSSNLibJ.GetScannerName();
lblconn.setValue("Connected - " + scannerName);
var btnscanfront = zk.Widget.$("$scanfront");
btnscanfront.setDisabled(false);
var btnfrontrotate = zk.Widget.$("$frontrotate");
btnfrontrotate.setDisabled(false);
var btnscanback = zk.Widget.$("$scanback");
btnscanback.setDisabled(false);
var btnbackrotate = zk.Widget.$("$backrotate");
btnbackrotate.setDisabled(false);
var btnprocessid = zk.Widget.$("$processid");
btnprocessid.setDisabled(false);
}
}
function ScanFront()
{
ScanCard(filePathFront, "front");
}
function ScanBack()
{
ScanCard(filePathBack, "back");
}
function ScanCard(filePath, cardSide)
{
console.log("Inside ScanCard " + cardSide + " and filepath "+ filePath);
var CSSNLibJ = getCSSNLibJObj();
if (CSSNLibJ.IsScannerValid() != 1)
{
alert("Not a valid scanner");
return;
}
if (CSSNLibJ.IsNeedCalibration() == 1)
{
console.log("IsNeedCalibration");
CSSNLibJ.CalibrateEx();
}
console.log("Going Scan");
CSSNLibJ.SetScanSize(-1, -1);
CSSNLibJ.SetResolution(300);
alert("Going scan");
if (cardSide == "front")
result = CSSNLibJ.ScanToFileJ(""); //scan file to buffer & disk
else
result = CSSNLibJ.ScanToFileBackJ(""); //scan file to buffer & disk
console.log("Scanning completed Result is " + result);
alert("Scanning completed Result is " + result);
var imgfront = zk.Widget.$("$imgfront");
imgfront.setContent(CSSNLibJ.GetImageBufferDataBase64("jpg"));
}
function ProcessCard()
{
console.log("ProcessCard ");
var CSSNLibJ = getCSSNLibJObj();
var stateid = -1;
var reg = document.getElementById('region');
var regio= "United States";
CSSNLibJ.SetIDRegion(GetRegionIntValue(regio));
// Auto detect crops and rotates the internal image for better OCR results
stateid = CSSNLibJ.DetectState("");
if (stateid < 0)
{
console.log("Error in Auto Detect " +stateid);
}
// var result = CSSNLibJ.ProcessState("",stateid);
console.log("Going Read Data ");
var result = CSSNLibJ.DetectProcessDuplex("", "", stateid, 0);
if (result < 0) {
console.log("Error in Read Data " +stateid);
}
console.log("Reading Done");
var BCData;
//refresh barcode to fill library properties
CSSNLibJ.RefreshBC();
//extract barcode (back side) data
BCData = "BarCode Data : <br /> " +
"Name - " + CSSNLibJ.getBCName() + "<br />" +
"Name First - " + CSSNLibJ.getBCFirstName() + "<br />" +
"Name Middle - " + CSSNLibJ.getBCMidName() + "<br />" +
"Name Last - " + CSSNLibJ.getBCLastName() + "<br />" +
"License - " + CSSNLibJ.getBCLicense() + "<br />" +
"DOB - " + CSSNLibJ.getBCDateOfBirth() + "<br />" +
"Address - " + CSSNLibJ.getBCAddress() + "<br />" +
"City - " + CSSNLibJ.getBCCity() + "<br />" +
"State - " + CSSNLibJ.getBCState() + "<br />" +
"Zip - " + CSSNLibJ.getBCZip();
var txtfname = zk.Widget.$("$firstname");
txtfname.setValue(CSSNLibJ.getBCFirstName());
var txtlname = zk.Widget.$("$lastname");
txtlname.setValue(CSSNLibJ.getBCLastName());
var txtmname = zk.Widget.$("$middlename");
txtmname.setValue(CSSNLibJ.getBCMidName());
var txtlincese = zk.Widget.$("$License");
txtlincese.setValue(CSSNLibJ.getBCLicense());
var txtDOB = zk.Widget.$("$DOB");
txtDOB.setValue(CSSNLibJ.getBCDateOfBirth());
var txtaddress = zk.Widget.$("$Address");
txtaddress.setValue(CSSNLibJ.getBCAddress());
var txtcity = zk.Widget.$("$city");
txtcity.setValue(CSSNLibJ.getBCCity());
var txtstate = zk.Widget.$("$state");
txtstate.setValue(CSSNLibJ.getBCState());
var txtzip = zk.Widget.$("$Zip");
txtzip.setValue(CSSNLibJ.getBCZip());
}
]]>
</script>
<applet name="CSSNLibJ" id="CSSNLibJ"
archive="xFunction.jar,CSSNLibJ.jar" code="lib.CSSNLibJ" width="10"
height="10">
</applet>
<div width="96%">
<span width="100%">
<div sclass="screenheader">
<separator />
<label id="lcaption" sclass="screenheaderlabel"
value="Driver License Scanning" />
<label id="scannerconnect"
value="" />
</div>
</span>
<div id="buttonsDiv" sclass="screenheaderbuts">
<fbutton label="Connect to Scanner"
xmlns:w="http://www.zkoss.org/2005/zk/client" w:onClick="InitLibrary();">
</fbutton>
<fbutton label="Clear All"
onClick="@command('OnClearAll')">
</fbutton>
</div>
<div sclass="clearboth"></div>
<div sclass="sectionSeperator"></div>
</div>
<panel width="95%" sclass="sectionpadding">
<panelchildren>
<groupbox mold="3d" closable="false"
sclass="grpboxSectionBar">
<vgrid>
<columns>
<column></column>
<column></column>
<column></column>
</columns>
<rows>
<row>
<vlayout>
<flabel value="Front Image"
sclass="screenheaderlabel" />
<image id="imgfront" src="/images/cardDemo.jpg" />
</vlayout>
<vlayout>
<flabel value="Back Image"
sclass="screenheaderlabel" />
<image id="imgback" src="/images/cardDemo.jpg" />
</vlayout>
<vlayout>
<flabel
value="Patient Image and Signature"
sclass="screenheaderlabel" />
<hbox>
<image
src="/images/faceDemo.jpg" />
<image
src="/images/signatureDemo.jpg" />
</hbox>
</vlayout>
</row>
<row>
<vlayout>
<hbox>
<fbutton label="Scan" id="scanfront" disabled="true"
xmlns:w="http://www.zkoss.org/2005/zk/client" w:onClick="ScanFront();">
</fbutton>
<space width="95px"></space>
<fbutton label="Rotate" id="frontrotate" disabled="true"
onClick="@command('onRotateFront')">
</fbutton>
</hbox>
</vlayout>
<vlayout>
<hbox>
<fbutton label="Scan" id="scanback" disabled="true"
onClick="@command('onScanBack')">
</fbutton>
<space width="95px"></space>
<fbutton label="Rotate" id="backrotate" disabled="true"
onClick="@command('onRotateBack')">
</fbutton>
</hbox>
</vlayout>
<vlayout>
<hbox>
<fbutton label="Process ID" id="processid" disabled="true"
onClick="@command('onProcessID')">
</fbutton>
</hbox>
</vlayout>
</row>
</rows>
</vgrid>
</groupbox>
<label sclass="screenheaderlabel" value="Card Data" />
<groupbox mold="3d" closable="false"
sclass="grpboxSectionBar">
<vgrid>
<columns>
<column></column>
<column></column>
<column></column>
<column></column>
<column></column>
</columns>
<rows>
<row>
<vlayout>
<flabel value="First Name" />
<ftextbox id="firstname" hflex="1"
readonly="true" name="firstname" />
</vlayout>
<vlayout>
<flabel value="Last Name" />
<ftextbox id="lastname" hflex="1"
readonly="true" name="lastname" />
</vlayout>
<vlayout>
<flabel value="Middle Name" />
<ftextbox id="middlename" hflex="1"
readonly="true" name="middlename" />
</vlayout>
<vlayout>
<label value="DOB" sclass="flabel" />
<ftextbox id="DOB" hflex="1"
readonly="true" name="DOB" />
</vlayout>
<vlayout>
<flabel value="License No" />
<ftextbox id="License" hflex="1"
readonly="true" name="License" />
</vlayout>
</row>
<row>
<cell colspan="2">
<vlayout>
<flabel value="Address" />
<ftextbox id="Address" hflex="1"
readonly="true" name="Address" />
</vlayout>
</cell>
<vlayout>
<flabel value="City" />
<ftextbox id="city" hflex="1"
readonly="true" name="city" />
</vlayout>
<vlayout>
<flabel value="State" />
<ftextbox id="state" hflex="1"
readonly="true" name="state" />
</vlayout>
<vlayout>
<flabel value="Zip" />
<ftextbox id="Zip" hflex="1"
readonly="true" name="Zip" />
</vlayout>
</row>
</rows>
</vgrid>
</groupbox>
</panelchildren>
</panel>
</window>
</zk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment