Giovanni Palerma Giovanni Palerma - 1 year ago 210
Javascript Question

tesseract.js sample code not working

I'm trying to make Tesseract.js working.

I have taken a very simple code from the web, apprarently declared as working, but it doesn't.

<script src=''></script>
<title>Tesseract Test</title>
<label for="fileInput">Choose File to OCR:</label>
<input type="file" id="fileInput" name="fileInput"/>
<br />
<br />
<div id="document-content">
document.addEventListener('DOMContentLoaded', function(){
var fileInput = document.getElementById('fileInput');
fileInput.addEventListener('change', handleInputChange);

function handleInputChange(event){
var input =;
var file = input.files[0];
var contentArea = document.getElementById('document-content');

This is their main website:

Answer Source

Works for me, but I had to make this change:

.then(function(result) {
  var contentArea = document.getElementById('document-content');
  contentArea.innerHTML = result.text;

(The example you posted only logs to the console.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download