pdf-lib icon indicating copy to clipboard operation
pdf-lib copied to clipboard

numbers are reversed in rtl strings

Open oridavidov opened this issue 6 years ago • 4 comments

Hello, i am trying to draw some rtl text (hebrew) using the drawText() function. i embedded a custom font, but in the final pdf, the numbers in the string (if exist) are getting reversed, and only the numbers, the hebrew text is fine, for ex: "בלה בלה 1234" will be draw as "בלה בלה 4321". i there a simple solution to this issue? Thanks, Ori

oridavidov avatar May 16 '20 21:05 oridavidov

Hello @oridavidov!

Apologies for the late response. I'm afraid I don't fully understand what is going on from the information you've provided. If you're still having trouble, please reopen this issue with some code and fonts that I can use to reproduce the problem.

Hopding avatar Sep 20 '20 20:09 Hopding

hey getting this error too, how do you solve it?

HodayaGruz avatar Dec 14 '21 16:12 HodayaGruz

@Hopding this issue still remains. To reproduce:

form.getTextField(field.name).setText(value);

set value to "כתובת 12345"

It will set the field value correctly, but once you call form.updateFieldAppearances(font); the value prints with the digits backwarded: "כתובת 54321"

It's just "Address 12345" resulting in "Address 54321".

Tests:

  1. Several different fonts - Fail.
  2. Hebrew with no spaces - Fail
  3. Same font but in English - OK.
  4. Hebrew but only digits(no text e.g. "12345") - OK.

Fonts used: Open serif

I briefly went over the code and couldn't find the reason, tried exploring the fontkit as well but no success.

zeev-js avatar Feb 02 '22 23:02 zeev-js

@zeev-js Any progress with this? How did you solve the issue?

shrestharohit avatar Jan 10 '24 06:01 shrestharohit