Last active
June 9, 2025 08:00
-
-
Save yushulx/a5f07891d5b22cfd24f21a111c80a008 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<script src="https://cdn.jsdelivr.net/npm/dynamsoft-capture-vision-bundle@3.0.3001/dist/dcv.bundle.min.js"></script> | |
<input id="input-file" type="file" multiple accept=".jpg,.jpeg,.icon,.gif,.svg,.webp,.png,.bmp" /><br /> | |
Results:<br /> | |
<div id="results"></div> | |
<div id="parsedrResults" style="width: 100%; min-height: 10vh; font-size: 3vh; overflow: auto"></div> | |
<script> | |
const resultsContainer = document.querySelector("#results"); | |
const parsedResultsContainer = document.querySelector("#parsedrResults"); | |
let cvRouter; // an instance of CaptureVisionRouter | |
let pCvRouter; // promise of CaptureVisionRouter | |
let parser = null; // an instance of CodeParser | |
let isSDKReady = false; | |
document.querySelector("#input-file").addEventListener("change", async function () { | |
let files = [...this.files]; | |
this.value = ""; | |
resultsContainer.innerText = ""; | |
try { | |
if (!isSDKReady) { | |
alert("Please wait for the SDK to load"); | |
return; | |
} | |
for (let file of files) { | |
// Decode selected image with 'ReadSingleBarcode' template. | |
const result = await cvRouter.capture(file, "ReadBarcodes_Balance") | |
if (files.length > 1) { | |
resultsContainer.innerText += `\n${file.name}:\n`; | |
} | |
for (let item of result.items) { | |
if (item.type !== Dynamsoft.Core.EnumCapturedResultItemType.CRIT_BARCODE) { | |
continue; | |
} | |
resultsContainer.innerText += item.text + "\n"; | |
console.log(item.text); | |
// Parse the Aadhaar | |
let AADHAAR_Str = item.text; | |
let parsedResultItem = await parser.parse(AADHAAR_Str); | |
let parsedResult = JSON.parse(parsedResultItem.jsonString); | |
let parsedLines = parsedResult.ResultInfo; | |
console.log(parsedLines) | |
parsedResultsContainer.innerHTML = ""; | |
parsedLines.forEach((element) => { | |
resultsContainer.innerHTML += | |
"<hr><strong>" + element.FieldName + "</strong><br /><hr>" + element.Value; | |
}); | |
} | |
if (!result.items.length) resultsContainer.innerText += "No barcode found\n"; | |
} | |
} catch (ex) { | |
let errMsg = ex.message || ex; | |
console.error(errMsg); | |
alert(errMsg); | |
} | |
}); | |
async function activate() { | |
try { | |
await Dynamsoft.License.LicenseManager.initLicense( | |
"DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==", | |
true | |
); | |
Dynamsoft.Core.CoreModule.loadWasm(["DBR"]); | |
parser = await Dynamsoft.DCP.CodeParser.createInstance(); | |
await Dynamsoft.DCP.CodeParserModule.loadSpec("AADHAAR"); | |
cvRouter = await Dynamsoft.CVR.CaptureVisionRouter.createInstance(); | |
isSDKReady = true; | |
} | |
catch (ex) { | |
console.error(ex); | |
} | |
} | |
activate(); | |
</script> | |
</body> | |
</html> |
thanks.
@vikas990 it doesn't matter. Since it's XML, you can use any pair of keys and values. If there's no standard, you have to check both loc and locality.
thanks.
its really usefull.
But, your source code is not working Bro..........
plz do it another way ohk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is very usefull but can you also explain that different aadhaar-card have different form of xml data how do we store all different type of data;
for example:-
in some aadhaar card location is stored as loc and in some locality how to solve that