Issue- Dompdf is not supporting Font-Family

Author - Umang Pasricha

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.

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

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