Sunday, October 2, 2016

How to write Bengali (Bangla বাংলা) unicode PDF file using PHP?

How to write Bengali (Bangla বাংলা) unicode PDF file using PHP?

Solution:  Now a days Bengali is using a lot on Computer based system. So developers need generate Bangla PDF file frequently.  But generating Bangla pdf is not so easy as it is complex script. In this tutorial I will use mpdf 6.0  library for PDF generation and nikosh.ttf as Bangla unicode font. If you are not familiar with mpdf, but using fpdf, don't worry. mpdf is similar with fpdf with very little change.

Step 01: First of all, we need to download mpdf library and nikosh.ttf unicode Bangla font.

Step 02: Now, copy nikosh.ttf font file on /ttfonts folder of mpdf library.




Step 03: For add any font the major task is to change config_fonts.php file of mpdf. As Bangla has similarity with Indic language so I will add Bangla font (Nikosh) information after Indic.   






That's it. We are done. Now we can generate Bangla PDF files using php.
Here is a simple php example of Bangla pdf file generation:








If you don't want to go through those process, you could just download my modified mpdf from here
Or you could just download config_fonts.php and example file individualy


2 comments:

  1. how to initialize by FPDF on this

    ReplyDelete
    Replies
    1. Thanks for visiting my blog and sorry for late. Unfortunately I could not manage to write bangla using FPDF. You could use mpdf instead of fpdf. Mpdf is very similar to fpdf. Actually mpdf is made from fpdf.

      Delete