|
|
|
@ -12,10 +12,9 @@ console.log(`Recognizing ${image}`);
@@ -12,10 +12,9 @@ console.log(`Recognizing ${image}`);
|
|
|
|
|
const worker = await createWorker(); |
|
|
|
|
await worker.loadLanguage('eng'); |
|
|
|
|
await worker.initialize('eng'); |
|
|
|
|
const { data: { text } } = await worker.recognize(image); |
|
|
|
|
const { data: { text, pdf } } = await worker.recognize(image, {savePDF: true}); |
|
|
|
|
console.log(text); |
|
|
|
|
const { data } = await worker.getPDF('Tesseract OCR Result'); |
|
|
|
|
fs.writeFileSync('tesseract-ocr-result.pdf', Buffer.from(data)); |
|
|
|
|
fs.writeFileSync('tesseract-ocr-result.pdf', Buffer.from(pdf)); |
|
|
|
|
console.log('Generate PDF: tesseract-ocr-result.pdf'); |
|
|
|
|
await worker.terminate(); |
|
|
|
|
})(); |
|
|
|
|