-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix: copy paste for registered font #2408
Conversation
|
So seems that some fonts cause issues when they are copied and pasted. And ATS software reads text that way probably so I needed to fix it. Otherwise I'd be stuck with default fonts. I've created this patch package based on this pending PR diegomura/react-pdf#2408 that fixes the issue so now I can use any font!
Please @diegomura have a look at this PR if you have some time. This has been a very problematic issue for us :( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks good to me comparing to latest pdfkit.Will try to test it today and merge it
@diegomura I also got this issue, waiting for next release 🙏🏻 |
@chihyux I have used your PR and customized it into a separate node module, and it works 100%. I really appreciate that 💯 |
Was anyone able to monkey patch this with patch-package by any chance? 🤔 or deployed a forked package to NPM? Found the code on the |
@hazem3500 If you haven't already got it to work, I have it in Thanks for the code @chihyux ! |
EDIT: Actually did not solve it. What helped: go to https://www.tophix.com/font-tools/font-editor just import/export the font and everything seems to work. |
I use the |
+1 waiting on this |
What was mentioned by @teq-vunguyen worked for me as well. I had to do this since bun was not happy with patch-package, but overall everything went good. Also thanks to @sandeepdotcode's patch. Let's get this merged! Probably many resume websites are having issues due to this 🤯 |
Do we have plans in merging this PR asap? I'm facing some weird copy+paste issues right now, and it'd be awesome to have it fixed 😄 |
When will this be merged? |
Let's merge this bad boy |
Hello! Thank you for creating this package. My company has chosen this package, and I encountered an issue when using a custom font where copying text results in garbled characters. I have also noticed that there are many similar issues in the repository, where the characters copied from the generated PDF are different from what is displayed on the screen.
I have found that the package uses an older version of pdfkit, and based on the code in the latest version of that package, the following function is no longer used:
The reason for this change is that the function was producing duplicate Unicode values, leading to consecutive or incorrect characters in the cmap and resulting in garbled text when copying.
Additionally, when using this package in my country, which uses Chinese characters, copying text from the generated document in Chrome and Edge browsers can also result in garbled characters when there are a large number of Unicode characters. I suspect that this is because the original implementation
toUnicodeCmap
usedbfrange
for generating Unicode mappings for glyphs, and when there are many Unicode characters(more than 244 characters), the browser cannot correctly interpret the corresponding Unicode values. To address this issue, I suggest changing the cmap implementation to usebfchar
, which resolved the problem.