Rubberduck1337106092
Rubberduck1337106092

Reputation: 1344

How to include a barcode font in DOMPDF

I would like to add a barcode font on a label, I generate the label in PDF.

when I generate the label in PDF it does not work but in my view it works fine.

I use DOMPDF for laravel.

View: enter image description here

PDF: enter image description here

I include my font like this:

<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>

What am I doing wrong?

Upvotes: 1

Views: 2776

Answers (1)

Rubberduck1337106092
Rubberduck1337106092

Reputation: 1344

Found the solution:

First there was a typo in my style:

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

The ; at the first line had to be a comma.

It then gave me a different error pointing to the /storage/fonts not found.

I created the directory and placed my BarcodeFont.ttf in there and it worked.

Thanks alot everybody who tried helping me with this!

Upvotes: 1

Related Questions