0

Here I tried to extract and set the texts in one state, but I'm not able to console the text

const [text, setText] = useState('')

useEffect(() => {
    
    fetch('Docs/Introduction.pdf').then(res=>{
     let texts =  res.text()
    setText(texts)
    })

  }, [])

**console.log(text);**

But in console, I'm getting,

enter image description here

Here I need to get the all texts in texts state

Labeeb OPC
  • 21
  • 7
  • A PDF isn't a simple plain-text file, I'm afraid extracting text isn't that easy. Here's a question covering it: [How to extract text from a PDF in JavaScript](https://stackoverflow.com/questions/1554280/how-to-extract-text-from-pdf-in-javasript) – DBS Aug 08 '22 at 10:20
  • The text retrieved in the result represents the PDF data, which is contained within a byte array. In order to extract meaningful text from this data, you will have to parse the PDF structure and extract the text within. One way you could do this is by using the LEADTOOLS Document Toolkit which provides several approaches to [Parsing Text](https://www.leadtools.com/help/sdk/v22/dh/javascript/to/parsing-text-with-the-document-library.html) from PDF. (Disclaimer: I am an employee of the vendor) – Hussam Barouqa Aug 17 '22 at 13:35

0 Answers0