在Laravel应用中将MALAYALAM字体添加到MPDF中

发布于 2025-01-26 09:04:45 字数 1574 浏览 4 评论 0原文

我在Laravel应用程序中使用MPDF。我的PDF文件都带有英语和马拉雅拉姆语。但是马拉雅拉姆语内容无法正确加载。我尝试添加新字体,但是它总是显示缺少OTL Table错误。这是我的代码。

config/pdf.php

return [
'mode'                  => 'utf-8',
'format'                => 'A4',
'author'                => '',
'subject'               => '',
'keywords'              => '',
'creator'               => 'Laravel Pdf',
'display_mode'          => 'fullpage',
//'tempDir'               => base_path('../temp/'),
'tempDir'               => __DIR__.'/../temp/',
//'tempDir'               => __DIR__.'/../storage/framework/pdf/',
'pdf_a'                 => false,
'pdf_a_auto'            => false,
'icc_profile_path'      => '',

'font_path' => base_path('resources/fonts/'),
'font_data' => [
    'malayalam' => [
        'R'  => 'ECBThinkal.ttf',    // regular font
        'B'  => 'ECBThinkal.ttf',       // optional: bold font
        'I'  => 'ECBThinkal.ttf',     // optional: italic font
        'BI' => 'ECBThinkal.ttf', // optional: bold-italic font
        'useOTL' => 0xFF,    
        'useKashida' => 75, 
    ]
    
   ]
];

view.blade.php

<html>
   <?php header('Content-Type: text/html; charset=utf-8');?>
<head>
<style>
    body {
        font-family: 'malayalam', sans-serif;
    }
</style>

我没有粘贴完整代码。当我尝试创建PDF时,它会返回错误无法设置字体“ d:\ xampp \ htdocs \ xxxxx \ resources/fonts/fonts/ecbthinkal.ttf”以使用otl”,因为它不包括OTL表(或至少不包括OTL表) GDEF表)。

也尝试了其他一些字体,但此错误仍显示。

I am using mPDF in my Laravel application. My pdf file comes with both English and Malayalam languages. But Malayalam content not loading properly. I tried to add new font, but it's always showing missing OTL table error. Here is my code.

config/pdf.php

return [
'mode'                  => 'utf-8',
'format'                => 'A4',
'author'                => '',
'subject'               => '',
'keywords'              => '',
'creator'               => 'Laravel Pdf',
'display_mode'          => 'fullpage',
//'tempDir'               => base_path('../temp/'),
'tempDir'               => __DIR__.'/../temp/',
//'tempDir'               => __DIR__.'/../storage/framework/pdf/',
'pdf_a'                 => false,
'pdf_a_auto'            => false,
'icc_profile_path'      => '',

'font_path' => base_path('resources/fonts/'),
'font_data' => [
    'malayalam' => [
        'R'  => 'ECBThinkal.ttf',    // regular font
        'B'  => 'ECBThinkal.ttf',       // optional: bold font
        'I'  => 'ECBThinkal.ttf',     // optional: italic font
        'BI' => 'ECBThinkal.ttf', // optional: bold-italic font
        'useOTL' => 0xFF,    
        'useKashida' => 75, 
    ]
    
   ]
];

view.blade.php

<html>
   <?php header('Content-Type: text/html; charset=utf-8');?>
<head>
<style>
    body {
        font-family: 'malayalam', sans-serif;
    }
</style>

I am not pasting full code. When I try to create pdf it returns error Unable to set font "D:\xampp\htdocs\xxxxx\resources/fonts//ECBThinkal.ttf" to use OTL as it does not include OTL tables (or at least not a GDEF table).

Tried some other fonts also, but still this error is showing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

×纯※雪 2025-02-02 09:04:45

我想这就是您在配置中所缺少的。

'autoLangToFont'        => true,

参考: https://mpdf.github.io/fonts-languages/自动font-selection.html

I guess this is what you are missing in your config.

'autoLangToFont'        => true,

Reference: https://mpdf.github.io/fonts-languages/automatic-font-selection.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文