Skip to content Skip to sidebar Skip to footer

Reading PDF File Using Javascript

I'm currently developing an application that would Copy/Transfer a sentence/paragraph from a PDF file to my program. I'm using Javascript to develop my program but I have not found

Solution 1:

I know that the question is old, but if you find PDF.js too complex for the job, npm install pdfreader. (I wrote that module)

It would take 5 lines of code to extract text from your PDF file:

var PdfReader = require("pdfreader").PdfReader;
new PdfReader().parseFileItems("sample.pdf", function(err, item){
  if (item && item.text)
    console.log(item.text);
});

Solution 2:

Check out PDF.js, it's a commonly used JavaScript library that contains a lot of methods for PDF manipulation.

Check out this answer to see a demonstration of how to extract text using pdf.js.


Post a Comment for "Reading PDF File Using Javascript"