Sam Joni
Sam Joni

Reputation: 159

TCPDF doesn't show non-latin characters when loading views inside pdf

I've spent a lot of time looking for a package that can show Arabic characters inside pdf files, when I finally found that I ran into another issue.

I'm using TCPDF package in laravel 4 to retrieve a view inside a pdf file and output it, my view contains Arabic characters which TCPDF is not able to show, instead of the texts I get "????"

Note that when I used the Text() method for TCPDF and inserted Arabic letters it showed correctly since I'm setting my font to freeserif, but that is not the same case when I loaded a blade view, have a look to my code:

   $view = View::make('myView')->with('data',$data)->render();
            $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

            $pdf->SetPrintHeader(false);
            $pdf->SetPrintFooter(false);
            $pdf->SetFont('freeserif');
            $pdf->AddPage();

           $pdf->writeHTML($view, true, false, false, false, '');

            $pdf->Output('example_048.pdf', 'I');

Upvotes: 0

Views: 520

Answers (1)

Andrei
Andrei

Reputation: 882

I solved similar issue by commenting out

font-family:'Times New Roman';

from my css.

Upvotes: 0

Related Questions