Convert html to pdf with arabic

I need to create a pdf file with php from html, I use html2pdf, but it does not support Arabic. I need something easy to use.

and thanks in advance

+4
source share
3 answers

You can try with TCPDF , I used it in the past and completed the task, one of its listed functions

  • Unicode and Right-To-Left Languages ​​UTF-8

So, I suppose that covers the Arabic language.

UPDATE :
Yes, they support it, they even have an online example:

Persian and Arabic in RTL document: PDF and its source PHP

+7
source

The following is an example of working with the Arabic language.

<?php include("MPDF57/mpdf.php"); $mpdf=new mPDF('utf-8'); $html = ' <p> قال الرئيس الامريكي جورج بوش في حديث متلفز في الذكرى الرابعة للغزو الامريكي للعراق ان الاولوية حاليا لاعادة الامن للعراق.</p> <p> هل ستسفر الجهود الدبلوماسية الجارية عن حلول؟ وكيف تنظر للاتهامات لبعض هذه الدول بالتدخل في الشأن العراقي، والتورط في دعم عمليات العنف؟ والى اي مدى يبدو الوضع في العراق انعكاسا للصراعات الإقليمية في المنطقة؟</p> <p> وادان البيت الابيض "بشدة" تفجير ايلات فيما اعربت وزارة الخارجية الروسية عن "ادانتها الشديدة" للحادث" واصفة اياه بـ"المتطرف" الذي استهدف "مدنيين مسالمين".</p> test '; $html = iconv("windows-1256","UTF-8//IGNORE",$html); $mpdf=new mPDF('ar','A4','','',32,25,27,25,16,13); // From mPDF 5.1 onwards you must set: $mpdf->SetDirectionality('rtl'); $mpdf->mirrorMargins = true; //$mpdf->SetDisplayMode('fullpage'); //$mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text $mpdf->WriteHTML($html); $mpdf->Output(); 
+4
source

Try mPDF , it is very easy to use, and it amazingly supports RTL languages ​​like Arabic, Hebrew, Farsi / Persian, Urdu and Pashto, and this example demonstrates this.

+3
source

Source: https://habr.com/ru/post/1436899/


All Articles