react-pdf-highlighter icon indicating copy to clipboard operation
react-pdf-highlighter copied to clipboard

How to get the loading status?

Open alex6liu opened this issue 4 years ago • 3 comments

I want to do something after the PDF loaded successfully. Anyway to get the loading status? One more thing, when I try to use document.querySelectorAll('span'), it seems that I can only get the spans in first page and rest pages are null. What's the reason and how can I make them render at the same time?

alex6liu avatar Dec 28 '20 03:12 alex6liu

Yeah, it is not straightforward. You can create a local component and put it under <PdfLoader> and fire a callback as soon as you receive pdfDocument.

I'll also accept a PR with the loading callback status for ./packages/react-pdf-highlighter/src/components/PdfLoader.js.

The rendering is done by PDF.js and it is done in a lazy way to have good performance on large files.

agentcooper avatar Jan 10 '21 19:01 agentcooper

I had success with this:

const [node, setNode] = useState(null)
const onRefChange = useCallback(n => {
    if (n)
      setNode(true)
  }, [])

// useEffect with dependency [node]
...
<PdfHighlighter
  scrollRef={scrollTo => {
      scrollViewerTo.current = scrollTo
      onRefChange(scrollTo)
   }}
...

LydiaF avatar May 10 '22 16:05 LydiaF

您好 您的邮件已收到我会尽快处理!

alex6liu avatar Oct 11 '22 07:10 alex6liu