Closed dsernst closed 5 years ago
@nisaacson would you welcome a PR to fix this? I have a working version:
const path = require("path")
const pdf_extract = require('pdf-extract')
console.log("Usage: node thisfile.js the/path/tothe.pdf")
const absolute_path_to_pdf = path.resolve(process.argv[2])
if (absolute_path_to_pdf.includes(" ")) throw new Error("will fail for paths w spaces like "+absolute_path_to_pdf)
const options = {
type: 'ocr', // perform ocr to get the text within the scanned image
ocr_flags: ['--psm 1'] // automatically detect page orientation
}
const processor = pdf_extract(absolute_path_to_pdf, options, ()=>console.log("Starting…"))
processor.on('complete', data => callback(null, data))
processor.on('error', callback)
function callback (error, data) { error ? console.error(error) : console.log(data.text_pages[0]) }
sure
Here's an example you give:
But the npm package
eyes
was never installed, andcallback
(called 3 times) is undefined.