Php 如何使用laravel在DOMPDF中显示印地语字体?

Php 如何使用laravel在DOMPDF中显示印地语字体?,php,html,laravel-5,dompdf,Php,Html,Laravel 5,Dompdf,这是幼虫中的pdf刀片文件。它给你什么?在pdf文件中标记 @section('css') <meta name="viewport" content="width=device-width, initial-scale=1" > <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="https://fonts.googleapis.

这是幼虫中的pdf刀片文件。它给你什么?在pdf文件中标记

@section('css')
    <meta name="viewport" content="width=device-width, initial-scale=1" >
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
    <style>
        @font-face {
            font-family: 'Noto Sans', sans-serif;
            font-style: normal;
            font-weight: 400;
        }
    </style>
@endsection
@section('js')
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
@endsection

       <div class="container">
            <h2>Leave Request Information</h2>
            <h3>Month - {{$month}} {{$year}}</h3>
            <br/>

            @if(isset($leavesRequest) && count($leavesRequest)>0)

                <table style="width:100%" border="1" cellspacing="0">
                    <thead>
                    <tr>
                        <th>S No.</th>
                        <th>अध्यापक कर्मचारी का नाम और पद</th>
                        <th>Name of school</th>
                        <th>Leave Type</th>
                        <th>Leave Status</th>
                        <th>Year</th>
                        <th>Month</th>
                        <th>Total Days</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i = 0; ?>
                    @foreach($leavesRequest as $status)
                        <?php ++$i; ?>
                        <tr>
                            <td style="text-align: center"><?php echo $i;?></td>
                            <td style="text-align: center"><?php echo $status->teacher->name;?></td>
                            <td style="text-align: center"><?php echo $status->school->name;?></td>
                            <td style="text-align: center">{{$status->leave_type}}</td>
                            <td style="text-align: center">{{$status->leave_status}}</td>
                            <td style="text-align: center">{{$status->leave_year}}</td>
                            <td style="text-align: center">{{$status->month_name}}</td>
                            <td style="text-align: center">{{$status->total_days}}</td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>

            @else

                No data found

            @endif

        </div>
@节('css')
@字体{
字体系列:“无衬线”,无衬线;
字体风格:普通;
字体大小:400;
}
@端部
@节('js')
@端部
请假信息
月-{{$Month}{{$year}

@如果(isset($leavesRequest)和计数($leavesRequest)>0) 是的。 अध्यापक कर्मचारी का नाम और पद 学校名称 休假类型 休假状态 年 月 总天数 @foreach($leavesRequestas$status) {{$status->leave_type} {{$status->leave_status} {{$status->leave_year} {{$status->month_name} {{$status->total_days} @endforeach @否则 没有找到任何数据 @恩迪夫
生成的PDF如下所示:

我发现两个问题:

  • 在引用字体时,不指定devanagari子集
  • 谷歌字体提供的默认字体子集通常只包括拉丁字符(iso-8859-1)。这是出于性能原因。要包含devanagari字符,字体参考应如下所示:

    <link href="https://fonts.googleapis.com/css?family=Noto+Sans&subset=devanagari" rel="stylesheet">
    
    
    
  • 实际上,您没有指定要使用该字体
  • 您附加到页面的唯一样式如下所示:

    <style>
        @font-face {
            font-family: 'Noto Sans', sans-serif;
            font-style: normal;
            font-weight: 400;
        }
    </style>
    
    
    @字体{
    字体系列:“无衬线”,无衬线;
    字体风格:普通;
    字体大小:400;
    }
    
    但是这个CSS用于引用字体文件,而不是告诉HTML呈现程序(dompdf)使用字体。您可以删除该代码。要实际使用文档中的字体,可以使用以下样式:

    <style>
      * { font-family: Noto Sans, sans-serif; }
    </style>
    
    
    *{font-family:Noto-Sans,Sans-serif;}
    
    一些相关资源:


    最后一个注意事项:我建议使用最新版本的dompdf(目前为0.7.0),因为字体支持随着每个版本而改进。当前版本中存在一些已知的、未解决的问题,这些问题可能会影响文本的呈现方式()