I have tamil font in my Laravel Blade View, It is working perfectly in Web page but not in pdf, When I download pdf the tamil words shuffled

huangapple go评论76阅读模式
英文:

I have tamil font in my Laravel Blade View, It is working perfectly in Web page but not in pdf, When I download pdf the tamil words shuffled

问题

I used Tamil font Noto Sans but when I am trying to generate pdf, the tamil words mismatch in pdf.
This is What I wrote in web page "முகவரி", but in pdf it generates like this "மீகவரி".

This is my head tag of my blade view in laravel:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

//I also tried akruti1.ttf by downloading it and added it to my public directory but it does not load in my project::

<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil&display=swap" rel="stylesheet">
<title>Proforma Report</title>
<style>
    body {
        font-family: 'Noto Sans Tamil', sans-serif;
    }
</style>

//This is my body tag:

<div>
    <label>1. விண்ணப்பதாரர் பெயர்<br>
        Name of the Applicant</label>
</div>
<div>
    <textarea></textarea>
</div>
英文:

I used Tamil font Noto Sans but when I am trying to generate pdf, the tamil words mismatch in pdf.
This is What I wrote in web page "முகவரி", but in pdf it generate like this "மீகவரி".

This is my head tag of my blade view in laravel:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

//I also tried akruti1.ttf by downloading it and added on my public directory but it does not load in my project::

&lt;link href=&quot;https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt;

&lt;title&gt;Proforma Report&lt;/title&gt;
&lt;style&gt;
    body {
        font-family: &#39;Noto Sans Tamil&#39;, sans-serif;
    }
&lt;/style&gt;

//This is my body tag:

&lt;div&gt;
    &lt;label&gt;1. விண்ணப்பதாரர் பெயர்&lt;br&gt;
        Name of the Applicant&lt;/label&gt;
&lt;/div&gt;
&lt;div&gt;
    &lt;textarea&gt;&lt;/textarea&gt;
&lt;/div&gt;

答案1

得分: 0

在您的Blade中,请尝试修改head标签部分如下:

<head>
    <title>Proforma Report</title>
    <style>
        @font-face {
            font-family: 'Noto Sans Tamil';
            font-style: normal;
            font-weight: 400;
            src: url('{{ public_path('fonts/NotoSansTamil-Regular.ttf') }}') format('truetype');
        }
        body {
            font-family: 'Noto Sans Tamil', sans-serif;
        }
    </style>
</head>
英文:

In your Blade, try modifying the head tag section to the following.

&lt;head&gt;
    &lt;title&gt;Proforma Report&lt;/title&gt;
    &lt;style&gt;
        @font-face {
            font-family: &#39;Noto Sans Tamil&#39;;
            font-style: normal;
            font-weight: 400;
            src: url(&#39;{{ public_path(&#39;fonts/NotoSansTamil-Regular.ttf&#39;) }}&#39;) format(&#39;truetype&#39;);
        }
        body {
            font-family: &#39;Noto Sans Tamil&#39;, sans-serif;
        }
    &lt;/style&gt;
&lt;/head&gt;

huangapple
  • 本文由 发表于 2023年5月17日 18:22:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76271062.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定