Issue in HTML to PDF generation in laravel in Gujarati

179 Views Asked by At

I have used wkhtmltopdf and barryvdh/laravel-snappy package in laravel version 10 for generate pdf reports and report is in Gujarati Shruti language. Issue is report works fine in local system but when we upload it on server it’s not displayed.

We also find that if we use php artisan serve command then it got dependencies what’s required to load fonts and working fine.

At server we can’t use php artisan serve command and that causing the problem.

$getevidence = $this->reportRepository->downloadReport($request);
$pdf = PDF::loadView('pages.Report.downloadReportNew', compact('getevidence'))->setPaper('a4')->setOrientation('portrait');
$current = Carbon::now()->format('YmdHs').'pdf.pdf';
$pdf->save(public_path('Report-data/').$current);

It should work with Gujarati Language

1

There are 1 best solutions below

0
Nehal On

Try adding your fonts Shruti in /public/fonts folder and add following css to it.

@font-face {
    font-family: 'Shruti';
    src: url('/fonts/Shruti.ttf') format('truetype');
}

body {
    font-family: 'Shruti', sans-serif;
}