adding font to mPDF

后端 未结 6 1086
失恋的感觉
失恋的感觉 2020-12-14 02:32

I\'m getting the following error when I try and generate a PDF using the mPDF class:

TTF file \"C:/wamp/www/inc/mpdf/ttfonts/verdana.ttf\": invalid checksum          


        
6条回答
  •  情书的邮戳
    2020-12-14 03:18

    Following are the steps to add new font family in mpdf library:

    1. Download the font zip and unzip it.
    2. Add new newFont.ttf font file(s) to this location /mpdf/ttfonts folder.
    3. Edit /mpdf/config_fonts.php OR /mpdf/src/config/FontVariables.php to add an entry to the $this->fontdata array for the new font file(s). Like:

      $this->fontdata = array(
          "newFont" => array(
          'R' => "newFont-Regular.ttf",
          'B' => "newFont-Bold.ttf",
          'I' => "newFont-Italic.ttf",
          'BI' => "newFont-BoldItalic.ttf",
      ),
      
    4. font-family: 'newFont'; is now available in the stylesheets.

    5. $mpdfObj = new mPDF('', '', 'newFont'); $mpdfObj->SetFont('newFont');

    6. Now your new font is added.

提交回复
热议问题