i want to export text pdf to json using nodejs pdf-parse but when exported it gives a compressed json. The json generated is invalid when read from a reader. How can i generate a valid json
The code i am using:
const fs = require('fs');
const pdf = require('pdf-parse');
let dataBuffer = fs.readFileSync('./test.PDF');
pdf(dataBuffer).then(function(data) {
console.log(data);
// // PDF text
var json = JSON.stringify(data);
fs.writeFile('myjsonfile.json', json, 'utf8', function (err) {
console.log(err)
});
});
thank you