galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.14k stars 169 forks source link

Not able to read the pdf file #442

Open kalyanipullela opened 4 years ago

kalyanipullela commented 4 years ago

Hello @galkahana ,

I have tried to read the uploaded pdf using nodejs, but the response of the uploaded file is getting empty. Below is the following code I have used

var app = express();
app.get('/', function(req, res){
    res.writeHead(200, {'Content-Type': 'application/pdf'});
    console.log("hey",__dirname)
    var pdfParser = hummus.createReader(__dirname +'/appointments.pdf'); // the path to the pdf file
    console.log("pdfParser", pdfParser)
  });
app.listen(3000);

The pdfParser returns an empty object. Can anyone tell what's wrong with it and help me out to use this package

Thank you

freebeans commented 4 years ago

Hi!

It seems to be the correct behaviour, since, by my newbie looks, PDFReader's class doesn't implement the .toString() method. You won't be able to use console.log() like this.

What exactly you want to do?

kalyanipullela commented 4 years ago

Thank you @freebeans

I want to read the PDF which contains form fields, and then add the data to the form fields given in the PDF and generate new PDF

schemar commented 4 years ago

@kalyanipullela see here.