Browse Source

Updated download-pdf example for node to use new savePDF option

dev/v4
Balearica 2 years ago
parent
commit
81bf04c678
  1. 5
      examples/node/download-pdf.js

5
examples/node/download-pdf.js

@ -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();
})();

Loading…
Cancel
Save