如何在DOMPDF中包含条形码字体

问题描述 投票:1回答:1

我想在标签上添加条形码字体,我用PDF生成标签。

当我在PDF中生成标签时它不起作用,但在我看来它工作正常。

我使用DOMPDF作为laravel。

查看:enter image description here

PDF:enter image description here

我包括我的字体:

<style>
    @font-face {
        font-family: 'barcode_fontregular';
        src: url('{{url('/css/barcode/BarcodeFont.ttf')}}') format('woff2'),
             url('{{url('/css/barcode/BarcodeFont.ttf')}}') format('woff');
             url('{{url('/css/barcode/BarcodeFont.ttf')}}') format('truetype');
        font-weight: normal;
        font-style: normal;

    }
</style>

我究竟做错了什么?

php laravel pdf fonts
1个回答
1
投票

找到解决方案:

首先,我的风格有一个错字:

url('{{url('/css/barcode/BarcodeFont.ttf')}}') format('woff');
url('{{url('/css/barcode/BarcodeFont.ttf')}}') format('truetype');

的;在第一行必须是逗号。

然后它给了我一个指向未找到/ storage / fonts的错误。

我创建了目录并将我的BarcodeFont.ttf放在那里,它工作正常。

非常感谢所有帮助我的人!

© www.soinside.com 2019 - 2024. All rights reserved.