title: Laravel domPDF arabic characters generate PDF error
body: <p>In my project, I want to extract a certain page into a PDF file. the page is mostly in the Arabic language.</p>
  <p>I am using <a href="https://github.com/barryvdh/laravel-dompdf" rel="nofollow noreferrer">barryvdh/laravel-dompdf</a>
  On the first try, there were no characters showing, only question marks instead.</p>
  <p>After digging around, I found that I should add the following CSS to my blade page:</p>
  <pre><code>* { 
      font-family: DejaVu Sans, sans-serif; 
      direction: rtl;
  }
  </code></pre>
  <p>now the Arabic letters are showing in the PDF but their order is inverted (ABC is CBA).
  after another round of research, I found a solution somewhere that I should add the following into my <code>dompdf/dompdf/src/Renderer/Text.php</code> right before</p>
  <pre><code>if (strtolower($style-&gt;direction) == 'rtl') {
      preg_match_all('/./us', $text, $ar);
      $text = join('',array_reverse($ar[0]));
  }
  
  // this is added here to know where exactly i put this code
  $this-&gt;_canvas-&gt;text($x, $y, $text
  </code></pre>
  <p>this works and inverts back the text as it should be, but now the letters are separated... (Arabic letters belonging to the same word are connected)</p>
  <p>ex: البناء is showing as ‫ا ل ب ن ا ء</p>
  <p>this is a known issue for this library that is still not resolved. one of the commentators suggested using the composer library <code>chehivskiy/i18n-arabic‬</code> and use it as <code>new \I18N_Arabic('Glyphs')</code></p>
  <p>But I keep getting a class not found error. this library does not have any namespaces.</p>
  <p>can anyone help me to either find a library that works to transform Arabic HTML to PDF, or maybe try to find a way to fix this library for it to work, or perhaps suggest a way to use a composer non-Laravel library such as <code>chehivskiy/i18n-arabic‬</code> in a Laravel project.</p>
  <p>Thank you so much.</p>