-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Problem in Arabic text in dompdf #712
Comments
Are you saying the characters themselves are reversed or that you were expecting RTL and got LTR? I don't read Arabic and so am unable to really make much sense of the issue just looking at the PDF. At the very least seeing a PDF with the correct display would help. One thing you might try to see how it affects the render is to turn off font sub-setting (if enabled). To debug the issue we would want to be able to access the actual HTML and font used. |
Can you post the HTML in non-image format for easier replication in testing? |
I am sorry I did not know how to post html code without getting it parsed in the comment
|
No worries, markdown takes a little getting used to, but it's easy to pick up. Plus we can go in and edit issues/comments. |
any feedback regarding this problem ? |
Not yet. We'll need to perform additional testing on this issue before we can provide any specific feedback. This may be an issue of how the text is represented in the PDF and how it is mapped to the font glyphs. In which case we'll have to research the issue a bit more before we can work out a solution. |
ok , thank you |
@bsweeney, is this somewhat related to this old post I found? https://groups.google.com/forum/#!msg/dompdf/qfWb24ct7Ts/5_KKgc2ufqQJ I played around with it a bit, and it sortof seems to work, but I guess it never made it into the master branch? Is this still something you would recommend? |
@rjbijl I believe the RTL issue is a separate, but still valid, problem for dompdf. If you're looking for RTL support then, yes, give the advice in that discussion a try. This issue, if I am correct, is about the visual display of "words" in the PDF. The individual characters display correctly, but when combined into a word they should be linked (similar to cursive script in English). For some reason this is not happening. |
ok, my bad, I guess I got confused by the images. I'll try and see if I can come up with something decent regarding the RTL rendering, I do think that would be a real improvement for dompdf |
Thanks for this amazing library. TCPDF Library handled this problem for persian and arabic characters.I think you can take a look about it. |
Just small modification, hope you will enter it to the main : this code has to be insered into file dompdf/include/text_renderer.cls.php, before "$this->_canvas->text". and now the Hebrew/Ara bic is in the RTL direction. if (strtolower($style->direction) == 'rtl' && !mb_detect_encoding($text, array("ASCII"))) {
preg_match_all('/./us', $text, $ar);
$text = join('',array_reverse($ar[0]));
// if there are numbers in the string
// so the next line reverse the number back
// treat also numbers with dot (decimal) and email
$text = preg_replace_callback('/\d+-\d+|\d+|\d+\.\d+|\S+@\S+/', function (array $m) { return strrev($m[0]); }, $text);
} (this is improved solution from http://stackoverflow.com/questions/21201257/arabic-fonts-display-in-reverse-order-in-dompdf ) PLEASE BE AWARE that mb_detect_encoding is not working properly, maybee it good to use only the rtl condition. |
Hi , the best solution to support and fix arabic characters in dompdf Library you should integrate please follow these steps: 1- download the ar-php library for khaled.alshamaa from the following link 2 - extract and upload I18N folder inside dompdf folder 3- open Glyphs.php file in this path
search
replace to
4-in text_renderer.cls.php file before this line
add this code
also you should use any custom arabic font in your css file thanks |
@t3rep-com interesting, we'll definitely take a look! |
@t3rep-com , it is support Arabic, It is work perfectly Thank you a lot !! |
How can we make this work in version 0.7.0? I had to change 1 line to prevent an error: $Arabic = new \I18N_Arabic_Glyphs('Glyphs'); Located in /dompdf/dompdf/src/Renderer/Text.php (instead of /dompdf/include/text_renderer.cls.php) Unfortunately, my DOMPDF is not outputting 1 of the characters. When I var_dump the text (var_dump($text); exit;), I DO see the characters though. So for some reason, my DOMPDF is not rendering these characters (or this font?). Anyone knows what to do here? I'm using @t3rep-com method BTW, but for 0.7.0 as stated, not 0.6.x |
You are right, after hard word I moved my project to run with new library called mPDF, it is more stable and powerful in Arabic Language. :'( |
@ramonleenders maybe the font you are using not good for Renderer try using this font |
@t3rep-com OK, I extracted this .ttf into /dompdf/dompdf/lib/fonts I did not install any extra font. Should I have any other font related files? What should my (extra) CSS be, to render the font? I'm still getting blank output. I can attach a pic (picture), but it's empty. Normal/english characters DO render! So it's not a DOMPDF problem, it's just not rendering these characters/the font. My computer is full English and I have not installed any extra fonts, not on my computer not within DOMPDF (except the DINNextLTArabic-Medium you just provided). |
hi @ramonleenders
and add DINNextLTArabic-Medium.ttf in same style.css path |
Yeah, I'm using HTML and CSS. I used your code, added the .ttf and also added this
Still doesn't seem to work... Perhaps someone can set up a sample project where all this IS working? |
@ramonleenders you'll need to load the font into dompdf before it can actually be used. The loading process parses the font to generate the font metrics used for layout. You can load fonts using the load_font.php script or, as indicated by @t3rep-com, using the Take a look at the Unicode How-to for an overview of the process. |
OK, I figured out that if a div/span/element is in BOLD (font-weight: bold), it does not render the arabic characters. Is there a way to actually use bold font weight? Now I got that figured out, I need to know why this I18N_Arabic_Glyphs is replacing my "&" into "&;". Really annoying of course. Anyone else having this issue too? It's doing this in all cases, so in Arabic usage and normal usage. And one more thing, for some reason when using the I18N_Arabic_Glyphs class, it adds extra spaces before the actual text starts. This is without Arabic Glyphs: This is with Arabic Glyphs: |
It depends on how you are loading the font. If you're using
dompdf doesn't support psuedo-bold or psuedo-italic (i.e. faking it using the existing font), so if you don't have a separate font you would just specify the same font file. Something like:
|
OK, I will take care of the bold somehow. That's not my biggest issue. The other 2 seem to be disturbing, anyone knows what to do with them? As the Arabic language is all about aligning to the right, it's quite annoying if the characters have white space.. |
can you please guide me I'm trying this in CodeIgniter and error is such file doesn't exist |
Hey, i need your to help with this line |
saniya gazala khaled.alshamaa/ar-php Set of functionalities enable Arabic website developers to serve |
YES it was my silly mistake , its working fine now but the symbols are also moving to right eg : my parantheises should be like this () but there are like )( any suggestion sir |
Try specifying <html dir="rtl" lang="ar"> in your markup.
Le ven. 18 juin 2021 à 14:45, saniya gazala ***@***.***> a
écrit :
… saniya gazala ar-php/ar-php : This package is *abandoned* and no longer
maintained. The author suggests using the khaled.alshamaa/ar-php package
instead. khaled.alshamaa/ar-php Set of functionalities enable Arabic
website developers to serve professional search, present and process Arabic
content in PHP https://packagist.org/packages/khaled.alshamaa/ar-php good
luck
YES it was my silly mistake , its working fine now but the symbols are
also moving to right eg : my parantheises should be like this () but there
are like )( any suggestion sir
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#712 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFRYQPOHAQXPSXWP4GFVRATTTNEY3ANCNFSM4AHZDG5A>
.
|
No luck |
i don't want to change the entire pdf to arabic just a part of it , |
Juste try with div
<div dir='rtl'>.......</div>
Le sam. 19 juin 2021 à 11:34, saniya gazala ***@***.***> a
écrit :
… Try specifying in your markup. Le ven. 18 juin 2021 à 14:45, saniya gazala
*@*.***> a écrit :
… <#m_7541740580272018901_>
saniya gazala ar-php/ar-php : This package is *abandoned* and no longer
maintained. The author suggests using the khaled.alshamaa/ar-php package
instead. khaled.alshamaa/ar-php Set of functionalities enable Arabic
website developers to serve professional search, present and process Arabic
content in PHP https://packagist.org/packages/khaled.alshamaa/ar-php good
luck YES it was my silly mistake , its working fine now but the symbols are
also moving to right eg : my parantheises should be like this () but there
are like )( any suggestion sir — You are receiving this because you were
mentioned. Reply to this email directly, view it on GitHub <#712 (comment)
<#712 (comment)>>, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AFRYQPOHAQXPSXWP4GFVRATTTNEY3ANCNFSM4AHZDG5A
.
i don't want to change the entire pdf to arabic just a part of it ,
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#712 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFRYQPMP43T6BUETMQCLZYTTTRXE3ANCNFSM4AHZDG5A>
.
|
don't forget the requirements of dompdf
Requirements
- PHP version 7.1 or higher
- DOM extension
- MBString extension
- php-font-lib
- php-svg-lib
Note that some required dependencies may have further dependencies (notably
php-svg-lib requires sabberworm/php-css-parser).
Recommendations
- OPcache (OPcache, XCache, APC, etc.): improves performance
- GD (for image processing)
- IMagick or GMagick extension: improves image processing performance
Le sam. 19 juin 2021 à 12:34, saniya gazala ***@***.***> a
écrit :
… Try specifying in your markup. Le ven. 18 juin 2021 à 14:45, saniya gazala
*@*.***> a écrit :
… <#m_-1473708801261247347_>
saniya gazala ar-php/ar-php : This package is *abandoned* and no longer
maintained. The author suggests using the khaled.alshamaa/ar-php package
instead. khaled.alshamaa/ar-php Set of functionalities enable Arabic
website developers to serve professional search, present and process Arabic
content in PHP https://packagist.org/packages/khaled.alshamaa/ar-php good
luck YES it was my silly mistake , its working fine now but the symbols are
also moving to right eg : my parantheises should be like this () but there
are like )( any suggestion sir — You are receiving this because you were
mentioned. Reply to this email directly, view it on GitHub <#712 (comment)
<#712 (comment)>>, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AFRYQPOHAQXPSXWP4GFVRATTTNEY3ANCNFSM4AHZDG5A
.
i don't want to change the entire pdf to arabic just a part of it ,
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#712 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFRYQPMP43T6BUETMQCLZYTTTRXE3ANCNFSM4AHZDG5A>
.
|
thank you so much it really helped. |
I use your solution before loading html but it looks messed up for sure have a look it is showing word "ﺓﺭﻮﺗﺎﻔﻟﺍ ﻢﻗ" instead of "رقم الفاتورة" also in pdf i'm attaching screenshot |
Going to close this ticket in favor of 2619 as the tracking ticket for the necessary functionality but will review comments here as we build out better support for Arabic. |
@bsweeney got a solution LaravelDaily/laravel-invoices#78 (comment) |
Thanks, It works for me. I have used this with laravel 8.x like this Installed package using composer
Then integrated code (as mentioned above) with controller method
|
Works fine for me, thank you 🙏 |
Solution is here |
شكرا لك ع الخطوات السهله https://drive.google.com/file/d/1lvh6-eDGgOfwRI5Ri7zviavfFCjsEF0f/view?usp=sharing |
فقط قم باضافة التالي: Arabic->utf8Glyphs($text, 50, false, false) كما هو موضح بالشرح /** |
Thank you very much dude, this, using the DejaVu Sans font, works perfectly with arabic text |
Work thank you 👌🏻 |
For Arabic script you can usee Khaled Al Shamaa ar-php see this way it's working |
I went to unicode discussion and googled it and looked for it in stackverflow
I did everything you recommended from using standard meta tag with content type and charset to loading font that supports arabic
and the result was I got arabic letters separated from each other and reversed
so plz let me know If you have really a serious issue regarding supporting arabic text ??
please refer to attached image
The text was updated successfully, but these errors were encountered: