我试图生成一个包含尼泊尔字体的PDF文件,但是在生成PDF之后,它呈现了??? (问号)代替确切的尼泊尔字体

时间:2018-06-28 14:34:21

标签: php laravel dompdf

我正在使用   Laravel 5.6,   Dompdf 0.8.2和   Barryvdh 0.8.2

这是我的控制器:

namespace App\Http\Controllers\Admin;
use App\Model\IncomingLetter;
use Illuminate\Support\Facades\Auth;
use PDF;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Maatwebsite\Excel\Facades\Excel;

class ExportExcel extends Controller
{
    public function incomingDatabaseExportPDF(Request $request)
    {

        if (Auth::user()->utype == 1 || Auth::user()->utype == 2) {
            $results = IncomingLetter::orderBy('created_at', 'DESC')->get();
        } else {
            $results = IncomingLetter::where('data_from', '=', Auth::user()->kshetra)->orderBy('created_at', 'DESC')->get();
        }

        $this->data('title', $this->title('Incoming Letter Export - PDF'));
        if (count($results)>0) {

            $pdf = PDF::loadView('Admin.Pages.Management.Incoming-letters.incoming-letter-pdf',compact('results'));
            $pdf->setPaper('A4','landscape');

            return $pdf->download('incoming-letter.pdf');
        } else{
            return redirect()->back();
        }
}

这是我的来信-pdf.blade.php,它是包含PDF内容的刀片模板

<!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <style type="text/css" media="all">
            @font-face {
                font-family: 'preeti';
                font-weight: normal;
                font-style: normal;
                font-variant: normal; 

   src:url('../../../../../../vendor/dompdf/dompdf/lib/fonts/PREETI.TTF');;
            }
            @page {
                size: A4 portrait; /* can use also 'landscape' for orientation */
                margin: 1.0in;
                margin-left: 0.75in;
                margin-right: 0.52in;
                border: thin solid black;
                font-family: 'preeti';
                font-size: 11;
                text-align: justify;
            }
            @bottom-center {
                content: element(footer);
            }

            @top-center {
                content: element(header);
            }
            table {
                border-collapse: collapse;
            }

            table {
                border: 1px solid black;
            }
        </style>
    </head>
    <body>
        <center><h4>दर्ता प्रणाली</h4></center>
    <table border="1" width="100%" >
        <tr>
            <th>आ.व.</th>
            <th>द.न&zwnj;</th>
            <th>मिति</th>
            <th>पत्रको मिति</th>
            <th>पठाउने</th>
            <th>विषय</th>
            <th>कैफियत </th>
            <th>कार्यालय</th>
        </tr>
        @if(count($results)>0)
            @forelse($results as $key=>$letter)
                <tr>
                    <td>{{$letter->aa_ba}}</td>
                    <td>{{$letter->da_na}}</td>
                    <td>{{$letter->date}}</td>
                    <td class="center">{{$letter->patramiti}}</td>
                    <td class="center">{{$letter->sender}}</td>
                    <td class="center">{{$letter->subject}}</td>
                    <td class="center">{{$letter->kaifiyat}}</td>
                    <td class="center">{{$letter->office}}</td>
                </tr>
            @empty
            @endforelse
        @endif
    </table>
    <p style="page-break-after:always;"/>
</body>
</html>

这是我的输出:

This image contains the output of above code.

我还使用了尼泊尔字体家族preeti preeti.ttf作为自定义字体。

0 个答案:

没有答案