wojtekmaj / react-pdf

Display PDFs in your React app as easily as if they were images.
https://projects.wojtekmaj.pl/react-pdf
MIT License
9.11k stars 867 forks source link

The customTextRenderer function is not called for the page if PDF file has links in that page (reference paragraph in same pdf) #1661

Closed ShubhamSingh19 closed 5 months ago

ShubhamSingh19 commented 9 months ago

Before you start - checklist

Description

The customTextRenderer function is not called for the page if PDF file has links in that page (reference paragraph in same pdf). Else it is working normal, highlighting conditional text.

Steps to reproduce

  1. Display a PDF that has links on few pages.
  2. Use customTextRenderer as <Page customTextRenderer={textRenderer}></Page>
  3. Mark every page (whole) using textRenderer function, sample below. const textRenderer = useCallback( (textItem) => <mark>{textItem}</mark>, [pageNumber] );
  4. You will see that pages with links will not be marked as customTextRenderer function is not called for that page. Other normal pages are marked properly.

Expected behavior

All pages should be marked. Even with links.

Actual behavior

Pages that contain link do not highlight the text layer.

Additional information

"react-pdf": "^7.3.3",

Environment

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

wojtekmaj commented 5 months ago

First of all, this code can't work - the correct way to mark every single text would be:

  const customTextRenderer = useCallback(
    (textItem: { str: string }) => `<mark>${textItem.str}</mark>`,
    [],
  );

Secondly, I couldn't reproduce that with my test PDFs. Therefore I'm going to close this for now until a reproducible example is provided. Thanks for understanding.