Hagar Maher
Hagar Maher

Reputation: 33

PDF Package in Laravel is not writing Arabic letters

I am using this function to print payslip as PDF, it's working for English content but the client has his data in Arabic so instead of Arabic letters it displays "?????".

I tried many fonts that supports Arabic but it's still not working.

This is the controller function:

public function printPdf(Payslip $payslip)
{
  $month_year = $payslip->month_year;
  $employee = Employee::get();
 
  PDF::setOptions([
     'dpi' => 150,
     'defaultFont' => 'arial', // A font that supports Arabic
     'tempDir' => storage_path('temp')
  ]);
    
  $pdf = PDF::loadview('backend.salary.payslip.pdf', $payslip->toArray(), $employee);
  return $pdf->stream();
}

Upvotes: 0

Views: 123

Answers (1)

Kevin Bui
Kevin Bui

Reputation: 3045

Which package are you using?

We have a feature to printing pdf files in different languages too. We use mpdf/mpdf, works like a charm.

Upvotes: 0

Related Questions