0

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

  • Yes it does help. Thank you so much. Now the entire content is in a single field. I now to figure out how to extract pieces of information from the entire text. – Sanat Gupta Feb 02 '22 at 11:46

0 Answers0