CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Hebrew in PDF Labels
Pages: [1]

Author Topic: Hebrew in PDF Labels  (Read 9382 times)

FredJones

  • Guest
Hebrew in PDF Labels
August 13, 2007, 02:03:34 am
I now have the Hebrew correctly displaying in the browser in my V1.8 install.

Now we are trying to print labels and in the PDF the Hebrew comes out as garbage once again. :(

Any ideas? If not I will try to recreate what I did for our v1.4: Since none of the labels matched our physical labels, I added an option to the Contact Search Results dropdown which created an RTF file for downloading, custom built to match our labels. Even there, however, I had to figure out the RTF symbols for the Hebrew characters and use a character mapping to convert them.

Thanks.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Hebrew in PDF Labels
August 13, 2007, 10:10:50 pm
I ran some tests and it seems the font we use for the PDF file does not cover Hebrew characters; an address with both Polish and Hebrew characters displays the Polish characters properly and the Hebrew ones as empty boxes. :(

We’re using the DejaVu Sans font for the PDF creation. It seems there’s a new release of the fonts – I’ll see whether it has a better Hebrew support. I filed this as CRM-2197.

If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

FredJones

  • Guest
Re: Hebrew in PDF Labels
August 14, 2007, 02:04:33 am
Thanks for your help. So either we move the NPO to Poland or we must find a solution for the Hebrew, eh? :)

Can I ask:

1. What sort of time frame do you think is involved for this ticket fix? I know you don't know, but from experience is this a matter of a week or 3 months?

2. Would it be feasible for me to experiment myself with other fonts? If so, could you give me a clue where to begin muddling with this? I would be happy to try.

Thanks.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Hebrew in PDF Labels
August 14, 2007, 02:46:12 am
I upgraded DejaVu Sans on the 1.8 branch to the current upstream (2.19) and can now see Hebrew in my PDF labels. This will be in the next 1.8 tarball later this week; if you need this earlier, go to http://svn.civicrm.org/branches/v1.8/packages/ufpdf/font/ and grab the DejaVuSans.ctg.z, DejaVuSans.php and DejaVuSans.z files from there (and put them in your CiviCRM’s packages/ufpdf/font directory).

Now, if this indeed fixes things for you, we’d be really happy if you could contribute the time saved on experiments to helping out with the Hebrew translation. :)
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

FredJones

  • Guest
Re: Hebrew in PDF Labels
August 19, 2007, 01:45:27 am
It works perfectly AND we did put in some time translating. :)

Thank you!

FredJones

  • Guest
Re: Hebrew in PDF Labels
August 19, 2007, 03:08:33 am
I spoke too soon. It doesn't actually work.

While it DOES show Hebrew characters correctly, it shows them RTL whereas Hebrew is LTR so I am seeing:

derF

instead of

Fred

for each Hebrew word. :(

I poked around the code and in \CRM\Contact\Form\Task\Label.php just before the line

Code: [Select]
$pdf->AddPdfLabel($val);

the Hebrew characters appear to be in the correct order, at least if I do an echo to the browser of $val. Seems to be the next step that corrupts it.
« Last Edit: August 19, 2007, 12:15:19 pm by FredJones »

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Hebrew in PDF Labels
August 19, 2007, 09:45:47 pm
I investigated it for a bit and indeed UFPDF (which is a UTF-8-support hack over FPDF) does not seem to support the directionality property of Unicode characters. :|

I filed CRM-2211 to track this issue, but it won’t get fixed for CiviCRM 1.8 (which went stable).

The only approach I came up with so far is to reverse the Hebrew lines on PHP side; this can be done with the following (assuming $line does not have any non-Hebrew, non-digit characters, so can be reversed as a whole):

Code: [Select]
<?php
preg_match_all
('/(\d+)?./us', $line, $ar);
$line = join('',array_reverse($ar[0]));
?>


It’s a crude hack, but seems to make UFPDF reverse the Hebrew strings.
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

FredJones

  • Guest
Re: Hebrew in PDF Labels
August 20, 2007, 12:19:11 am
Yes, I came to the same conclusion last night--that I would probably need a hack. I began along the same lines as you. The data itself is often mixed, however, with English and Hebrew so I must break it into words, check each word for Hebrew characters (and if so, then flip it) and then rebuild the string.

Your code actually DID help, BTW, as it fixed one error on my code.

Anyhow I have it now 90% working.

Thank you.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Hebrew in PDF Labels
August 20, 2007, 03:38:05 am
Actually, to go this way it’d be best to get the Unicode ranges of all right-to-left characters (if I understand that properly, directness is a property of a Unicode codepoint), scan the lines for groups of such characters and then flip them in the above manner.

Do let us know what’s the final solution that works for you, as I’d gladly add it to the next CiviCRM release.
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

FredJones

  • Guest
Re: Hebrew in PDF Labels
August 20, 2007, 03:42:23 am
Quote from: Piotr Szotkowski on August 20, 2007, 03:38:05 am
Actually, to go this way it’d be best to get the Unicode ranges of all right-to-left characters (if I understand that properly, directness is a property of a Unicode codepoint), scan the lines for groups of such characters and then flip them in the above manner.

I imagine that's correct, but I have limited knowledge of Unicode.

Quote from: Piotr Szotkowski on August 20, 2007, 03:38:05 am
Do let us know what’s the final solution that works for you, as I’d gladly add it to the next CiviCRM release.

At this point I think I will return to my custom RTF solution, because we are also having other problems with the labels. And the RTF I know matches our label paper perfectly. :)

Thanks.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Hebrew in PDF Labels
October 31, 2007, 07:21:27 am
FWIW, I managed to force UFPDF to display the strings properly by binding to FriBidi using the PECL fribidi package (there’s a bug in the package that makes it uninstallable on Ubuntu/Debian systems but is easily fixable). The relevant issue is CRM-2211, the fix is in r12024.
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

FredJones

  • Guest
Re: Hebrew in PDF Labels
October 31, 2007, 07:38:43 am
I don't recall today what happened, but someone provided me a fix some months ago. It works for us anyhow. :)

I think it was in another thread here somewhere...

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Hebrew in PDF Labels

This forum was archived on 2017-11-26.