-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Browser Arabic Reading Inconsistent after update_page_form_field_values #1874
Comments
Can you please provide the pypdf version |
If the behavior changes between the viewers, it means that the NeedAppearance flag does not have the same behavior on the different applications. |
pypdf version: 3.9.1 , i used multiple fonts supporting RTL like Adobe Arabic but also fails. Could you clarify further what you mean by "The solution would be to generate the appearance in the PDF." @pubpub-zz Thank you for the efforts! |
I've bee a little too fast. As said, you should check that you can complete / modify your empty form to embody a compatible font. |
@yassinsameh ok to close this issue or do you have an upgraded PDF? |
Apologies for my late reply, Here is a pdf github_issue_sample.pdf |
@pubpub-zz Hello, any other info i can provide to help? |
Many fonts will not be able to handle arabic |
Hi! I have previously filled out PDF forms with Arabic text and had the exactly same problem. The issue is not on pypdf's side, but with the way Python treats Arabic. Since Arabic is written with letters connected together, it means that the letters next to each letter determine how it will look like and those are called ligatures (a specific rendering of a letter). Python by default treats Arabic exactly the same way as it does English - character by character, while ignoring the different ways the letters need to be rendered to make coherent words and thus the text comes out broken. To fix this, you need to use a package called arabic_reshaper, that will take the letters and turn them into the appropriate ligatures and make the text nice and connected. To fix it being the other way around you need to use bidi package: It kinda looks like this in the end:
Very important to keep ENABLE_ALL_LIGATURES, so that all Arabic special ligatures will work. |
@arvo95 Are you interested in adding your example to the docs for further reference? Feel free to submit a corresponding PR in this case. |
After using update_page_form_field_values to update certain fields, some browsers read the filled arabic fields incorrectly (Unformatted and Reversed):
Expected: ياسين حسام , Result in some cases : م ا س ح ن ي س ا ن(Reversed and as if there are spaces)
To clarify further, the Form arabic text itself is read correctly however the filled text using update_page_form_field_values is not.
Working on: Chrome Mobile, Safari Mobile, Safari Web, Edge Mobile
Not Working: Chrome Web, Edge Web
This is a minimal, complete example that shows the issue:
PDF Sample:
github_issue_sample.pdf
The text was updated successfully, but these errors were encountered: