UNPKG

ocr

Version:
60 lines (56 loc) 2.48 kB
// *******************************************************************' // Copyright 1996-2018 Accusoft Corporation. All rights reserved. *' // This sample code is provided to Accusoft licensees "as is" *' // with no restrictions on use or modification. No warranty for *' // use of this sample code is provided by Accusoft. *' // *' // SAMPLE PURPOSE *' // *' // This sample illustrates how to read in multiple text-based image *' // and export that data to memory, using Accusoft's OCR Xpress. *' //****************************************************************** *' var ocrx = require('ocr'); require('ocr-lang-eng'); params = {}; // Get command line input. if (process.argv.length != 4) { console.log('********************************************************************'); console.log('Usage: \t\t' + 'node multipage.js <inputFile1> <inputFile2>'); console.log('Example:\t\t' + 'node multipage.js ../images/color.bmp ../images/text.bmp'); console.log('Run Example by default:\t' + 'node multipage.js ../images/color.bmp ../images/text.bmp'); console.log('********************************************************************'); // Set default value params.input = '../images/color.bmp'; } else { params.input = process.argv[2]; } // Initialize any licensing that needs to be set. // ocrx.setSolutionName('<Solution name goes here>'); // ocrx.setSolutionKey(0x01234567, 0x01234567, 0x01234567, 0x01234567); // Recognize the input images to memory. ocrx.recognize(params, function(err, document){ if (err) { console.error(err); } else { params.document = document; if (process.argv.length != 4) { params.input = '../images/text.bmp'; } else { params.input = process.argv[3]; } ocrx.recognize(params, function(err, document) { if (err) { console.error(err); } else { console.log(' === Print out the 1st page text === '); console.log(document.getPages()[0].text); console.log('\n === Print out the 2nd page text === '); console.log(document.getPages()[1].text); } }); } });