div.mpdf_index_main { font-family: xbriyaz; } div.mpdf_index_entry { font-family: xbriyaz; } div.mpdf_index_letter { font-family: xbriyaz; }

mPDF

RTL Languages

English

Please note that I do not understand any of the scripts below. The texts are borrowed from News websites, and I have used words and bits of phrases just to demonstrate the program.‎

Hebrew (pangram)‎

דג סקרן שט בים מאוכזב ולפתע מצא חברה

או הנסה אלהים, לבוא לקחת לו גוי מקרב גוי, במסת באתת ובמופתים ובמלחמה וביד חזקה ובזרוע נטויה, ובמוראים גדלים: ככל אשר-עשה לכם יהוה אלהיכם, במצרים--לעיניך

לכן חכו לי נאם יהוה ליום קומי לעד, כי משפטי לאסף גוים לקבצי ממלכות, לשפך עליהם זעמי כל חרון אפי, כי באש קנאתי תאכל כל הארץ

שפן אכל קצת גזר בטעם חסה, ודי.

Arabic

الامريكي جورج بوش في حديث متلفز في الذكرى الرابعة للغزو الامريكي للعراق ان الاولوية حاليا لاعادة الامن للعراق.

هل ستسفر الجهود الدبلوماسية الجارية عن حلول؟ وكيف تنظر للاتهامات لبعض هذه الدول بالتدخل في الشأن العراقي، والتورط في دعم عمليات العنف؟ والى اي مدى يبدو الوضع في العراق انعكاسا للصراعات الإقليمية في المنطقة؟

وادان البيت الابيض "بشدة" تفجير ايلات فيما اعربت وزارة الخارجية الروسية عن "ادانتها الشديدة" للحادث" واصفة اياه بـ"المتطرف" الذي استهدف "مدنيين مسالمين".

واضافت وزارة الخارجية الروسية في بيانها: "من المؤسف ان يأتي هذا الحادث بينما تبذل الجهود لتخطي الازمة الفلسطينية الداخلية".

ودعت موسكو السلطات الفلسطينية الى "بذل كل ما يمكن من اجل احتواء مظاهر التطرف التي لا مبرر لها والتي لا تفيد مصالح الشعب الفلسطيني على الامد الطويل".

ودعت موسكو السلطات الفلسطينية الى "بذل كل ما ودعت موسكو السلطات الفلسطينية الى "بذل كل

ودعت موسكو السلطات الفلسطينية الى ودعت موسكو السلطات الفلسطينية الى "بذل كل ما يمكن من اجل

كما ادان الفارو دي سوتو مبعوث الامم المتحدة الخاص الى الشرق الاوسط العملية وقال "انه كان هجوما على اشخاص عاديين كانوا يقومون بنشاطهم اليومي وهذا امر لا يمكن تبريره".

Farsi / Persian (fa)‎

محمد البرادعی رئيس آژانس بين المللی انرژی اتمی پيشنهاد کرده است تهران برنامه جنجالی غنی سازی اورانيوم را متوقف کند و غرب نيز اجرای تحريم های تنبيهی مورد تائيد سازمان ملل متحد را به تعويق بياندازد.

جورج بوش، در چهارمین سالگرد اشغال عراق می گوید استراتژی استقرار نیروهای آمریکایی بیشتری در بغداد، مدتی طول خواهد کشید.

آمریکا ویزای رئیس جمهور ایران را به منظور حضور وی در جلسه رای گیری شورای امنیت برای قطعنامه تازه علیه این کشور صادر کرد.

Urdu

جسٹس افتخار کی جبری رخصت پر لاہورہائی کورٹ کے ایک اور سندھ میں کئی سول جج مستعفی ہوگئے ہیں۔

چیف جسٹس کی سرگرمیاں محدود کرنے اور پولیس تعیناتی کے حکم نامے پر دستخط کرکے غلط کیا: جنرل مشرف

‪Pashto (ps)‬

په کابل او کندهار کې دوو ځانمرگو بريدونو لږ تر لږه يو ماشوم وژلى او اته تنه نور ىې ټپيان کړي.

ه عراق کې يوه تازه نظر شمېرنه ښيي چې عراقيان په زياتېدونکي توگه د حالاتو په اړه بدبينه دي او د بې باوري احساس کوي، خو خپل هيواد يوموټى غواړي.

Symbols

©®™µ•…′″§<>≤≥°−±÷⁄׃∫∑∞√≈≠≡∏¬∩∂

ΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ

αβγδεζηθικλμνξοπρςστυφχψω

←↑→↓↔◊♣♥♦

Dingbats

§<>→↔♣♥♦

win-1252

¢€©®™‰µ·•…§ß‹›«»‘’“”‚„<>–—ˆ˜°±÷×¼½¾ƒ¬†‡

ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØŒŠÙÚÛÜÝŸ

àáâãäåæçèéêëìíîïðñòôõöøœšùúûüýþÿ

Bidirectional text

Text alignment, unless specified, is neutral and therefore dictated by the \'direction\' of the paragraph.

Ttext is analysed at the end of every block element (div, p, td). If the text contains RTL characters, those characters and words are reversed according to the Unicode BiDirectional algorithm e.g.

وادان البيت الابيض "بشدة" تفجير with some english in the middle ايلات فيما اعربت وزارة

To set the \'directionality\' of the whole document e.g. to reverse default alignment, tables, lists etc. you can set the dir attribute or the direction CSS property on the HTML or BODY tag to \'rtl\' e.g.

<body style="direction: rtl">

<body dir="rtl">

or you can use $mpdf->SetDirectionality(\'rtl\');

The document now has a baseline direction; this determines the:
- text-alignment in blocks for which text-align has not been specifically set
- layout of mirrored page-margins, columns, ToC and Indexes, headers and footers
- base direction can be set by any of:
	- $mpdf->SetDirectionality(\'rtl\');
	- <html dir="rtl" or style="direction: rtl;">
	- <body dir="rtl" or style="direction: rtl;">
Base direction is an inherited CSS property, so will affect all content, unless...
- direction can be set for all HTML block elements e.g.
	<DIV><P><TABLE><TD><UL><LI> etc using
	- CSS property < style="direction: rtl;">
NOTE
- block/table margins/paddings are NOT reversed by direction
	NB mPDF <5.1 reversed the margins/paddings for blocks when RTL set.
- language (either CSS "lang", using Autofont, or through initial set-up e.g. $mpdf = new mPDF(\'ar\') )
	no longer affects direction in any way.
	- config_cp.php has been changed as a result; any values of "dir" set here are now ineffective
- default text-align is now as per CSS spec: "a nameless value which is dependent on direction"
	NB default text-align removed from default stylesheet in config.php
- once text-align is specified, it is respected and inherited
	NB mPDF <5.1 reversed the text-align property for all blocks when RTL set.
- the configurable value is depracated, as it is no longer required
- the algorithm for handling bidirectioal text was substantially re-written/improved in mPDF v 6.0

Tables

Tables are automatically transposed when the direction is rtl:‎

الامريكي

الامريكي

الامريكي
قال الرئيس الرئيس
قال

قال الرئيس الامريكي جورج بوش في حديث متلفز

قال الرئيس الامريكي جورج بوش في حديث متلفز

قال

الرئيس

الرئيس

قال

الرئيس

الرئيس

الرئيس

قال الرئيس الرئيس
قال الرئيس الرئيس
قال الرئيس الرئيس
قال الرئيس الرئيس

 

Lists

Lists will automatically reverse as well (note the use of list-style to set numbering):‎

  1. قال الرئيس
  2. الامريكي
    • جورج بوش في جورج بوش في جورج بوش في جورج بوش في جورج بوش في جورج
    • حديث متلفز
      • في الذكرى الرابعة
      • للغزو الامريكي
  3. للعراق ان الاولوية حاليا
  4. لاعادة الامن للعراق
'; //============================================================== // Set Header and Footer $h = array ( 'odd' => array ( 'R' => array ( 'content' => '{PAGENO}', 'font-size' => 8, 'font-style' => 'B', ), 'L' => array ( 'content' => "\xd9\x82\xd8\xa7\xd9\x84 \xd8\xa7\xd9\x84\xd8\xb1\xd8\xa6\xd9\x8a\xd8\xb3", 'font-size' => 8, 'font-style' => 'B', ), 'line' => 1, ), 'even' => array ( 'L' => array ( 'content' => '{PAGENO}', 'font-size' => 8, 'font-style' => 'B', ), 'R' => array ( 'content' => "\xd9\x82\xd8\xa7\xd9\x84 \xd8\xa7\xd9\x84\xd8\xb1\xd8\xa6\xd9\x8a\xd8\xb3", 'font-size' => 8, 'font-style' => 'B', ), 'line' => 1, ), ); $f = array ( 'odd' => array ( 'L' => array ( 'content' => '{DATE Y-m-d}', 'font-size' => 8, 'font-style' => 'BI', ), 'C' => array ( 'content' => '- {PAGENO} -', 'font-size' => 8, ), 'R' => array ( 'content' => "\xd8\xa7\xd9\x84\xd8\xb1\xd8\xa6\xd9\x8a\xd8\xb3", 'font-size' => 8, ), 'line' => 1, ), 'even' => array ( 'L' => array ( 'content' => "\xd8\xa7\xd9\x84\xd8\xb1\xd8\xa6\xd9\x8a\xd8\xb3", 'font-size' => 8, 'font-style' => 'B', ), 'C' => array ( 'content' => '- {PAGENO} -', 'font-size' => 8, ), 'R' => array ( 'content' => '{DATE Y-m-d}', 'font-size' => 8, 'font-style' => 'BI', ), 'line' => 1, ), ); //============================================================== // Create Index entries from random words in $html // Split $html into words $a =preg_split('/<(.*?)>/ms',$html,-1,PREG_SPLIT_DELIM_CAPTURE); $html = ''; foreach($a as $i => $e) { if($i%2==0) { $words = preg_split('/([\s,\.]+)/',$e,-1,PREG_SPLIT_DELIM_CAPTURE); foreach($words as $w) { $y = rand(1,10); // every tenth word // If it is just a word use it as an index entry if (preg_match("/^(&#x[0]{0,1}6[0-9a-f][0-9a-f];){4,30}$/i",$w) && ($y > 8)) { $content = trim($w); $html .= ''; } $html .= $w; } } else { $html .= '<'.$e.'>'; } } //============================================================== //============================================================== require_once __DIR__ . '/../vendor/autoload.php'; $mpdf = new mPDF('','A4','','',32,25,27,25,16,13); $mpdf->SetDirectionality('rtl'); $mpdf->mirrorMargins = true; $mpdf->SetDisplayMode('fullpage','two'); $mpdf->autoLangToFont = true; $mpdf->defaultPageNumStyle = 'arabic-indic'; $mpdf->setHeader($h); $mpdf->setFooter($f); $mpdf->debug = true; $stylesheet = file_get_contents('mpdfstyletables.css'); $mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text $mpdf->WriteHTML($html); $mpdf->AddPage(); $mpdf->SetColumns(2,'J'); $mpdf->WriteHTML($html); $mpdf->SetColumns(0); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // INDEX $html = '

Index

'; $mpdf->WriteHTML($html); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ $mpdf->Output(); exit; //============================================================== //============================================================== //==============================================================