Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

customTextRenderer is not called #1593

Closed
4 tasks done
mixeden opened this issue Aug 11, 2023 · 4 comments · Fixed by #1623
Closed
4 tasks done

customTextRenderer is not called #1593

mixeden opened this issue Aug 11, 2023 · 4 comments · Fixed by #1623
Labels
bug Something isn't working

Comments

@mixeden
Copy link

mixeden commented Aug 11, 2023

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

Well, customTextRenderer is not called!

My guess is because of this particular line:
https://github.com/wojtekmaj/react-pdf/blob/v7.3.3/src/Page/TextLayer.tsx#L222

It seems that this layer has some marked content, but it is above the text I'm talking about (see "steps to reproduce").
It should not affect the text being rendered in any way.

Steps to reproduce

  1. Load this https://arxiv.org/pdf/1905.09263.pdf, navigate to page 4, check if your customTextRenderer is called on a text that starts with "sequence in speech tasks. We evaluate", for example.

Expected behavior

customTextRenderer is called

Actual behavior

customTextRenderer is not called

Additional information

No response

Environment

  • Browser (if applicable):
  • React-PDF version:
  • React version:
  • Webpack version (if applicable):
@mixeden mixeden added the bug Something isn't working label Aug 11, 2023
@picasocro1
Copy link

picasocro1 commented Aug 21, 2023

I have exactly the same problem. For this particular pdf defined customTextRenderer is not called.

The method was executed correctly on the other pdf I worked on so far (using exactly the same code).

Environment

  • Browser (if applicable): Chrome ver. 116

  • React-PDF version: 7.3.3

  • React version: 18.2.0

  • Webpack version (if applicable): -

@mixeden
Copy link
Author

mixeden commented Aug 21, 2023

What is even more funny, it works on the majority pages of the PDF I attached in the reproduction section except a page number 4. I guess this is because this particular page had elements with class name "markedContent" in it somewhere to the top. Please check if your PDF from Volvo also has elements with the same class name in problematic places

@frontendphil
Copy link

Yup, I can confirm that marked content seems to have something to do with it. AFAICT, the moment this lib sees .markedContent, it assumes that all text of that layer is inside the .markedContent element. However, in our case, these are just empty blocks. https://github.com/wojtekmaj/react-pdf/blob/main/packages/react-pdf/src/Page/TextLayer.tsx#L207

@hdwatts
Copy link
Contributor

hdwatts commented Sep 22, 2023

Yes having this same issue with markedContent!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants