Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding new font in dompdf

Tags:

fonts

dompdf

To add new font Arvo in DOMPdf I updated file dompdf_font_family_cache.dist and added following code -

'arvo' => 
array (
  'normal' => DOMPDF_FONT_DIR . 'Arvo-Regular',
  'bold' => DOMPDF_FONT_DIR . 'Arvo-Bold',
  'italic' => DOMPDF_FONT_DIR . 'Arvo-Italic',
  'bold_italic' => DOMPDF_FONT_DIR . 'Arvo-BoldItalic',
),

I included font files in lib/fonts directory I added style sheet in html -

font-family: arvo;

But new font is not added in result pdf. Please help me to resolve this problem.

like image 214
Raju Thakur Avatar asked Sep 06 '12 08:09

Raju Thakur


2 Answers

Instead of manually modifying dompdf_font_family_cache you should use load_font.php or (in dompdf 0.6.0 beta 3) the web-based installer located at www/fonts.php.

like image 97
Raju Thakur Avatar answered Nov 16 '22 16:11

Raju Thakur


In my case, I solved it:

  1. Installing load_font.php from here: https://github.com/dompdf/utils/blob/master/load_font.php

    1.1. Create a new file in your root folder from your project and save.

    1.2. Next, run this line in your command line: php load_font.php FONTNAME FONTPATH/fonts/EXAMPLEFONT.ttf

  2. Search and open the file dompdf_font_family_cache.php and update your file in this way (eg):

    'poppins' => 
    array(
    
    'normal' => $rootDir . '\lib\fonts\Poppins-Light_0',
    
    ),
    
  3. Go to your PDF and use your font.

These few steps maybe solve the issue. :)

like image 2
Samii Avatar answered Nov 16 '22 16:11

Samii