javascript - how to convert pdf to .txt and .txt to json by using node.js -
i have pdf file want extract fields pdf , convert them .json file. have looked @ couple npm packages pdfjs, pdf2json. tried many ways found throughout search.i cant figure out how convert pdf json file.can tell me how figure out this.i can able convert text json file if can tell function of pdf text helpful me..
pdf txt
https://www.npmjs.com/package/pdf-to-text
use this:
var pdfutil = require('pdf-to-text'); var pdf_path = "absolute_path/to/pdf_file.pdf"; //option extract text page 0 10 var option = {from: 0, to: 10}; pdfutil.pdftotext(upload.path, option, function(err, data) { if (err) throw(err); console.log(data); //print text }); //omit option extract text pdf file pdfutil.pdftotext(upload.path, function(err, data) { if (err) throw(err); console.log(data); //print text });
txt json
https://www.npmjs.com/package/text-2-json
run command command line. example:
node index.js --i=test/test.txt --o=test/output.json --h
Comments
Post a Comment