Search code examples
javascriptphphtmlwebweb-applications

generate pdf support arabic language


I want to generate pdf file from my php script that support utf-8 "arabic language" like -> "السلام عليكم " that support RTL i make small search and i found some library like fpdf but it's aint support arabic and also tpdf and i found tcpdf but it's need as i "think" using laravel in my project ? i am not using MVC i just using normal web development .


Solution

  • If you want to programtically generate the pdf and send it in email attachment the TCPDF library is the best solution for you. The TCPDF provides fonts for Arabic and Farsi. However, it looks like the TCPDF does not support RTL.

    I would also suggest you to give DOMPDF a try. DOMPDF generates PDF with HTML with ease. Read more here: https://github.com/dompdf/dompdf

    I have used both to generate the PDF for all kind of non-latin chars.

    EDIT: Don't forget to add dir="rtl" in the html. Please read more here: https://www.w3.org/International/questions/qa-html-dir

    Also, please show your code if you can. So I can help you more.