[ ]

Reading text from a scanned page, photo, web link or even archive in Aspose.OCR for JavaScript via C++ is as easy as calling a universal AsposeOCRRecognize() method.

This method takes a sequence of WasmAsposeOCRInput objects and optional recognition settings.

Recognition results are returned as an object, that allow you to get extracted text in various formats.


The following code example shows how to extract text from an image uploaded by an user:

var Module = {
   onRuntimeInitialized: function()
      // Interface
      const sourceFile = document.getElementById("sourceFile");
      sourceFile.addEventListener("change", handleImgUpload);
      const outputConsole = document.getElementById("outputConsole");

      // Recognition
      function handleImgUpload(event)
         const file =[0];
         const reader = new FileReader();
         reader.onload = function(e){
            const fileData = new Uint8Array(;
            let filename =;
            let stream =, "w+");
            Module.FS.write(stream, fileData, 0, fileData.length, 0);
            var input = Module.WasmAsposeOCRInput();
            var inputs = new Module.WasmAsposeOCRInputs();
            var settings = Module.WasmAsposeOCRRecognitionSettings();
            input.url = filename;
            var result = Module.AsposeOCRRecognize(inputs, settings);
            // Get recognition results as text
            var result_str = Module.AsposeOCRSerializeResult(result, Module.ExportFormat.text);