Reading a pdf file using javascript

I am currently developing an application that will Copy/Transfer a sentence/paragraph from a PDF file to my program . I use Javascript to develop my program, but I did not find an idea on how to read a PDF file.

I want to know how to copy / transfer sentence / paragraph from a PDF file to my program?

Thanks.

+6
source share
2 answers

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

To extract text from a PDF file, you need 5 lines of code:

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

Check out PDF.js , this is a commonly used JavaScript library that contains many methods for handling PDF.

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

+3
source

Source: https://habr.com/ru/post/923445/


All Articles