openhtmltopdf icon indicating copy to clipboard operation
openhtmltopdf copied to clipboard

Arabic and English words get mixed up when together in one line

Open kenneth-apuyan opened this issue 1 year ago • 2 comments

This issue happens when the line starts with arabic followed by english words. They interchange places or get all mixed up. I already applied the below code : PdfRendererBuilder builder = new PdfRendererBuilder(); builder.useUnicodeBidiSplitter(new ICUBidiSplitter.ICUBidiSplitterFactory()); builder.useUnicodeBidiReorderer(new ICUBidiReorderer()); builder.defaultTextDirection(BaseRendererBuilder.TextDirection.LTR);

kenneth-apuyan avatar Mar 09 '23 05:03 kenneth-apuyan

This seems to be the same issue as discussed in #432. I have experienced this issue before and the solution I have described here has fixed the issue for me. So, in your case, the "RTL here" should be replaced with your Arabic text, "LTR here" with your English insertions.

a-leithner avatar Mar 09 '23 10:03 a-leithner

This seems to be the same issue as discussed in #432. I have experienced this issue before and the solution I have described here has fixed the issue for me. So, in your case, the "RTL here" should be replaced with your Arabic text, "LTR here" with your English insertions.

Thanks :D. It worked on some parts of my template. Sadly, this seems to works only if you know what texts are LTR and RTL i.e. static text. For dynamic text, i.e. provided by a user that will then be embedded to the html template, you don't have any control on it so it could be an arabic text, an english text or a mixed of both. You can't separate them via spans with the LTR/RTL beforehand.

kenneth-apuyan avatar Mar 09 '23 13:03 kenneth-apuyan