Issue- Dompdf is not supporting Font-Family

|
| By Webner

How to resolve the issue of Dompdf is not supporting Font-Family

Problem: We have html with some inline css and we are also importing some files on blade file where we are rendering our html but font families are not supported by Dompdf.

Solution: Dompdf only support some of font families. You can see those font-families in ‘/vendor/dompdf/dompdf/lib/fonts’ file.

So one way to allow pdf to support more fonts is-

Step 1: Download font you want to add to dompdf.

Step 2: Copy its .ttf file and add this file in ‘/public/fonts/’ or you can add it to some other path.

Step 3: Add this code to blade file where html is rendered-

@font-face {
  font-family: 'Georgia';
  font-style: normal;
  font-weight: normal;
  src: url('https://proposalways.com/font/Georgia/Georgia.ttf') format('truetype');
}

Note: It only takes absolute paths.

Now when dompdf will support Georgia font-family.

Leave a Reply

Your email address will not be published. Required fields are marked *