I want to store the value of the finallext in a variable and print it in a text box how can I do it? Can anybody help me with this????
Tesseract.recognize(
'../uploads/scanned-images/<?php echo $image_name; ?>',
'eng',
{ logger: m => console.log(m) }
).then(({ data: { text } }) => {
var extractedText = text;
var finalText = extractedText.replace(/[^0-9A-Za-z]/gi, '');
alert(finalText);
})
You can return some variables in then() like this.
const finalText = await Tesseract.recognize(
'../uploads/scanned-images/<?php echo $image_name; ?>',
'eng',
{ logger: m => console.log(m) }
).then(({ data: { text } }) => {
let extractedText = text;
let finalText = extractedText.replace(/[^0-9A-Za-z]/gi, '');
// alert(finalText);
return finalText;
});
alert(finalText);
P.S You need to use async function.