1

We need to extract text from pdf file in React native. Please suggest me any library or source code.

Hari krishna
  • 29
  • 1
  • 4
  • https://stackoverflow.com/questions/57435198/how-to-extract-content-from-pdf-file-in-react-native – Ken Lee Dec 22 '20 at 05:58
  • RNFS.readAsync is not a function – Hari krishna Dec 22 '20 at 06:43
  • If we use pdf-parse library, we are getting 'fs could not be found' – Hari krishna Dec 22 '20 at 07:03
  • Some days ago I needed to extract text from pdf file using react-native, I try some libraries but none worked like expected for me, therefore I started create a new one library to extract texts from pdf using regex, this is on initial stage but could be util. https://1fabiopereira.github.io/react-native-pdf-extractor/ – 1fabiopereira Jun 19 '22 at 22:43

1 Answers1

0

You can use react-native-pdf2json repo to read pdf content into json like

let fs = require('fs'),
PDFParser = require("pdf2json");

let pdfParser = new PDFParser();

pdfParser.on("pdfParser_dataError", errData => console.error(errData.parserError) );
pdfParser.on("pdfParser_dataReady", pdfData => {
     fs.writeFile("./pdf2json/test/F1040EZ.json", JSON.stringify(pdfData));
});

pdfParser.loadPDF("./pdf2json/test/pdf/fd/form/F1040EZ.pdf"); 

You can also use react-native-pdf-lib

Nooruddin Lakhani
  • 7,507
  • 2
  • 19
  • 39