Hello Jamal,
Thanks for using our plugin.
When RTL support is enabled, numbers, letters, and brackets adhere to RTL rules, resulting in their reversal as well. This ensures comprehensive RTL support throughout the content.
We are always here to assist you.
Best Regards
Thanks for your reply. Can you please confirm the following statement?
If RTL is enabled, Even the content is LTR (for Example, English), Numbers, letters and brackets will looks like RTL, when downloading the PDF. Is that correct?
We are using Arabic (RTL) and English (LTR) with the WPML plugin and some other languages. Can you advise me to overcome this issue? Without RTL support we would not be able to download the Arabic content.
Jamal
Hello,
It seems like you’re discussing a modification to the PDF generation process for WordPress, particularly with regards to handling RTL (right-to-left) text and mixed content (including Arabic characters, numbers, and letters) in the PDF template files. If you want to enhance the functionality to only apply RTL formatting to Arabic characters while leaving other characters unchanged, you can modify the logic as follows:
php // pdf-generator-for-wp/package/lib/dompdf/vendor/dompdf/dompdf/src/Renderer/Text.php // line no 83 if (strtolower($style->direction) === 'rtl') { // Separate Arabic characters from the text using a regular expression preg_match_all('/[\p{Arabic}]/u', $text, $arabicCharacters); // Reverse Arabic characters and keep other characters unchanged $text = preg_replace_callback('/[\p{Arabic}]/u', function($match) { return strrev($match[0]); }, $text); // Join Arabic characters with unchanged characters $text = join('',array_reverse($arabicCharacters[0])); }
Explanation:
- The regular expression
'/[\p{Arabic}]/u' is used to match Arabic characters within the text.
- We then use
preg_replace_callback() to reverse each Arabic character found in the text while leaving non-Arabic characters unchanged.
- Finally, we join the reversed Arabic characters with other characters and assign the result back to the
$text variable.
This modification ensures that only Arabic characters are reversed for RTL formatting, while other characters such as numbers and letters remain unchanged in their original order.
Make sure to test this modification thoroughly to ensure it works as expected with your PDF generation process in WordPress.
Regards,
-
This reply was modified 2 years, 3 months ago by
WP Swings.