gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-31 21:52:16 25 4
gpt4 key购买 nike

这是幼虫中的 pdf Blade 文件。它给 ?在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>

生成的 PDF 如下所示:

Sample PDF Output

最佳答案

我看到两个问题:

  1. 您在引用字体时不指定天城体子集。

Google Fonts 提供的默认字体子集通常仅包含拉丁字符 (iso-8859-1)。这是出于性能原因。要包含梵文字符,您的字体引用应如下所示:

<link href="https://fonts.googleapis.com/css?family=Noto+Sans&subset=devanagari" rel="stylesheet">
  1. 您实际上并未指定要使用该字体。

您附加到页面的唯一样式如下:

<style>
@font-face {
font-family: 'Noto Sans', sans-serif;
font-style: normal;
font-weight: 400;
}
</style>

但是您用来引用字体文件的这个 CSS 并没有告诉 HTML 渲染器 (dompdf) 使用该字体。您可以删除该代码。要在文档中实际使用字体,您可以使用以下样式:

<style>
* { font-family: Noto Sans, sans-serif; }
</style>

一些相关资源:


最后一个注意事项:我建议使用最新版本的 dompdf(当前为 0.7.0),因为每个版本都会改​​进字体支持。当前版本中存在一些已知但 Unresolved 问题,这些问题可能会影响文本的呈现方式 (see issue #655)。

关于php - 如何使用 laravel 在 DOMPDF 中显示印地语字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39408764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com