react-pdf: Text copied from PDF is sometimes incorrect
Describe the bug
When text in PDF contains string fi the resulting document is bit broken - when text is copied, it is not matching text visible in PDF. I suspect this is because fi is ligature? It happens with different fonts, but not with those which are built-in.
Expected behavior Copied text matches PDF document
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 12
- Comments: 21 (2 by maintainers)
If someone else is using google fonts I also managed to fix the fonts using fontforge with the following command
I think we can close this bug as there are some easy workarounds
In my case suspect is font file.
After downloading font from another source and import in OpenSource BirdFont free software and export and use in my website.
It’s working as expected. Hope it helps someone 😃
June 7th Edit: This is still not fully functioning, some letters are wrong.
I also tried the following other solutions:
@diegomura it would be nice to understand a bit more about what could be causing this issue as this it preventing our users to search in the PDF we are providing them.
I just found out about this issue today while copy-pasting some text on my PDF (also found this related issue https://github.com/diegomura/react-pdf/issues/1950 - not sure if its worth keeping these 2 issues open since they look the same)
Here is my fix if it can help anyone:
I’m not sure how React-pdf uses the fonts to generate PDFs but given that I use the same font for my website and it works fine, it does look like this issue is specific to React-pdf and hopefully will get fixed
I had the same problem and I solved it using the method mentioned in the comment above with ‘BirdFont’. However, it seems like there might be a way to solve it without modifying the font. Check out this https://github.com/Hopding/pdf-lib/issues/245.
Any progress on that ? 🙏
@LukaszMiskowiak and @jasiekkrk, There are other issues here like #629 that mention downloading the BirdFont software. I had the same issue using the Roboto font where
fiwas not working correctly. After purchasing the commercial Birdfont software for 4.99 USD, I was able to import the font, and export it with default settings and now works just fine.This was fixed in #2408 / #2488. The test case in the REPL now works correctly. This issue can be closed.
Exporting SourceHanSans with BirdFont did not fix all my issues. Some text copies correctly, but many do not.
I also have the same issue with fonts like Inter.