Reading PDF file using javascript

后端 未结 2 1051
囚心锁ツ
囚心锁ツ 2020-12-05 15:24

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 progra

相关标签:
2条回答
  • 2020-12-05 15:41

    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);
    });
    
    0 讨论(0)
  • 2020-12-05 16:04

    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.

    0 讨论(0)
提交回复
热议问题